|
|
|
@ -1,11 +1,6 @@
|
|
|
|
|
package net.parsell.cherry.core;
|
|
|
|
|
|
|
|
|
|
import com.google.common.collect.ImmutableMap.Builder;
|
|
|
|
|
|
|
|
|
|
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
|
|
|
|
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
|
|
|
|
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
|
|
|
|
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
|
import net.minecraft.block.BlockState;
|
|
|
|
|
import net.minecraft.block.Blocks;
|
|
|
|
@ -18,146 +13,128 @@ import net.minecraft.block.SignBlock;
|
|
|
|
|
import net.minecraft.block.SlabBlock;
|
|
|
|
|
import net.minecraft.block.entity.BlockEntityType;
|
|
|
|
|
import net.minecraft.block.entity.SignBlockEntity;
|
|
|
|
|
import net.minecraft.client.render.RenderLayer;
|
|
|
|
|
import net.minecraft.util.Identifier;
|
|
|
|
|
import net.minecraft.util.SignType;
|
|
|
|
|
import net.minecraft.util.registry.Registry;
|
|
|
|
|
import net.parsell.cherry.common.blocks.CherryButtonBlock;
|
|
|
|
|
import net.parsell.cherry.common.blocks.CherryDoorBlock;
|
|
|
|
|
import net.parsell.cherry.common.blocks.CherryPressurePlate;
|
|
|
|
|
import net.parsell.cherry.common.blocks.CherryStairsBlock;
|
|
|
|
|
import net.parsell.cherry.common.blocks.CherryTrapdoorBlock;
|
|
|
|
|
import net.parsell.cherry.mixin.AxeItemAccessor;
|
|
|
|
|
|
|
|
|
|
public class CherryBlocks {
|
|
|
|
|
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);
|
|
|
|
|
public static final Block CHERRYFENCE = registerFence("cherry_fence", FabricBlockSettings.copyOf(Blocks.OAK_FENCE), 5, 20); // TODO: tags (as required)
|
|
|
|
|
public static final Block CHERRYFENCEGATE = registerFenceGate("cherry_fence_gate", FabricBlockSettings.copyOf(Blocks.OAK_FENCE_GATE), 5, 20); // TODO: recipe, loot_tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYDOOR = registerDoor("cherry_door", FabricBlockSettings.copyOf(Blocks.OAK_DOOR), 5, 20); // TODO: recipe, loot_tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYTRAPDOOR = registerTrapDoor("cherry_trapdoor", FabricBlockSettings.copyOf(Blocks.OAK_TRAPDOOR), 5, 20); //TODO: recipe, loot_tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYSLAB = registerSlab("cherry_slab", FabricBlockSettings.copyOf(Blocks.OAK_SLAB), 5, 20); // TODO: recipe, loot tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYSTAIRS = registerStair("cherry_stairs", CHERRYPLANKS.getDefaultState(), FabricBlockSettings.copyOf(Blocks.OAK_STAIRS), 5, 20); //TODO: recipe, loot tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYBUTTON = registerButton("cherry_button", FabricBlockSettings.copyOf(Blocks.OAK_BUTTON), 5, 20); //TODO: recipe, loot tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYPRESSUREPLATE = registerPressurePlate("cherry_pressure_plate", PressurePlateBlock.ActivationRule.EVERYTHING, FabricBlockSettings.copyOf(Blocks.OAK_PRESSURE_PLATE), 5, 20); //TODO: recipe, loot tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYSIGN = registerSign("cherry_sign", SignType.OAK, FabricBlockSettings.copyOf(Blocks.OAK_SIGN), 5, 20); // TODO: recipe, loot tables
|
|
|
|
|
public static final Block CHERRYLOGSTRIPPED = createPillar("stripped_cherry_log", FabricBlockSettings.copyOf(Blocks.STRIPPED_OAK_LOG), 5, 5);
|
|
|
|
|
public static final Block CHERRYLOG = createPillar("cherry_log", FabricBlockSettings.copyOf(Blocks.OAK_LOG), 5, 5, CHERRYLOGSTRIPPED);
|
|
|
|
|
public static final Block CHERRYWOOD = createPillar("cherry_wood", FabricBlockSettings.copyOf(Blocks.OAK_WOOD), 5, 5);
|
|
|
|
|
public static final Block CHERRYWOODSTRIPPED = createPillar("stripped_cherry_wood", FabricBlockSettings.copyOf(Blocks.STRIPPED_OAK_WOOD), 5, 5);
|
|
|
|
|
public static final Block CHERRYLEAVES = createLeaves("cherry_leaves", FabricBlockSettings.copyOf(Blocks.OAK_LEAVES), 30, 60, 6649929);
|
|
|
|
|
public static final Block CHERRYPLANKS = createBlock("cherry_planks", FabricBlockSettings.copyOf(Blocks.OAK_PLANKS), 5, 20);
|
|
|
|
|
public static final Block CHERRYFENCE = createFence("cherry_fence", FabricBlockSettings.copyOf(Blocks.OAK_FENCE), 5, 20); // TODO: tags (as required)
|
|
|
|
|
public static final Block CHERRYFENCEGATE = createFenceGate("cherry_fence_gate", FabricBlockSettings.copyOf(Blocks.OAK_FENCE_GATE), 5, 20); // TODO: recipe, loot_tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYDOOR = createDoor("cherry_door", FabricBlockSettings.copyOf(Blocks.OAK_DOOR), 5, 20); // TODO: recipe, loot_tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYTRAPDOOR = createTrapDoor("cherry_trapdoor", FabricBlockSettings.copyOf(Blocks.OAK_TRAPDOOR), 5, 20); //TODO: recipe, loot_tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYSLAB = createSlab("cherry_slab", FabricBlockSettings.copyOf(Blocks.OAK_SLAB), 5, 20); // TODO: recipe, loot tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYSTAIRS = createStair("cherry_stairs", CHERRYPLANKS.getDefaultState(), FabricBlockSettings.copyOf(Blocks.OAK_STAIRS), 5, 20); //TODO: recipe, loot tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYBUTTON = createButton("cherry_button", FabricBlockSettings.copyOf(Blocks.OAK_BUTTON), 5, 20); //TODO: recipe, loot tables, tags (as required)
|
|
|
|
|
public static final Block CHERRYPRESSUREPLATE = createPressurePlate("cherry_pressure_plate", PressurePlateBlock.ActivationRule.EVERYTHING, FabricBlockSettings.copyOf(Blocks.OAK_PRESSURE_PLATE), 5, 20); //TODO: recipe, loot tables, tags (as required)
|
|
|
|
|
public static final SignType CHERRYSIGN_TYPE = CherryRegistry.register("cherry");
|
|
|
|
|
public static final Block CHERRYSIGN = createSign("cherry_sign", CHERRYSIGN_TYPE, FabricBlockSettings.copyOf(Blocks.OAK_SIGN), 5, 20); // TODO: recipe, loot tables
|
|
|
|
|
public static final BlockEntityType<SignBlockEntity> CHERRYSIGN_ENTITY = BlockEntityType.Builder.create(SignBlockEntity::new, CHERRYSIGN).build(null);
|
|
|
|
|
|
|
|
|
|
private static Block registerBlock(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
private static Block createBlock(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
Block block = new Block(settings);
|
|
|
|
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
|
|
|
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Block registerSlab(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
private static Block createSlab(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
Block block = new SlabBlock(settings);
|
|
|
|
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
|
|
|
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Block registerStair(String blockID, BlockState baseBlockState, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
private static Block createStair(String blockID, BlockState baseBlockState, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
Block block = new CherryStairsBlock(baseBlockState, settings);
|
|
|
|
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
|
|
|
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Block registerButton(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
private static Block createButton(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
Block block = new CherryButtonBlock(settings);
|
|
|
|
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
|
|
|
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Block registerPressurePlate(String blockID, PressurePlateBlock.ActivationRule rule, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
private static Block createPressurePlate(String blockID, PressurePlateBlock.ActivationRule rule, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
Block block = new CherryPressurePlate(rule, settings);
|
|
|
|
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
|
|
|
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Block registerSign(String blockID, SignType type, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
private static Block createSign(String blockID, SignType type, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
Block block = new SignBlock(settings, type);
|
|
|
|
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
|
|
|
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Block registerFence(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
private static Block createFence(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
Block block = new FenceBlock(settings);
|
|
|
|
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
|
|
|
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Block registerFenceGate(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
private static Block createFenceGate(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) {
|
|
|
|
|
Block block = new FenceGateBlock(settings);
|
|
|
|
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
|
|
|
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Block registerPillar(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread){
|
|
|
|
|
private static Block createPillar(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread){
|
|
|
|
|
Block block = new PillarBlock(settings);
|
|
|
|
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
|
|
|
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Block registerPillar(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread, Block strippedVariant){
|
|
|
|
|
private static Block createPillar(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);
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.addStrippable(block, strippedVariant);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Block registerLeaves(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread, int color){
|
|
|
|
|
private static Block createLeaves(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread, int color){
|
|
|
|
|
Block block = new LeavesBlock(settings);
|
|
|
|
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
|
|
|
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
|
|
|
|
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> {
|
|
|
|
|
return color;
|
|
|
|
|
}, block);
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.registerColor(block, color);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Block registerDoor(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread){
|
|
|
|
|
private static Block createDoor(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread){
|
|
|
|
|
Block block = new CherryDoorBlock(settings);
|
|
|
|
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
|
|
|
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
|
|
|
|
BlockRenderLayerMap.INSTANCE.putBlock(block, RenderLayer.getCutout());
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.registerTransparentLayer(block);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Block registerTrapDoor(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread){
|
|
|
|
|
private static Block createTrapDoor(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread){
|
|
|
|
|
Block block = new CherryTrapdoorBlock(settings);
|
|
|
|
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
|
|
|
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
|
|
|
|
BlockRenderLayerMap.INSTANCE.putBlock(block, RenderLayer.getCutout());
|
|
|
|
|
CherryRegistry.register(block, blockID);
|
|
|
|
|
CherryRegistry.registerBurnable(block, burnChance, burnSpread);
|
|
|
|
|
CherryRegistry.registerTransparentLayer(block);
|
|
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void init(){
|
|
|
|
|
// Ensure not to overwrite on previous strippable logs
|
|
|
|
|
AxeItemAccessor.getStrippedLogs().forEach((log, strippedLog) -> {
|
|
|
|
|
STRIPPABLE_BLOCKS.put(log, strippedLog);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Register unique logs
|
|
|
|
|
AxeItemAccessor.setStrippedLogs(STRIPPABLE_BLOCKS.build());
|
|
|
|
|
System.out.println(CHERRYSIGN_ENTITY.toString());
|
|
|
|
|
if(!(CHERRYSIGN_ENTITY == null))
|
|
|
|
|
Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier("cherry", "cherry_sign"), CHERRYSIGN_ENTITY);
|
|
|
|
|
else
|
|
|
|
|
System.out.println("cherry:cherry_sign entity is null");
|
|
|
|
|
CherryRegistry.register(CHERRYSIGN_ENTITY, "cherry_sign");
|
|
|
|
|
}
|
|
|
|
|
}
|