From 48e8d07d634a36297446b41ca0b75b3bda00b40e Mon Sep 17 00:00:00 2001 From: quat1024 Date: Thu, 20 Jul 2023 20:25:22 -0400 Subject: [PATCH] Iron trapdoors, sure --- .../github/cottonmc/templates/Templates.java | 11 +-- .../cottonmc/templates/TemplatesClient.java | 2 + .../templates/blockstates/iron_trapdoor.json | 69 +++++++++++++++++++ .../assets/templates/lang/en_us.json | 1 + .../tags/blocks/mineable/pickaxe.json | 6 ++ .../data/minecraft/tags/blocks/trapdoors.json | 6 ++ .../recipes/decorations/templates.json | 1 + .../loot_tables/blocks/iron_trapdoor.json | 19 +++++ .../data/templates/recipes/iron_trapdoor.json | 24 +++++++ 9 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/assets/templates/blockstates/iron_trapdoor.json create mode 100644 src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json create mode 100644 src/main/resources/data/minecraft/tags/blocks/trapdoors.json create mode 100644 src/main/resources/data/templates/loot_tables/blocks/iron_trapdoor.json create mode 100644 src/main/resources/data/templates/recipes/iron_trapdoor.json diff --git a/src/main/java/io/github/cottonmc/templates/Templates.java b/src/main/java/io/github/cottonmc/templates/Templates.java index 46f4f13..ac202d6 100644 --- a/src/main/java/io/github/cottonmc/templates/Templates.java +++ b/src/main/java/io/github/cottonmc/templates/Templates.java @@ -20,10 +20,7 @@ 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; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; +import net.minecraft.block.*; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; @@ -52,13 +49,14 @@ public class Templates implements ModInitializer { //door? (hard cause its a multiblock) public static final Block FENCE = Registry.register(Registries.BLOCK, id("fence") , new TemplateFenceBlock(cp(Blocks.OAK_FENCE))); public static final Block FENCE_GATE = Registry.register(Registries.BLOCK, id("fence_gate") , new TemplateFenceGateBlock(cp(Blocks.OAK_FENCE_GATE))); + public static final Block IRON_TRAPDOOR = Registry.register(Registries.BLOCK, id("iron_trapdoor") , new TemplateTrapdoorBlock(cp(Blocks.IRON_TRAPDOOR), BlockSetType.IRON)); public static final Block LEVER = Registry.register(Registries.BLOCK, id("lever") , new TemplateLeverBlock(cp(Blocks.LEVER))); public static final Block PANE = Registry.register(Registries.BLOCK, id("pane") , new TemplatePaneBlock(cp(Blocks.GLASS_PANE))); public static final Block POST = Registry.register(Registries.BLOCK, id("post") , new TemplatePostBlock(cp(Blocks.OAK_FENCE))); public static final Block PRESSURE_PLATE = Registry.register(Registries.BLOCK, id("pressure_plate"), new TemplatePressurePlateBlock(cp(Blocks.OAK_PRESSURE_PLATE))); public static final Block SLAB = Registry.register(Registries.BLOCK, id("slab") , new TemplateSlabBlock(cp(Blocks.OAK_SLAB))); public static final Block STAIRS = Registry.register(Registries.BLOCK, id("stairs") , new TemplateStairsBlock(cp(Blocks.OAK_STAIRS))); - public static final Block TRAPDOOR = Registry.register(Registries.BLOCK, id("trapdoor") , new TemplateTrapdoorBlock(cp(Blocks.OAK_TRAPDOOR))); + public static final Block TRAPDOOR = Registry.register(Registries.BLOCK, id("trapdoor") , new TemplateTrapdoorBlock(cp(Blocks.OAK_TRAPDOOR), BlockSetType.OAK)); public static final Block WALL = Registry.register(Registries.BLOCK, id("wall") , new TemplateWallBlock(TemplateInteractionUtil.makeSettings())); public static final Block SLOPE = Registry.register(Registries.BLOCK, id("slope") , new TemplateSlopeBlock(TemplateInteractionUtil.makeSettings())); //30 degree slope (shallow/deep) @@ -75,6 +73,7 @@ public class Templates implements ModInitializer { CUBE, FENCE, FENCE_GATE, + IRON_TRAPDOOR, LEVER, PANE, POST, @@ -107,6 +106,7 @@ public class Templates implements ModInitializer { 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_gate") , new BlockItem(FENCE_GATE, new Item.Settings())); + Registry.register(Registries.ITEM, id("iron_trapdoor") , new BlockItem(IRON_TRAPDOOR, new Item.Settings())); Registry.register(Registries.ITEM, id("lever") , new BlockItem(LEVER, new Item.Settings())); Registry.register(Registries.ITEM, id("pane") , new BlockItem(PANE, new Item.Settings())); Registry.register(Registries.ITEM, id("post") , new BlockItem(POST, new Item.Settings())); @@ -139,6 +139,7 @@ public class Templates implements ModInitializer { e.add(FENCE_GATE); // <-- insert door here e.add(TRAPDOOR); + e.add(IRON_TRAPDOOR); e.add(PRESSURE_PLATE); e.add(BUTTON); e.add(LEVER); diff --git a/src/main/java/io/github/cottonmc/templates/TemplatesClient.java b/src/main/java/io/github/cottonmc/templates/TemplatesClient.java index fc2bbe7..ddc8db8 100644 --- a/src/main/java/io/github/cottonmc/templates/TemplatesClient.java +++ b/src/main/java/io/github/cottonmc/templates/TemplatesClient.java @@ -62,6 +62,7 @@ public class TemplatesClient implements ClientModInitializer { Templates.CUBE, Templates.FENCE, Templates.FENCE_GATE, + Templates.IRON_TRAPDOOR, Templates.LEVER, Templates.PANE, Templates.POST, @@ -129,6 +130,7 @@ public class TemplatesClient implements ClientModInitializer { provider.assignItemModel(Templates.id("cube_special") , Templates.CUBE); provider.assignItemModel(Templates.id("fence_inventory_special") , Templates.FENCE); provider.assignItemModel(Templates.id("fence_gate_special") , Templates.FENCE_GATE); + provider.assignItemModel(Templates.id("trapdoor_bottom_special") , Templates.IRON_TRAPDOOR); provider.assignItemModel(Templates.id("lever_special") , Templates.LEVER); //TODO vanilla uses its own item model //provider.assignItemModel(Templates.id("glass_pane_side_special"), Templates.PANE); //Done with a regular json model actually provider.assignItemModel(Templates.id("fence_post_inventory_special") , Templates.POST); diff --git a/src/main/resources/assets/templates/blockstates/iron_trapdoor.json b/src/main/resources/assets/templates/blockstates/iron_trapdoor.json new file mode 100644 index 0000000..f7f5a6a --- /dev/null +++ b/src/main/resources/assets/templates/blockstates/iron_trapdoor.json @@ -0,0 +1,69 @@ +{ + "variants": { + "facing=east,half=bottom,open=false": { + "model": "templates:trapdoor_bottom_special", + "y": 90 + }, + "facing=east,half=bottom,open=true": { + "model": "templates:trapdoor_open_special", + "y": 90 + }, + "facing=east,half=top,open=false": { + "model": "templates:trapdoor_top_special", + "y": 90 + }, + "facing=east,half=top,open=true": { + "model": "templates:trapdoor_open_special", + "x": 180, + "y": 270 + }, + "facing=north,half=bottom,open=false": { + "model": "templates:trapdoor_bottom_special" + }, + "facing=north,half=bottom,open=true": { + "model": "templates:trapdoor_open_special" + }, + "facing=north,half=top,open=false": { + "model": "templates:trapdoor_top_special" + }, + "facing=north,half=top,open=true": { + "model": "templates:trapdoor_open_special", + "x": 180, + "y": 180 + }, + "facing=south,half=bottom,open=false": { + "model": "templates:trapdoor_bottom_special", + "y": 180 + }, + "facing=south,half=bottom,open=true": { + "model": "templates:trapdoor_open_special", + "y": 180 + }, + "facing=south,half=top,open=false": { + "model": "templates:trapdoor_top_special", + "y": 180 + }, + "facing=south,half=top,open=true": { + "model": "templates:trapdoor_open_special", + "x": 180, + "y": 0 + }, + "facing=west,half=bottom,open=false": { + "model": "templates:trapdoor_bottom_special", + "y": 270 + }, + "facing=west,half=bottom,open=true": { + "model": "templates:trapdoor_open_special", + "y": 270 + }, + "facing=west,half=top,open=false": { + "model": "templates:trapdoor_top_special", + "y": 270 + }, + "facing=west,half=top,open=true": { + "model": "templates:trapdoor_open_special", + "x": 180, + "y": 90 + } + } +} \ 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 11068a4..c0d3008 100644 --- a/src/main/resources/assets/templates/lang/en_us.json +++ b/src/main/resources/assets/templates/lang/en_us.json @@ -7,6 +7,7 @@ "block.templates.cube": "Cube Template", "block.templates.fence": "Fence Template", "block.templates.fence_gate": "Fence Gate Template", + "block.templates.iron_trapdoor": "Iron Trapdoor Template", "block.templates.lever": "Lever Template", "block.templates.pane": "Pane Template", "block.templates.post": "Post Template", diff --git a/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json new file mode 100644 index 0000000..2408475 --- /dev/null +++ b/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "templates:iron_trapdoor" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/blocks/trapdoors.json b/src/main/resources/data/minecraft/tags/blocks/trapdoors.json new file mode 100644 index 0000000..2408475 --- /dev/null +++ b/src/main/resources/data/minecraft/tags/blocks/trapdoors.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "templates:iron_trapdoor" + ] +} \ 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 ea588a1..e933f3a 100644 --- a/src/main/resources/data/templates/advancements/recipes/decorations/templates.json +++ b/src/main/resources/data/templates/advancements/recipes/decorations/templates.json @@ -8,6 +8,7 @@ "templates:cube", "templates:fence", "templates:fence_gate", + "templates:iron_trapdoor", "templates:lever", "templates:pane", "templates:post", diff --git a/src/main/resources/data/templates/loot_tables/blocks/iron_trapdoor.json b/src/main/resources/data/templates/loot_tables/blocks/iron_trapdoor.json new file mode 100644 index 0000000..073646d --- /dev/null +++ b/src/main/resources/data/templates/loot_tables/blocks/iron_trapdoor.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "templates:iron_trapdoor" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/templates/recipes/iron_trapdoor.json b/src/main/resources/data/templates/recipes/iron_trapdoor.json new file mode 100644 index 0000000..a4d66c4 --- /dev/null +++ b/src/main/resources/data/templates/recipes/iron_trapdoor.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "III", + "III", + "~X~" + ], + "key": { + "I": { + "item": "minecraft:bamboo" + }, + "~": { + "item": "minecraft:string" + }, + "X": { + "item": "minecraft:iron_ingot" + } + }, + "result": { + "item": "templates:iron_trapdoor", + "count": 4 + }, + "group": "templates" +} \ No newline at end of file