From 57df888fd5e2a1b30394a82bb7e37e3a5e44b90d Mon Sep 17 00:00:00 2001 From: MattiDragon Date: Fri, 22 Apr 2022 17:36:34 +0300 Subject: [PATCH] Add connector block --- .../extendeddrawers/block/ConnectorBlock.java | 10 ++++++++++ .../datagen/DrawersBlockLootTableProvider.java | 1 + .../datagen/DrawersModelProvider.java | 7 +++---- .../datagen/DrawersRecipeProvider.java | 12 ++++++++++++ .../extendeddrawers/registry/ModBlocks.java | 14 +++++++++----- .../extendeddrawers/registry/ModItems.java | 2 ++ .../assets/extended_drawers/lang/en_us.json | 1 + 7 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 src/main/java/io/github/mattidragon/extendeddrawers/block/ConnectorBlock.java diff --git a/src/main/java/io/github/mattidragon/extendeddrawers/block/ConnectorBlock.java b/src/main/java/io/github/mattidragon/extendeddrawers/block/ConnectorBlock.java new file mode 100644 index 0000000..f955614 --- /dev/null +++ b/src/main/java/io/github/mattidragon/extendeddrawers/block/ConnectorBlock.java @@ -0,0 +1,10 @@ +package io.github.mattidragon.extendeddrawers.block; + +import io.github.mattidragon.extendeddrawers.block.base.NetworkComponent; +import net.minecraft.block.Block; + +public class ConnectorBlock extends Block implements NetworkComponent { + public ConnectorBlock(Settings settings) { + super(settings); + } +} diff --git a/src/main/java/io/github/mattidragon/extendeddrawers/datagen/DrawersBlockLootTableProvider.java b/src/main/java/io/github/mattidragon/extendeddrawers/datagen/DrawersBlockLootTableProvider.java index f680826..db801ac 100644 --- a/src/main/java/io/github/mattidragon/extendeddrawers/datagen/DrawersBlockLootTableProvider.java +++ b/src/main/java/io/github/mattidragon/extendeddrawers/datagen/DrawersBlockLootTableProvider.java @@ -16,5 +16,6 @@ protected void generateBlockLootTables() { addDrop(ModBlocks.QUAD_DRAWER); addDrop(ModBlocks.SHADOW_DRAWER); addDrop(ModBlocks.CONTROLLER); + addDrop(ModBlocks.CONNECTOR); } } diff --git a/src/main/java/io/github/mattidragon/extendeddrawers/datagen/DrawersModelProvider.java b/src/main/java/io/github/mattidragon/extendeddrawers/datagen/DrawersModelProvider.java index 6e9c4b5..cea4603 100644 --- a/src/main/java/io/github/mattidragon/extendeddrawers/datagen/DrawersModelProvider.java +++ b/src/main/java/io/github/mattidragon/extendeddrawers/datagen/DrawersModelProvider.java @@ -4,10 +4,7 @@ import io.github.mattidragon.extendeddrawers.registry.ModItems; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider; -import net.minecraft.data.client.BlockStateModelGenerator; -import net.minecraft.data.client.ItemModelGenerator; -import net.minecraft.data.client.Models; -import net.minecraft.data.client.TextureMap; +import net.minecraft.data.client.*; import static io.github.mattidragon.extendeddrawers.ExtendedDrawers.id; @@ -19,6 +16,8 @@ public DrawersModelProvider(FabricDataGenerator generator) { @Override public void generateBlockStateModels(BlockStateModelGenerator generator) { generator.registerSimpleCubeAll(ModBlocks.CONTROLLER); + + generator.registerSingleton(ModBlocks.CONNECTOR, TextureMap.all(id("block/drawer_base")), Models.CUBE_ALL); var texture = TextureMap.sideEnd(id("block/drawer_base"), id("block/drawer_base")); generator.registerNorthDefaultHorizontalRotatable(ModBlocks.SINGLE_DRAWER, texture); diff --git a/src/main/java/io/github/mattidragon/extendeddrawers/datagen/DrawersRecipeProvider.java b/src/main/java/io/github/mattidragon/extendeddrawers/datagen/DrawersRecipeProvider.java index 7ab2b83..3dfa43b 100644 --- a/src/main/java/io/github/mattidragon/extendeddrawers/datagen/DrawersRecipeProvider.java +++ b/src/main/java/io/github/mattidragon/extendeddrawers/datagen/DrawersRecipeProvider.java @@ -31,6 +31,7 @@ protected void generateRecipes(Consumer exporter) { offerLockRecipe(exporter); offerUpgradeFrameRecipe(exporter); offerControllerRecipe(exporter); + offerConnectorRecipe(exporter); } private void offerDrawerRecipes(Consumer exporter) { @@ -94,6 +95,17 @@ private void offerControllerRecipe(Consumer exporter) { .offerTo(exporter); } + private void offerConnectorRecipe(Consumer exporter) { + ShapedRecipeJsonBuilder.create(ModItems.CONNECTOR) + .input('L', ItemTags.LOGS) + .input('P', ItemTags.PLANKS) + .pattern("LPL") + .pattern("PPP") + .pattern("LPL") + .criterion(RecipeProvider.hasItem(ModItems.CONNECTOR), RecipeProvider.conditionsFromItem(ModItems.CONNECTOR)) + .offerTo(exporter); + } + private void offerUpgradeFrameRecipe(Consumer exporter) { ShapedRecipeJsonBuilder.create(ModItems.UPGRADE_FRAME) .input('S', Items.STICK) diff --git a/src/main/java/io/github/mattidragon/extendeddrawers/registry/ModBlocks.java b/src/main/java/io/github/mattidragon/extendeddrawers/registry/ModBlocks.java index ba6ee48..d0465e0 100644 --- a/src/main/java/io/github/mattidragon/extendeddrawers/registry/ModBlocks.java +++ b/src/main/java/io/github/mattidragon/extendeddrawers/registry/ModBlocks.java @@ -1,5 +1,6 @@ package io.github.mattidragon.extendeddrawers.registry; +import io.github.mattidragon.extendeddrawers.block.ConnectorBlock; import io.github.mattidragon.extendeddrawers.block.ControllerBlock; import io.github.mattidragon.extendeddrawers.block.DrawerBlock; import io.github.mattidragon.extendeddrawers.block.ShadowDrawerBlock; @@ -7,6 +8,7 @@ import io.github.mattidragon.extendeddrawers.block.entity.ShadowDrawerBlockEntity; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; +import net.minecraft.block.MapColor; import net.minecraft.block.Material; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.sound.BlockSoundGroup; @@ -15,11 +17,12 @@ import static io.github.mattidragon.extendeddrawers.ExtendedDrawers.id; public class ModBlocks { - public static final DrawerBlock SINGLE_DRAWER = new DrawerBlock(FabricBlockSettings.of(Material.WOOD).strength(2.0f, 3.0f).sounds(BlockSoundGroup.WOOD), 1); - public static final DrawerBlock DOUBLE_DRAWER = new DrawerBlock(FabricBlockSettings.of(Material.WOOD).strength(2.0f, 3.0f).sounds(BlockSoundGroup.WOOD), 2); - public static final DrawerBlock QUAD_DRAWER = new DrawerBlock(FabricBlockSettings.of(Material.WOOD).strength(2.0f, 3.0f).sounds(BlockSoundGroup.WOOD), 4); - public static final ControllerBlock CONTROLLER = new ControllerBlock(FabricBlockSettings.of(Material.STONE).strength(1.5f, 6.0f).sounds(BlockSoundGroup.STONE)); - public static final ShadowDrawerBlock SHADOW_DRAWER = new ShadowDrawerBlock(FabricBlockSettings.of(Material.STONE).strength(1.5f, 6.0f).sounds(BlockSoundGroup.STONE)); + public static final DrawerBlock SINGLE_DRAWER = new DrawerBlock(FabricBlockSettings.of(Material.WOOD).strength(2f, 3f).sounds(BlockSoundGroup.WOOD), 1); + public static final DrawerBlock DOUBLE_DRAWER = new DrawerBlock(FabricBlockSettings.of(Material.WOOD).strength(2f, 3f).sounds(BlockSoundGroup.WOOD), 2); + public static final DrawerBlock QUAD_DRAWER = new DrawerBlock(FabricBlockSettings.of(Material.WOOD).strength(2f, 3f).sounds(BlockSoundGroup.WOOD), 4); + public static final ConnectorBlock CONNECTOR = new ConnectorBlock(FabricBlockSettings.of(Material.WOOD).strength(2f, 3f).sounds(BlockSoundGroup.WOOD)); + public static final ControllerBlock CONTROLLER = new ControllerBlock(FabricBlockSettings.of(Material.STONE).strength(3f, 9f).sounds(BlockSoundGroup.STONE)); + public static final ShadowDrawerBlock SHADOW_DRAWER = new ShadowDrawerBlock(FabricBlockSettings.of(Material.STONE, MapColor.PALE_YELLOW).strength(3f, 9f).sounds(BlockSoundGroup.STONE)); public static final BlockEntityType DRAWER_BLOCK_ENTITY = FabricBlockEntityTypeBuilder.create(DrawerBlockEntity::new, SINGLE_DRAWER, DOUBLE_DRAWER, QUAD_DRAWER).build(); public static final BlockEntityType SHADOW_DRAWER_BLOCK_ENTITY = FabricBlockEntityTypeBuilder.create(ShadowDrawerBlockEntity::new, SHADOW_DRAWER).build(); @@ -28,6 +31,7 @@ public static void register() { Registry.register(Registry.BLOCK, id("single_drawer"), SINGLE_DRAWER); Registry.register(Registry.BLOCK, id("double_drawer"), DOUBLE_DRAWER); Registry.register(Registry.BLOCK, id("quad_drawer"), QUAD_DRAWER); + Registry.register(Registry.BLOCK, id("connector"), CONNECTOR); Registry.register(Registry.BLOCK, id("controller"), CONTROLLER); Registry.register(Registry.BLOCK, id("shadow_drawer"), SHADOW_DRAWER); diff --git a/src/main/java/io/github/mattidragon/extendeddrawers/registry/ModItems.java b/src/main/java/io/github/mattidragon/extendeddrawers/registry/ModItems.java index 91e40ce..52afe9f 100644 --- a/src/main/java/io/github/mattidragon/extendeddrawers/registry/ModItems.java +++ b/src/main/java/io/github/mattidragon/extendeddrawers/registry/ModItems.java @@ -14,6 +14,7 @@ public class ModItems { public static final Item SINGLE_DRAWER = new BlockItem(ModBlocks.SINGLE_DRAWER, new FabricItemSettings().group(MOD_GROUP)); public static final Item DOUBLE_DRAWER = new BlockItem(ModBlocks.DOUBLE_DRAWER, new FabricItemSettings().group(MOD_GROUP)); public static final Item QUAD_DRAWER = new BlockItem(ModBlocks.QUAD_DRAWER, new FabricItemSettings().group(MOD_GROUP)); + public static final Item CONNECTOR = new BlockItem(ModBlocks.CONNECTOR, new FabricItemSettings().group(MOD_GROUP)); public static final Item SHADOW_DRAWER = new BlockItem(ModBlocks.SHADOW_DRAWER, new FabricItemSettings().group(MOD_GROUP)); public static final Item CONTROLLER = new BlockItem(ModBlocks.CONTROLLER, new FabricItemSettings().group(MOD_GROUP)); @@ -30,6 +31,7 @@ public static void register() { Registry.register(Registry.ITEM, id("single_drawer"), SINGLE_DRAWER); Registry.register(Registry.ITEM, id("double_drawer"), DOUBLE_DRAWER); Registry.register(Registry.ITEM, id("quad_drawer"), QUAD_DRAWER); + Registry.register(Registry.ITEM, id("connector"), CONNECTOR); Registry.register(Registry.ITEM, id("shadow_drawer"), SHADOW_DRAWER); Registry.register(Registry.ITEM, id("controller"), CONTROLLER); diff --git a/src/main/resources/assets/extended_drawers/lang/en_us.json b/src/main/resources/assets/extended_drawers/lang/en_us.json index 0f082ad..93339fe 100644 --- a/src/main/resources/assets/extended_drawers/lang/en_us.json +++ b/src/main/resources/assets/extended_drawers/lang/en_us.json @@ -4,6 +4,7 @@ "block.extended_drawers.single_drawer": "Drawer", "block.extended_drawers.shadow_drawer": "Shadow Drawer", "block.extended_drawers.controller": "Drawer Controller", + "block.extended_drawers.connector": "Drawer Connector", "item.extended_drawers.t1_upgrade": "Drawer Upgrade I", "item.extended_drawers.t2_upgrade": "Drawer Upgrade II",