Modified how stripped blocks are registered

This commit is contained in:
Justin Parsell 2021-03-17 20:11:20 -04:00
parent 03b856afef
commit 754e9020c2
1 changed files with 17 additions and 7 deletions

View File

@ -18,9 +18,11 @@ import net.parsell.cherry.common.blocks.CherryDoor;
import net.parsell.cherry.mixin.AxeItemAccessor;
public class CherryBlocks {
public static final Block CHERRYLOG = registerPillar("cherry_log", FabricBlockSettings.copyOf(Blocks.OAK_LOG), 5, 5);
public static final Block CHERRYWOOD = registerPillar("cherry_wood", FabricBlockSettings.copyOf(Blocks.OAK_WOOD), 5, 5);
private static Builder<Block, Block> STRIPPABLE_BLOCKS = new Builder<Block, Block>();
public static final Block CHERRYLOGSTRIPPED = registerPillar("stripped_cherry_log", FabricBlockSettings.copyOf(Blocks.STRIPPED_OAK_LOG), 5, 5);
public static final Block CHERRYLOG = registerPillar("cherry_log", FabricBlockSettings.copyOf(Blocks.OAK_LOG), 5, 5, CHERRYLOGSTRIPPED);
public static final Block CHERRYWOOD = registerPillar("cherry_wood", FabricBlockSettings.copyOf(Blocks.OAK_WOOD), 5, 5);
public static final Block CHERRYWOODSTRIPPED = registerPillar("stripped_cherry_wood", FabricBlockSettings.copyOf(Blocks.STRIPPED_OAK_WOOD), 5, 5);
public static final Block CHERRYLEAVES = registerLeaves("cherry_leaves", FabricBlockSettings.copyOf(Blocks.OAK_LEAVES), 30, 60, 6649929);
public static final Block CHERRYPLANKS = registerBlock("cherry_planks", FabricBlockSettings.copyOf(Blocks.OAK_PLANKS), 5, 20);
@ -48,6 +50,14 @@ public class CherryBlocks {
return block;
}
private static Block registerPillar(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread, Block strippedVariant){
Block block = new PillarBlock(settings);
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
STRIPPABLE_BLOCKS.put(block, strippedVariant);
return block;
}
private static Block registerLeaves(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread, int color){
Block block = new LeavesBlock(settings);
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
@ -67,12 +77,12 @@ public class CherryBlocks {
}
public static void init(){
// Register unique logs
Builder<Block, Block> STRIPPED_BLOCKS = new Builder<Block, Block>();
// Ensure not to overwrite on previous strippable logs
AxeItemAccessor.getStrippedLogs().forEach((log, strippedLog) -> {
STRIPPED_BLOCKS.put(log, strippedLog);
STRIPPABLE_BLOCKS.put(log, strippedLog);
});
STRIPPED_BLOCKS.put(CHERRYLOG, CHERRYLOGSTRIPPED);
AxeItemAccessor.setStrippedLogs(STRIPPED_BLOCKS.build());
// Register unique logs
AxeItemAccessor.setStrippedLogs(STRIPPABLE_BLOCKS.build());
}
}