Skip to content

Commit

Permalink
Add connector block
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiDragon committed Apr 22, 2022
1 parent ef7a858 commit 57df888
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ protected void generateBlockLootTables() {
addDrop(ModBlocks.QUAD_DRAWER);
addDrop(ModBlocks.SHADOW_DRAWER);
addDrop(ModBlocks.CONTROLLER);
addDrop(ModBlocks.CONNECTOR);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ protected void generateRecipes(Consumer<RecipeJsonProvider> exporter) {
offerLockRecipe(exporter);
offerUpgradeFrameRecipe(exporter);
offerControllerRecipe(exporter);
offerConnectorRecipe(exporter);
}

private void offerDrawerRecipes(Consumer<RecipeJsonProvider> exporter) {
Expand Down Expand Up @@ -94,6 +95,17 @@ private void offerControllerRecipe(Consumer<RecipeJsonProvider> exporter) {
.offerTo(exporter);
}

private void offerConnectorRecipe(Consumer<RecipeJsonProvider> 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<RecipeJsonProvider> exporter) {
ShapedRecipeJsonBuilder.create(ModItems.UPGRADE_FRAME)
.input('S', Items.STICK)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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;
import io.github.mattidragon.extendeddrawers.block.entity.DrawerBlockEntity;
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;
Expand All @@ -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<DrawerBlockEntity> DRAWER_BLOCK_ENTITY = FabricBlockEntityTypeBuilder.create(DrawerBlockEntity::new, SINGLE_DRAWER, DOUBLE_DRAWER, QUAD_DRAWER).build();
public static final BlockEntityType<ShadowDrawerBlockEntity> SHADOW_DRAWER_BLOCK_ENTITY = FabricBlockEntityTypeBuilder.create(ShadowDrawerBlockEntity::new, SHADOW_DRAWER).build();
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/extended_drawers/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 57df888

Please sign in to comment.