diff --git a/src/main/java/io/github/cottonmc/templates/Templates.java b/src/main/java/io/github/cottonmc/templates/Templates.java index 2aaf313..8ee81a3 100644 --- a/src/main/java/io/github/cottonmc/templates/Templates.java +++ b/src/main/java/io/github/cottonmc/templates/Templates.java @@ -2,9 +2,11 @@ package io.github.cottonmc.templates; import io.github.cottonmc.templates.api.TemplateInteractionUtil; import io.github.cottonmc.templates.block.TemplateBlock; +import io.github.cottonmc.templates.block.TemplateFenceBlock; import io.github.cottonmc.templates.block.TemplateSlabBlock; import io.github.cottonmc.templates.block.TemplateSlopeBlock; import io.github.cottonmc.templates.block.TemplateEntity; +import io.github.cottonmc.templates.block.TemplateWallBlock; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; @@ -28,13 +30,15 @@ public class Templates implements ModInitializer { public static final String MODID = "templates"; public static final Block CUBE = Registry.register(Registries.BLOCK, id("cube"), new TemplateBlock(TemplateInteractionUtil.makeSettings())); - public static final Block SLOPE = Registry.register(Registries.BLOCK, id("slope"), new TemplateSlopeBlock(TemplateInteractionUtil.makeSettings())); + public static final Block FENCE = Registry.register(Registries.BLOCK, id("fence"), new TemplateFenceBlock(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 WALL = Registry.register(Registries.BLOCK, id("wall"), new TemplateWallBlock(TemplateInteractionUtil.makeSettings())); //N.B. it's fine to make your own block entity type instead of gluing additional blocks to this one public static final BlockEntityType TEMPLATE_BLOCK_ENTITY = Registry.register( Registries.BLOCK_ENTITY_TYPE, id("slope"), - FabricBlockEntityTypeBuilder.create(Templates::makeTemplateBlockEntity, CUBE, SLOPE, SLAB).build(null) + FabricBlockEntityTypeBuilder.create(Templates::makeTemplateBlockEntity, CUBE, FENCE, SLAB, SLOPE, WALL).build(null) ); @SuppressWarnings("unused") @@ -53,8 +57,10 @@ public class Templates implements ModInitializer { @Override public void onInitialize() { Registry.register(Registries.ITEM, id("cube"), new BlockItem(CUBE, new Item.Settings())); - Registry.register(Registries.ITEM, id("slope"), new BlockItem(SLOPE, new Item.Settings())); + Registry.register(Registries.ITEM, id("fence"), new BlockItem(FENCE, 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("wall"), new BlockItem(WALL, new Item.Settings())); } public static Identifier id(String path) { @@ -68,7 +74,9 @@ public class Templates implements ModInitializer { private static void fillItemGroup(ItemGroup.DisplayContext ctx, ItemGroup.Entries ent) { ent.add(CUBE); - ent.add(SLOPE); + ent.add(FENCE); ent.add(SLAB); + ent.add(SLOPE); + ent.add(WALL); } } diff --git a/src/main/java/io/github/cottonmc/templates/TemplatesClient.java b/src/main/java/io/github/cottonmc/templates/TemplatesClient.java index 199dc28..06f386a 100644 --- a/src/main/java/io/github/cottonmc/templates/TemplatesClient.java +++ b/src/main/java/io/github/cottonmc/templates/TemplatesClient.java @@ -54,15 +54,24 @@ public class TemplatesClient implements ClientModInitializer { ModelLoadingRegistry.INSTANCE.registerResourceProvider(rm -> provider); //block models ModelLoadingRegistry.INSTANCE.registerVariantProvider(rm -> provider); //item models - BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), Templates.CUBE, Templates.SLOPE, Templates.SLAB); + BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), Templates.CUBE, Templates.FENCE, Templates.SLAB, Templates.SLOPE, Templates.WALL); 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_side_special"), new RetexturedJsonModelUnbakedModel(Templates.id("block/fence_side"))); + provider.addTemplateModel(Templates.id("fence_inventory_special"), new RetexturedJsonModelUnbakedModel(Templates.id("block/fence_inventory"))); provider.addTemplateModel(Templates.id("slab_bottom_special"), new RetexturedJsonModelUnbakedModel(Templates.id("block/slab_bottom"))); provider.addTemplateModel(Templates.id("slab_top_special"), new RetexturedJsonModelUnbakedModel(Templates.id("block/slab_top"))); provider.addTemplateModel(Templates.id("slope_special"), new RetexturedMeshUnbakedModel(Templates.id("block/slope_base"), SlopeBaseMesh::make)); + provider.addTemplateModel(Templates.id("wall_inventory_special"), new RetexturedJsonModelUnbakedModel(Templates.id("block/wall_inventory"))); + provider.addTemplateModel(Templates.id("wall_post_special"), new RetexturedJsonModelUnbakedModel(Templates.id("block/wall_post"))); + provider.addTemplateModel(Templates.id("wall_side_special"), new RetexturedJsonModelUnbakedModel(Templates.id("block/wall_side"))); + provider.addTemplateModel(Templates.id("wall_side_tall_special"), new RetexturedJsonModelUnbakedModel(Templates.id("block/wall_side_tall"))); provider.assignItemModel(Templates.id("cube_special"), Templates.CUBE); + provider.assignItemModel(Templates.id("fence_inventory_special"), Templates.FENCE); provider.assignItemModel(Templates.id("slope_special"), Templates.SLOPE); provider.assignItemModel(Templates.id("slab_bottom_special"), Templates.SLAB); + provider.assignItemModel(Templates.id("wall_inventory_special"), Templates.WALL); } } diff --git a/src/main/java/io/github/cottonmc/templates/block/TemplateFenceBlock.java b/src/main/java/io/github/cottonmc/templates/block/TemplateFenceBlock.java new file mode 100644 index 0000000..3108c50 --- /dev/null +++ b/src/main/java/io/github/cottonmc/templates/block/TemplateFenceBlock.java @@ -0,0 +1,78 @@ +package io.github.cottonmc.templates.block; + +import com.google.common.base.MoreObjects; +import io.github.cottonmc.templates.Templates; +import io.github.cottonmc.templates.api.TemplateInteractionUtil; +import net.minecraft.block.Block; +import net.minecraft.block.BlockEntityProvider; +import net.minecraft.block.BlockState; +import net.minecraft.block.FenceBlock; +import net.minecraft.block.ShapeContext; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.state.StateManager; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; + +public class TemplateFenceBlock extends FenceBlock implements BlockEntityProvider { + public TemplateFenceBlock(Settings settings) { + super(settings); + setDefaultState(TemplateInteractionUtil.setDefaultStates(getDefaultState())); + } + + @Nullable + @Override + public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { + return Templates.TEMPLATE_BLOCK_ENTITY.instantiate(pos, state); + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(TemplateInteractionUtil.appendProperties(builder)); + } + + @Override + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + return TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit); + } + + @Override + public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) { + TemplateInteractionUtil.onStateReplaced(state, world, pos, newState, moved); + super.onStateReplaced(state, world, pos, newState, moved); + } + + @Override + public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { + TemplateInteractionUtil.onPlaced(world, pos, state, placer, stack); + } + + @Override + public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ctx) { + return MoreObjects.firstNonNull(TemplateInteractionUtil.getCollisionShape(state), super.getCollisionShape(state, view, pos, ctx)); + } + + @Override + public boolean emitsRedstonePower(BlockState state) { + return TemplateInteractionUtil.emitsRedstonePower(state); + } + + @Override + public int getWeakRedstonePower(BlockState state, BlockView view, BlockPos pos, Direction dir) { + return TemplateInteractionUtil.getWeakRedstonePower(state, view, pos, dir); + } + + @Override + public int getStrongRedstonePower(BlockState state, BlockView view, BlockPos pos, Direction dir) { + return TemplateInteractionUtil.getStrongRedstonePower(state, view, pos, dir); + } +} diff --git a/src/main/java/io/github/cottonmc/templates/block/TemplateWallBlock.java b/src/main/java/io/github/cottonmc/templates/block/TemplateWallBlock.java new file mode 100644 index 0000000..b9f0610 --- /dev/null +++ b/src/main/java/io/github/cottonmc/templates/block/TemplateWallBlock.java @@ -0,0 +1,121 @@ +package io.github.cottonmc.templates.block; + +import com.google.common.base.MoreObjects; +import io.github.cottonmc.templates.Templates; +import io.github.cottonmc.templates.api.TemplateInteractionUtil; +import io.github.cottonmc.templates.mixin.WallBlockAccessor; +import net.minecraft.block.Block; +import net.minecraft.block.BlockEntityProvider; +import net.minecraft.block.BlockState; +import net.minecraft.block.ShapeContext; +import net.minecraft.block.WallBlock; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.block.enums.WallShape; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.state.StateManager; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + +public class TemplateWallBlock extends WallBlock implements BlockEntityProvider { + public TemplateWallBlock(Settings settings) { + super(settings); + setDefaultState(TemplateInteractionUtil.setDefaultStates(getDefaultState())); + + initNewShapemaps(); //WallBlock specific haxx + } + + @Nullable + @Override + public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { + return Templates.TEMPLATE_BLOCK_ENTITY.instantiate(pos, state); + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(TemplateInteractionUtil.appendProperties(builder)); + } + + @Override + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + return TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit); + } + + @Override + public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) { + TemplateInteractionUtil.onStateReplaced(state, world, pos, newState, moved); + super.onStateReplaced(state, world, pos, newState, moved); + } + + @Override + public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { + TemplateInteractionUtil.onPlaced(world, pos, state, placer, stack); + } + + @Override + public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ctx) { + return MoreObjects.firstNonNull(TemplateInteractionUtil.getCollisionShape(state), getNewShape(state, newCollisionShapeMap)); + } + + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ctx) { + return getNewShape(state, newShapeMap); + } + + @Override + public boolean emitsRedstonePower(BlockState state) { + return TemplateInteractionUtil.emitsRedstonePower(state); + } + + @Override + public int getWeakRedstonePower(BlockState state, BlockView view, BlockPos pos, Direction dir) { + return TemplateInteractionUtil.getWeakRedstonePower(state, view, pos, dir); + } + + @Override + public int getStrongRedstonePower(BlockState state, BlockView view, BlockPos pos, Direction dir) { + return TemplateInteractionUtil.getStrongRedstonePower(state, view, pos, dir); + } + + //Shapemap heck (WallBlock has a map keyed on BlockState, but since we add more blockstates most of those map lookups fail) + + protected static record ShapeKey(boolean up, WallShape north, WallShape east, WallShape south, WallShape west) { + static ShapeKey fromBlockstate(BlockState state) { + return new ShapeKey( + state.get(WallBlock.UP), + state.get(WallBlock.NORTH_SHAPE), + state.get(WallBlock.EAST_SHAPE), + state.get(WallBlock.SOUTH_SHAPE), + state.get(WallBlock.WEST_SHAPE) + ); + } + } + + protected Map newShapeMap = new HashMap<>(); + protected Map newCollisionShapeMap = new HashMap<>(); + + protected void initNewShapemaps() { + initNewShapemap(((WallBlockAccessor) this).templates$getShapeMap(), newShapeMap); + initNewShapemap(((WallBlockAccessor) this).templates$getCollisionShapeMap(), newCollisionShapeMap); + } + + protected void initNewShapemap(Map oldShapeMap, Map newShapeMap) { + oldShapeMap.forEach((state, shape) -> newShapeMap.putIfAbsent(ShapeKey.fromBlockstate(state), shape)); + } + + protected VoxelShape getNewShape(BlockState state, Map shapes) { + return shapes.getOrDefault(ShapeKey.fromBlockstate(state), VoxelShapes.empty()); + } +} diff --git a/src/main/java/io/github/cottonmc/templates/mixin/WallBlockAccessor.java b/src/main/java/io/github/cottonmc/templates/mixin/WallBlockAccessor.java new file mode 100644 index 0000000..6cc3290 --- /dev/null +++ b/src/main/java/io/github/cottonmc/templates/mixin/WallBlockAccessor.java @@ -0,0 +1,15 @@ +package io.github.cottonmc.templates.mixin; + +import net.minecraft.block.BlockState; +import net.minecraft.block.WallBlock; +import net.minecraft.util.shape.VoxelShape; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.Map; + +@Mixin(WallBlock.class) +public interface WallBlockAccessor { + @Accessor("shapeMap") Map templates$getShapeMap(); + @Accessor("collisionShapeMap") Map templates$getCollisionShapeMap(); +} diff --git a/src/main/java/io/github/cottonmc/templates/model/RetexturedJsonModelBakedModel.java b/src/main/java/io/github/cottonmc/templates/model/RetexturedJsonModelBakedModel.java index 17d3348..a6b21e1 100644 --- a/src/main/java/io/github/cottonmc/templates/model/RetexturedJsonModelBakedModel.java +++ b/src/main/java/io/github/cottonmc/templates/model/RetexturedJsonModelBakedModel.java @@ -15,6 +15,7 @@ import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView; import net.minecraft.block.BlockState; import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.BakedQuad; +import net.minecraft.client.render.model.ModelBakeSettings; import net.minecraft.client.texture.Sprite; import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.item.BlockItem; @@ -29,15 +30,17 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.random.Random; import net.minecraft.world.BlockRenderView; +import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import java.util.function.Supplier; public class RetexturedJsonModelBakedModel extends ForwardingBakedModel { - public RetexturedJsonModelBakedModel(BakedModel baseModel, TemplateAppearanceManager tam, Function spriteLookup, BlockState itemModelState) { + public RetexturedJsonModelBakedModel(BakedModel baseModel, TemplateAppearanceManager tam, ModelBakeSettings settings, Function spriteLookup, BlockState itemModelState) { this.wrapped = baseModel; this.tam = tam; + this.facePermutation = MeshTransformUtil.facePermutation(settings); this.itemModelState = itemModelState; for(int i = 0; i < DIRECTIONS.length; i++) { @@ -47,6 +50,7 @@ public class RetexturedJsonModelBakedModel extends ForwardingBakedModel { } private final TemplateAppearanceManager tam; + private final Map facePermutation; private final Sprite[] specialSprites = new Sprite[DIRECTIONS.length]; private final BlockState itemModelState; @@ -105,8 +109,8 @@ public class RetexturedJsonModelBakedModel extends ForwardingBakedModel { bounds.remap( emitter, specialSprites[i], - key.appearance().getSprite(DIRECTIONS[i]), - key.appearance().getBakeFlags(DIRECTIONS[i]) + key.appearance().getSprite(facePermutation.get(DIRECTIONS[i])), + key.appearance().getBakeFlags(facePermutation.get(DIRECTIONS[i])) ); break; } diff --git a/src/main/java/io/github/cottonmc/templates/model/RetexturedJsonModelUnbakedModel.java b/src/main/java/io/github/cottonmc/templates/model/RetexturedJsonModelUnbakedModel.java index 20bd8c8..4bb1538 100644 --- a/src/main/java/io/github/cottonmc/templates/model/RetexturedJsonModelUnbakedModel.java +++ b/src/main/java/io/github/cottonmc/templates/model/RetexturedJsonModelUnbakedModel.java @@ -45,6 +45,7 @@ public class RetexturedJsonModelUnbakedModel implements UnbakedModel { return new RetexturedJsonModelBakedModel( baker.bake(parent, modelBakeSettings), TemplatesClient.provider.getOrCreateTemplateApperanceManager(spriteLookup), + modelBakeSettings, spriteLookup, itemModelState ); diff --git a/src/main/resources/assets/templates/blockstates/fence.json b/src/main/resources/assets/templates/blockstates/fence.json new file mode 100644 index 0000000..f320179 --- /dev/null +++ b/src/main/resources/assets/templates/blockstates/fence.json @@ -0,0 +1,48 @@ +{ + "multipart": [ + { + "apply": { + "model": "templates:fence_post_special" + } + }, + { + "apply": { + "model": "templates:fence_side_special", + "uvlock": true + }, + "when": { + "north": "true" + } + }, + { + "apply": { + "model": "templates:fence_side_special", + "uvlock": true, + "y": 90 + }, + "when": { + "east": "true" + } + }, + { + "apply": { + "model": "templates:fence_side_special", + "uvlock": true, + "y": 180 + }, + "when": { + "south": "true" + } + }, + { + "apply": { + "model": "templates:fence_side_special", + "uvlock": true, + "y": 270 + }, + "when": { + "west": "true" + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/templates/blockstates/wall.json b/src/main/resources/assets/templates/blockstates/wall.json new file mode 100644 index 0000000..d0fd5ac --- /dev/null +++ b/src/main/resources/assets/templates/blockstates/wall.json @@ -0,0 +1,90 @@ +{ + "multipart": [ + { + "apply": { + "model": "templates:wall_post_special" + }, + "when": { + "up": "true" + } + }, + { + "apply": { + "model": "templates:wall_side_special", + "uvlock": true + }, + "when": { + "north": "low" + } + }, + { + "apply": { + "model": "templates:wall_side_special", + "uvlock": true, + "y": 90 + }, + "when": { + "east": "low" + } + }, + { + "apply": { + "model": "templates:wall_side_special", + "uvlock": true, + "y": 180 + }, + "when": { + "south": "low" + } + }, + { + "apply": { + "model": "templates:wall_side_special", + "uvlock": true, + "y": 270 + }, + "when": { + "west": "low" + } + }, + { + "apply": { + "model": "templates:wall_side_tall_special", + "uvlock": true + }, + "when": { + "north": "tall" + } + }, + { + "apply": { + "model": "templates:wall_side_tall_special", + "uvlock": true, + "y": 90 + }, + "when": { + "east": "tall" + } + }, + { + "apply": { + "model": "templates:wall_side_tall_special", + "uvlock": true, + "y": 180 + }, + "when": { + "south": "tall" + } + }, + { + "apply": { + "model": "templates:wall_side_tall_special", + "uvlock": true, + "y": 270 + }, + "when": { + "west": "tall" + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/templates/lang/en_us.json b/src/main/resources/assets/templates/lang/en_us.json index 8e22537..7820876 100644 --- a/src/main/resources/assets/templates/lang/en_us.json +++ b/src/main/resources/assets/templates/lang/en_us.json @@ -2,6 +2,8 @@ "itemGroup.templates.tab": "Templates", "block.templates.cube": "Cube Template", + "block.templates.fence": "Fence Template", "block.templates.slope": "Slope Template", - "block.templates.slab": "Slab Template" + "block.templates.slab": "Slab Template", + "block.templates.wall": "Wall Template" } \ No newline at end of file diff --git a/src/main/resources/assets/templates/models/block/fence_inventory.json b/src/main/resources/assets/templates/models/block/fence_inventory.json new file mode 100644 index 0000000..fc199a2 --- /dev/null +++ b/src/main/resources/assets/templates/models/block/fence_inventory.json @@ -0,0 +1,243 @@ +{ + "parent": "minecraft:block/block", + "textures": { + "down": "templates:templates_special/down", + "up": "templates:templates_special/up", + "north": "templates:templates_special/north", + "south": "templates:templates_special/south", + "west": "templates:templates_special/west", + "east": "templates:templates_special/east" + }, + "display": { + "gui": { + "rotation": [30, 135, 0], + "translation": [0, 0, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "rotation": [0, 90, 0], + "translation": [0, 0, 0], + "scale": [0.5, 0.5, 0.5] + } + }, + "elements": [ + { + "from": [6, 0, 0], + "to": [10, 16, 4], + "faces": { + "down": { + "uv": [6, 0, 10, 4], + "texture": "#down", + "cullface": "down" + }, + "up": { + "uv": [6, 0, 10, 4], + "texture": "#up" + }, + "north": { + "uv": [6, 0, 10, 16], + "texture": "#north" + }, + "south": { + "uv": [6, 0, 10, 16], + "texture": "#south" + }, + "west": { + "uv": [0, 0, 4, 16], + "texture": "#west" + }, + "east": { + "uv": [0, 0, 4, 16], + "texture": "#east" + } + }, + "__comment": "Left post" + }, + { + "from": [6, 0, 12], + "to": [10, 16, 16], + "faces": { + "down": { + "uv": [6, 12, 10, 16], + "texture": "#down", + "cullface": "down" + }, + "up": { + "uv": [6, 12, 10, 16], + "texture": "#up" + }, + "north": { + "uv": [6, 0, 10, 16], + "texture": "#north" + }, + "south": { + "uv": [6, 0, 10, 16], + "texture": "#south" + }, + "west": { + "uv": [12, 0, 16, 16], + "texture": "#west" + }, + "east": { + "uv": [12, 0, 16, 16], + "texture": "#east" + } + }, + "__comment": "Right post" + }, + { + "from": [7, 12, 0], + "to": [9, 15, 16], + "faces": { + "down": { + "uv": [7, 0, 9, 16], + "texture": "#down" + }, + "up": { + "uv": [7, 0, 9, 16], + "texture": "#up" + }, + "west": { + "uv": [0, 1, 16, 4], + "texture": "#west" + }, + "east": { + "uv": [0, 1, 16, 4], + "texture": "#east" + } + }, + "__comment": "Top bar" + }, + { + "from": [7, 12, -2], + "to": [9, 15, 0], + "faces": { + "down": { + "uv": [7, 0, 9, 2], + "texture": "#down" + }, + "up": { + "uv": [7, 14, 9, 16], + "texture": "#up" + }, + "north": { + "uv": [7, 1, 9, 4], + "texture": "#north" + }, + "west": { + "uv": [14, 1, 16, 4], + "texture": "#west" + }, + "east": { + "uv": [0, 1, 2, 4], + "texture": "#east" + } + }, + "__comment": "Top bar left" + }, + { + "from": [7, 12, 16], + "to": [9, 15, 18], + "faces": { + "down": { + "uv": [7, 14, 9, 16], + "texture": "#down" + }, + "up": { + "uv": [7, 0, 9, 2], + "texture": "#up" + }, + "south": { + "uv": [7, 1, 9, 4], + "texture": "#south" + }, + "west": { + "uv": [0, 1, 2, 4], + "texture": "#west" + }, + "east": { + "uv": [14, 1, 16, 4], + "texture": "#east" + } + }, + "__comment": "Top bar right" + }, + { + "from": [7, 6, 0], + "to": [9, 9, 16], + "faces": { + "down": { + "uv": [7, 0, 9, 16], + "texture": "#down" + }, + "up": { + "uv": [7, 0, 9, 16], + "texture": "#up" + }, + "west": { + "uv": [0, 7, 16, 10], + "texture": "#west" + }, + "east": { + "uv": [0, 7, 16, 10], + "texture": "#east" + } + }, + "__comment": "Lower bar" + }, + { + "from": [7, 6, -2], + "to": [9, 9, 0], + "faces": { + "down": { + "uv": [7, 0, 9, 2], + "texture": "#down" + }, + "up": { + "uv": [7, 14, 9, 16], + "texture": "#up" + }, + "north": { + "uv": [7, 7, 9, 10], + "texture": "#north" + }, + "west": { + "uv": [14, 7, 16, 10], + "texture": "#west" + }, + "east": { + "uv": [0, 7, 2, 10], + "texture": "#east" + } + }, + "__comment": "Lower bar left" + }, + { + "from": [7, 6, 16], + "to": [9, 9, 18], + "faces": { + "down": { + "uv": [7, 14, 9, 16], + "texture": "#down" + }, + "up": { + "uv": [7, 0, 9, 2], + "texture": "#up" + }, + "south": { + "uv": [7, 7, 9, 10], + "texture": "#south" + }, + "west": { + "uv": [0, 7, 2, 10], + "texture": "#west" + }, + "east": { + "uv": [14, 7, 16, 10], + "texture": "#east" + } + }, + "__comment": "Lower bar right" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/templates/models/block/fence_post.json b/src/main/resources/assets/templates/models/block/fence_post.json new file mode 100644 index 0000000..b182901 --- /dev/null +++ b/src/main/resources/assets/templates/models/block/fence_post.json @@ -0,0 +1,46 @@ +{ + "parent": "minecraft:block/block", + "textures": { + "down": "templates:templates_special/down", + "up": "templates:templates_special/up", + "north": "templates:templates_special/north", + "south": "templates:templates_special/south", + "west": "templates:templates_special/west", + "east": "templates:templates_special/east" + }, + "elements": [ + { + "from": [6, 0, 6], + "to": [10, 16, 10], + "faces": { + "down": { + "uv": [6, 6, 10, 10], + "texture": "#down", + "cullface": "down" + }, + "up": { + "uv": [6, 6, 10, 10], + "texture": "#up", + "cullface": "up" + }, + "north": { + "uv": [6, 0, 10, 16], + "texture": "#north" + }, + "south": { + "uv": [6, 0, 10, 16], + "texture": "#south" + }, + "west": { + "uv": [6, 0, 10, 16], + "texture": "#west" + }, + "east": { + "uv": [6, 0, 10, 16], + "texture": "#east" + } + }, + "__comment": "Center post" + } + ] +} diff --git a/src/main/resources/assets/templates/models/block/fence_side.json b/src/main/resources/assets/templates/models/block/fence_side.json new file mode 100644 index 0000000..9d76779 --- /dev/null +++ b/src/main/resources/assets/templates/models/block/fence_side.json @@ -0,0 +1,68 @@ +{ + "textures": { + "down": "templates:templates_special/down", + "up": "templates:templates_special/up", + "north": "templates:templates_special/north", + "south": "templates:templates_special/south", + "west": "templates:templates_special/west", + "east": "templates:templates_special/east" + }, + "elements": [ + { + "from": [7, 12, 0], + "to": [9, 15, 9], + "faces": { + "down": { + "uv": [7, 0, 9, 9], + "texture": "#down" + }, + "up": { + "uv": [7, 0, 9, 9], + "texture": "#up" + }, + "north": { + "uv": [7, 1, 9, 4], + "texture": "#north", + "cullface": "north" + }, + "west": { + "uv": [0, 1, 9, 4], + "texture": "#west" + }, + "east": { + "uv": [0, 1, 9, 4], + "texture": "#east" + } + }, + "__comment": "top bar" + }, + { + "from": [7, 6, 0], + "to": [9, 9, 9], + "faces": { + "down": { + "uv": [7, 0, 9, 9], + "texture": "#down" + }, + "up": { + "uv": [7, 0, 9, 9], + "texture": "#up" + }, + "north": { + "uv": [7, 7, 9, 10], + "texture": "#north", + "cullface": "north" + }, + "west": { + "uv": [0, 7, 9, 10], + "texture": "#west" + }, + "east": { + "uv": [0, 7, 9, 10], + "texture": "#east" + } + }, + "__comment": "lower bar" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/templates/models/block/wall_inventory.json b/src/main/resources/assets/templates/models/block/wall_inventory.json new file mode 100644 index 0000000..57bb3e0 --- /dev/null +++ b/src/main/resources/assets/templates/models/block/wall_inventory.json @@ -0,0 +1,91 @@ +{ + "parent": "block/block", + "textures": { + "down": "templates:templates_special/down", + "up": "templates:templates_special/up", + "north": "templates:templates_special/north", + "south": "templates:templates_special/south", + "west": "templates:templates_special/west", + "east": "templates:templates_special/east" + }, + "display": { + "gui": { + "rotation": [30, 135, 0], + "translation": [0, 0, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "rotation": [0, 90, 0], + "translation": [0, 0, 0], + "scale": [0.5, 0.5, 0.5] + } + }, + "elements": [ + { + "from": [4, 0, 4], + "to": [12, 16, 12], + "faces": { + "down": { + "uv": [4, 4, 12, 12], + "texture": "#down", + "cullface": "down" + }, + "up": { + "uv": [4, 4, 12, 12], + "texture": "#up" + }, + "north": { + "uv": [4, 0, 12, 16], + "texture": "#north" + }, + "south": { + "uv": [4, 0, 12, 16], + "texture": "#south" + }, + "west": { + "uv": [4, 0, 12, 16], + "texture": "#west" + }, + "east": { + "uv": [4, 0, 12, 16], + "texture": "#east" + } + }, + "__comment": "Center post" + }, + { + "from": [5, 0, 0], + "to": [11, 13, 16], + "faces": { + "down": { + "uv": [5, 0, 11, 16], + "texture": "#down", + "cullface": "down" + }, + "up": { + "uv": [5, 0, 11, 16], + "texture": "#up" + }, + "north": { + "uv": [5, 3, 11, 16], + "texture": "#north", + "cullface": "north" + }, + "south": { + "uv": [5, 3, 11, 16], + "texture": "#south", + "cullface": "south" + }, + "west": { + "uv": [0, 3, 16, 16], + "texture": "#west" + }, + "east": { + "uv": [0, 3, 16, 16], + "texture": "#east" + } + }, + "__comment": "Full wall" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/templates/models/block/wall_post.json b/src/main/resources/assets/templates/models/block/wall_post.json new file mode 100644 index 0000000..a1c67ff --- /dev/null +++ b/src/main/resources/assets/templates/models/block/wall_post.json @@ -0,0 +1,40 @@ +{ + "parent": "minecraft:block/block", + "textures": { + "down": "templates:templates_special/down", + "up": "templates:templates_special/up", + "north": "templates:templates_special/north", + "south": "templates:templates_special/south", + "west": "templates:templates_special/west", + "east": "templates:templates_special/east" + }, + "elements": [ + { + "from": [4, 0, 4], + "to": [12, 16, 12], + "faces": { + "down": { + "texture": "#down", + "cullface": "down" + }, + "up": { + "texture": "#up", + "cullface": "up" + }, + "north": { + "texture": "#north" + }, + "south": { + "texture": "#south" + }, + "west": { + "texture": "#west" + }, + "east": { + "texture": "#east" + } + }, + "__comment": "Center post" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/templates/models/block/wall_side.json b/src/main/resources/assets/templates/models/block/wall_side.json new file mode 100644 index 0000000..e609034 --- /dev/null +++ b/src/main/resources/assets/templates/models/block/wall_side.json @@ -0,0 +1,37 @@ +{ + "parent": "minecraft:block/block", + "textures": { + "down": "templates:templates_special/down", + "up": "templates:templates_special/up", + "north": "templates:templates_special/north", + "south": "templates:templates_special/south", + "west": "templates:templates_special/west", + "east": "templates:templates_special/east" + }, + "elements": [ + { + "from": [5, 0, 0], + "to": [11, 14, 8], + "faces": { + "down": { + "texture": "#down", + "cullface": "down" + }, + "up": { + "texture": "#up" + }, + "north": { + "texture": "#north", + "cullface": "north" + }, + "west": { + "texture": "#west" + }, + "east": { + "texture": "#east" + } + }, + "__comment": "wall" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/templates/models/block/wall_side_tall.json b/src/main/resources/assets/templates/models/block/wall_side_tall.json new file mode 100644 index 0000000..24b29ad --- /dev/null +++ b/src/main/resources/assets/templates/models/block/wall_side_tall.json @@ -0,0 +1,37 @@ +{ + "parent": "minecraft:block/block", + "textures": { + "down": "templates:templates_special/down", + "up": "templates:templates_special/up", + "north": "templates:templates_special/north", + "south": "templates:templates_special/south", + "west": "templates:templates_special/west", + "east": "templates:templates_special/east" + }, + "elements": [ + { + "from": [5, 0, 0], + "to": [11, 16, 8], + "faces": { + "down": { + "texture": "#down", + "cullface": "down" + }, + "up": { + "texture": "#up", + "cullface": "up" + }, + "north": { + "texture": "#north", + "cullface": "north" + }, + "west": { + "texture": "#west" + }, + "east": { + "texture": "#east" + } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/blocks/walls.json b/src/main/resources/data/minecraft/tags/blocks/walls.json new file mode 100644 index 0000000..6c7dc8d --- /dev/null +++ b/src/main/resources/data/minecraft/tags/blocks/walls.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "templates:wall" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/blocks/wooden_fences.json b/src/main/resources/data/minecraft/tags/blocks/wooden_fences.json new file mode 100644 index 0000000..e1ddaef --- /dev/null +++ b/src/main/resources/data/minecraft/tags/blocks/wooden_fences.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "templates:fence" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/templates/advancements/recipes/decorations/templates.json b/src/main/resources/data/templates/advancements/recipes/decorations/templates.json index f0e3ce0..f2df0bf 100644 --- a/src/main/resources/data/templates/advancements/recipes/decorations/templates.json +++ b/src/main/resources/data/templates/advancements/recipes/decorations/templates.json @@ -3,8 +3,10 @@ "rewards": { "recipes": [ "templates:cube", + "templates:fence", "templates:slab", - "templates:slope" + "templates:slope", + "templates:wall" ] }, "criteria": { diff --git a/src/main/resources/data/templates/loot_tables/blocks/fence.json b/src/main/resources/data/templates/loot_tables/blocks/fence.json new file mode 100644 index 0000000..40acdca --- /dev/null +++ b/src/main/resources/data/templates/loot_tables/blocks/fence.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "templates:fence" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/templates/loot_tables/blocks/wall.json b/src/main/resources/data/templates/loot_tables/blocks/wall.json new file mode 100644 index 0000000..ee15aca --- /dev/null +++ b/src/main/resources/data/templates/loot_tables/blocks/wall.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "templates:wall" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/templates/recipes/fence.json b/src/main/resources/data/templates/recipes/fence.json new file mode 100644 index 0000000..1f5fd44 --- /dev/null +++ b/src/main/resources/data/templates/recipes/fence.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "I~I", + "I~I" + ], + "key": { + "I": { + "item": "minecraft:bamboo" + }, + "~": { + "item": "minecraft:string" + } + }, + "result": { + "item": "templates:fence", + "count": 8 + }, + "group": "templates" +} \ No newline at end of file diff --git a/src/main/resources/data/templates/recipes/wall.json b/src/main/resources/data/templates/recipes/wall.json new file mode 100644 index 0000000..59f9996 --- /dev/null +++ b/src/main/resources/data/templates/recipes/wall.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + " ~ ", + "III", + "III" + ], + "key": { + "I": { + "item": "minecraft:bamboo" + }, + "~": { + "item": "minecraft:string" + } + }, + "result": { + "item": "templates:wall", + "count": 8 + }, + "group": "templates" +} \ No newline at end of file diff --git a/src/main/resources/templates.mixins.json b/src/main/resources/templates.mixins.json index e73825d..3f319f8 100644 --- a/src/main/resources/templates.mixins.json +++ b/src/main/resources/templates.mixins.json @@ -3,6 +3,7 @@ "package": "io.github.cottonmc.templates.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ + "WallBlockAccessor", "particles.MixinEntity", "particles.MixinLivingEntity" ],