We have quark posts at home

This commit is contained in:
quat1024 2023-07-06 01:44:00 -04:00
parent 71d21cd98a
commit ea476662d4
8 changed files with 133 additions and 2 deletions

View File

@ -3,10 +3,12 @@ package io.github.cottonmc.templates;
import io.github.cottonmc.templates.api.TemplateInteractionUtil; import io.github.cottonmc.templates.api.TemplateInteractionUtil;
import io.github.cottonmc.templates.block.TemplateBlock; import io.github.cottonmc.templates.block.TemplateBlock;
import io.github.cottonmc.templates.block.TemplateFenceBlock; import io.github.cottonmc.templates.block.TemplateFenceBlock;
import io.github.cottonmc.templates.block.TemplatePostBlock;
import io.github.cottonmc.templates.block.TemplateSlabBlock; import io.github.cottonmc.templates.block.TemplateSlabBlock;
import io.github.cottonmc.templates.block.TemplateSlopeBlock; import io.github.cottonmc.templates.block.TemplateSlopeBlock;
import io.github.cottonmc.templates.block.TemplateEntity; import io.github.cottonmc.templates.block.TemplateEntity;
import io.github.cottonmc.templates.block.TemplateWallBlock; import io.github.cottonmc.templates.block.TemplateWallBlock;
import io.github.cottonmc.templates.block.WaterloggableTemplateBlock;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
@ -31,6 +33,7 @@ public class Templates implements ModInitializer {
public static final Block CUBE = Registry.register(Registries.BLOCK, id("cube"), new TemplateBlock(TemplateInteractionUtil.makeSettings())); public static final Block CUBE = Registry.register(Registries.BLOCK, id("cube"), new TemplateBlock(TemplateInteractionUtil.makeSettings()));
public static final Block FENCE = Registry.register(Registries.BLOCK, id("fence"), new TemplateFenceBlock(TemplateInteractionUtil.makeSettings())); public static final Block FENCE = Registry.register(Registries.BLOCK, id("fence"), new TemplateFenceBlock(TemplateInteractionUtil.makeSettings()));
public static final Block POST = Registry.register(Registries.BLOCK, id("post"), new TemplatePostBlock(TemplateInteractionUtil.makeSettings()));
public static final Block SLAB = Registry.register(Registries.BLOCK, id("slab"), new TemplateSlabBlock(TemplateInteractionUtil.makeSettings())); public static final Block SLAB = Registry.register(Registries.BLOCK, id("slab"), new TemplateSlabBlock(TemplateInteractionUtil.makeSettings()));
public static final Block SLOPE = Registry.register(Registries.BLOCK, id("slope"), new TemplateSlopeBlock(TemplateInteractionUtil.makeSettings())); public static final Block SLOPE = Registry.register(Registries.BLOCK, id("slope"), new TemplateSlopeBlock(TemplateInteractionUtil.makeSettings()));
public static final Block WALL = Registry.register(Registries.BLOCK, id("wall"), new TemplateWallBlock(TemplateInteractionUtil.makeSettings())); public static final Block WALL = Registry.register(Registries.BLOCK, id("wall"), new TemplateWallBlock(TemplateInteractionUtil.makeSettings()));
@ -38,7 +41,7 @@ public class Templates implements ModInitializer {
//N.B. it's fine to make your own block entity type instead of gluing additional blocks to this one //N.B. it's fine to make your own block entity type instead of gluing additional blocks to this one
public static final BlockEntityType<TemplateEntity> TEMPLATE_BLOCK_ENTITY = Registry.register( public static final BlockEntityType<TemplateEntity> TEMPLATE_BLOCK_ENTITY = Registry.register(
Registries.BLOCK_ENTITY_TYPE, id("slope"), Registries.BLOCK_ENTITY_TYPE, id("slope"),
FabricBlockEntityTypeBuilder.create(Templates::makeTemplateBlockEntity, CUBE, FENCE, SLAB, SLOPE, WALL).build(null) FabricBlockEntityTypeBuilder.create(Templates::makeTemplateBlockEntity, CUBE, FENCE, POST, SLAB, SLOPE, WALL).build(null)
); );
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -58,6 +61,7 @@ public class Templates implements ModInitializer {
public void onInitialize() { public void onInitialize() {
Registry.register(Registries.ITEM, id("cube"), new BlockItem(CUBE, new Item.Settings())); Registry.register(Registries.ITEM, id("cube"), new BlockItem(CUBE, new Item.Settings()));
Registry.register(Registries.ITEM, id("fence"), new BlockItem(FENCE, new Item.Settings())); Registry.register(Registries.ITEM, id("fence"), new BlockItem(FENCE, new Item.Settings()));
Registry.register(Registries.ITEM, id("post"), new BlockItem(POST, new Item.Settings()));
Registry.register(Registries.ITEM, id("slab"), new BlockItem(SLAB, new Item.Settings())); Registry.register(Registries.ITEM, id("slab"), new BlockItem(SLAB, new Item.Settings()));
Registry.register(Registries.ITEM, id("slope"), new BlockItem(SLOPE, new Item.Settings())); Registry.register(Registries.ITEM, id("slope"), new BlockItem(SLOPE, new Item.Settings()));
Registry.register(Registries.ITEM, id("wall"), new BlockItem(WALL, new Item.Settings())); Registry.register(Registries.ITEM, id("wall"), new BlockItem(WALL, new Item.Settings()));
@ -75,6 +79,7 @@ public class Templates implements ModInitializer {
private static void fillItemGroup(ItemGroup.DisplayContext ctx, ItemGroup.Entries ent) { private static void fillItemGroup(ItemGroup.DisplayContext ctx, ItemGroup.Entries ent) {
ent.add(CUBE); ent.add(CUBE);
ent.add(FENCE); ent.add(FENCE);
ent.add(POST);
ent.add(SLAB); ent.add(SLAB);
ent.add(SLOPE); ent.add(SLOPE);
ent.add(WALL); ent.add(WALL);

View File

@ -54,7 +54,14 @@ public class TemplatesClient implements ClientModInitializer {
ModelLoadingRegistry.INSTANCE.registerResourceProvider(rm -> provider); //block models ModelLoadingRegistry.INSTANCE.registerResourceProvider(rm -> provider); //block models
ModelLoadingRegistry.INSTANCE.registerVariantProvider(rm -> provider); //item models ModelLoadingRegistry.INSTANCE.registerVariantProvider(rm -> provider); //item models
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), Templates.CUBE, Templates.FENCE, Templates.SLAB, Templates.SLOPE, Templates.WALL); BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(),
Templates.CUBE,
Templates.FENCE,
Templates.POST,
Templates.SLAB,
Templates.SLOPE,
Templates.WALL
);
provider.addTemplateModel(Templates.id("cube_special"), new RetexturedJsonModelUnbakedModel(Templates.id("block/cube"))); provider.addTemplateModel(Templates.id("cube_special"), new RetexturedJsonModelUnbakedModel(Templates.id("block/cube")));
provider.addTemplateModel(Templates.id("fence_post_special"), new RetexturedJsonModelUnbakedModel(Templates.id("block/fence_post"))); provider.addTemplateModel(Templates.id("fence_post_special"), new RetexturedJsonModelUnbakedModel(Templates.id("block/fence_post")));
@ -70,6 +77,7 @@ public class TemplatesClient implements ClientModInitializer {
provider.assignItemModel(Templates.id("cube_special"), Templates.CUBE); provider.assignItemModel(Templates.id("cube_special"), Templates.CUBE);
provider.assignItemModel(Templates.id("fence_inventory_special"), Templates.FENCE); provider.assignItemModel(Templates.id("fence_inventory_special"), Templates.FENCE);
provider.assignItemModel(Templates.id("fence_post_special"), Templates.POST);
provider.assignItemModel(Templates.id("slope_special"), Templates.SLOPE); provider.assignItemModel(Templates.id("slope_special"), Templates.SLOPE);
provider.assignItemModel(Templates.id("slab_bottom_special"), Templates.SLAB); provider.assignItemModel(Templates.id("slab_bottom_special"), Templates.SLAB);
provider.assignItemModel(Templates.id("wall_inventory_special"), Templates.WALL); provider.assignItemModel(Templates.id("wall_inventory_special"), Templates.WALL);

View File

@ -0,0 +1,57 @@
package io.github.cottonmc.templates.block;
import com.google.common.base.MoreObjects;
import io.github.cottonmc.templates.api.TemplateInteractionUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import org.jetbrains.annotations.Nullable;
public class TemplatePostBlock extends WaterloggableTemplateBlock {
public TemplatePostBlock(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(Properties.AXIS, Direction.Axis.Y));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder.add(Properties.AXIS));
}
@Override
public @Nullable BlockState getPlacementState(ItemPlacementContext ctx) {
BlockState sup = super.getPlacementState(ctx);
if(sup != null) sup = sup.with(Properties.AXIS, ctx.getSide().getAxis());
return sup;
}
protected static final VoxelShape SHAPE_X = createCuboidShape(0, 6, 6, 16, 10, 10);
protected static final VoxelShape SHAPE_Y = createCuboidShape(6, 0, 6, 10, 16, 10);
protected static final VoxelShape SHAPE_Z = createCuboidShape(6, 6, 0, 10, 10, 16);
protected VoxelShape shap(BlockState state) {
return switch(state.get(Properties.AXIS)) {
case X -> SHAPE_X;
case Y -> SHAPE_Y;
case Z -> SHAPE_Z;
};
}
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ctx) {
return MoreObjects.firstNonNull(TemplateInteractionUtil.getCollisionShape(state), shap(state));
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ctx) {
return shap(state);
}
}

View File

@ -0,0 +1,19 @@
{
"variants": {
"axis=x": {
"model": "templates:fence_post_special",
"x": 90,
"y": 90,
"uvlock": true
},
"axis=y": {
"model": "templates:fence_post_special",
"uvlock": true
},
"axis=z": {
"model": "templates:fence_post_special",
"uvlock": true,
"x": 90
}
}
}

View File

@ -3,6 +3,7 @@
"block.templates.cube": "Cube Template", "block.templates.cube": "Cube Template",
"block.templates.fence": "Fence Template", "block.templates.fence": "Fence Template",
"block.templates.post": "Post Template",
"block.templates.slope": "Slope Template", "block.templates.slope": "Slope Template",
"block.templates.slab": "Slab Template", "block.templates.slab": "Slab Template",
"block.templates.wall": "Wall Template" "block.templates.wall": "Wall Template"

View File

@ -4,6 +4,7 @@
"recipes": [ "recipes": [
"templates:cube", "templates:cube",
"templates:fence", "templates:fence",
"templates:post",
"templates:slab", "templates:slab",
"templates:slope", "templates:slope",
"templates:wall" "templates:wall"

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "templates:post"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,21 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"I ",
"I~",
"I "
],
"key": {
"I": {
"item": "minecraft:bamboo"
},
"~": {
"item": "minecraft:string"
}
},
"result": {
"item": "templates:post",
"count": 8
},
"group": "templates"
}