From 75ffe5fad73622f8ace794e0797b91be49802b56 Mon Sep 17 00:00:00 2001 From: Justin Parsell Date: Sat, 20 Mar 2021 22:06:03 -0400 Subject: [PATCH] introduction of pressure plate --- .../cherry/common/blocks/CherryPressurePlate.java | 12 ++++++++++++ .../java/net/parsell/cherry/core/CherryBlocks.java | 10 +++++++++- .../cherry/blockstates/cherry_pressure_plate.json | 10 ++++++++++ .../cherry/models/block/cherry_pressure_plate.json | 6 ++++++ .../models/block/cherry_pressure_plate_down.json | 6 ++++++ .../cherry/models/item/cherry_pressure_plate.json | 3 +++ 6 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/main/java/net/parsell/cherry/common/blocks/CherryPressurePlate.java create mode 100644 src/main/resources/assets/cherry/blockstates/cherry_pressure_plate.json create mode 100644 src/main/resources/assets/cherry/models/block/cherry_pressure_plate.json create mode 100644 src/main/resources/assets/cherry/models/block/cherry_pressure_plate_down.json create mode 100644 src/main/resources/assets/cherry/models/item/cherry_pressure_plate.json diff --git a/src/main/java/net/parsell/cherry/common/blocks/CherryPressurePlate.java b/src/main/java/net/parsell/cherry/common/blocks/CherryPressurePlate.java new file mode 100644 index 0000000..ca6cef6 --- /dev/null +++ b/src/main/java/net/parsell/cherry/common/blocks/CherryPressurePlate.java @@ -0,0 +1,12 @@ +package net.parsell.cherry.common.blocks; + +import net.minecraft.block.AbstractBlock; +import net.minecraft.block.BlockState; +import net.minecraft.block.PressurePlateBlock; + +public class CherryPressurePlate extends PressurePlateBlock{ + public CherryPressurePlate(PressurePlateBlock.ActivationRule type, AbstractBlock.Settings settings){ + super (type, settings); + this.setDefaultState((BlockState)((BlockState)this.stateManager.getDefaultState()).with(POWERED, false)); + } +} diff --git a/src/main/java/net/parsell/cherry/core/CherryBlocks.java b/src/main/java/net/parsell/cherry/core/CherryBlocks.java index e9b96ab..8a4f053 100644 --- a/src/main/java/net/parsell/cherry/core/CherryBlocks.java +++ b/src/main/java/net/parsell/cherry/core/CherryBlocks.java @@ -13,6 +13,7 @@ import net.minecraft.block.FenceBlock; import net.minecraft.block.FenceGateBlock; import net.minecraft.block.LeavesBlock; import net.minecraft.block.PillarBlock; +import net.minecraft.block.PressurePlateBlock; import net.minecraft.block.SlabBlock; import net.minecraft.client.render.RenderLayer; import net.minecraft.util.Identifier; @@ -36,7 +37,7 @@ public class CherryBlocks { 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); - public static final Block CHERRYPRESSUREPLATE = reigsterPressurePlate("cherry_pressure_plate", FabricBlockSettings.copyOf(Blocks.OAK_PRESSURE_PLATE), 5, 20); + public static final Block CHERRYPRESSUREPLATE = registerPressurePlate("cherry_pressure_plate", PressurePlateBlock.ActivationRule.EVERYTHING, FabricBlockSettings.copyOf(Blocks.OAK_PRESSURE_PLATE), 5, 20); private static Block registerBlock(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) { Block block = new Block(settings); @@ -66,6 +67,13 @@ public class CherryBlocks { return block; } + private static Block registerPressurePlate(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); + return block; + } + private static Block registerFence(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) { Block block = new FenceBlock(settings); Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block); diff --git a/src/main/resources/assets/cherry/blockstates/cherry_pressure_plate.json b/src/main/resources/assets/cherry/blockstates/cherry_pressure_plate.json new file mode 100644 index 0000000..046fe9b --- /dev/null +++ b/src/main/resources/assets/cherry/blockstates/cherry_pressure_plate.json @@ -0,0 +1,10 @@ +{ + "variants": { + "powered=false": { + "model": "cherry:block/cherry_pressure_plate" + }, + "powered=true": { + "model": "cherry:block/cherry_pressure_plate_down" + } + } + } \ No newline at end of file diff --git a/src/main/resources/assets/cherry/models/block/cherry_pressure_plate.json b/src/main/resources/assets/cherry/models/block/cherry_pressure_plate.json new file mode 100644 index 0000000..a86b6b1 --- /dev/null +++ b/src/main/resources/assets/cherry/models/block/cherry_pressure_plate.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/pressure_plate_up", + "textures": { + "texture": "cherry:block/cherry_planks" + } + } \ No newline at end of file diff --git a/src/main/resources/assets/cherry/models/block/cherry_pressure_plate_down.json b/src/main/resources/assets/cherry/models/block/cherry_pressure_plate_down.json new file mode 100644 index 0000000..90a3db1 --- /dev/null +++ b/src/main/resources/assets/cherry/models/block/cherry_pressure_plate_down.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/pressure_plate_down", + "textures": { + "texture": "cherry:block/cherry_planks" + } + } \ No newline at end of file diff --git a/src/main/resources/assets/cherry/models/item/cherry_pressure_plate.json b/src/main/resources/assets/cherry/models/item/cherry_pressure_plate.json new file mode 100644 index 0000000..b0b5ddc --- /dev/null +++ b/src/main/resources/assets/cherry/models/item/cherry_pressure_plate.json @@ -0,0 +1,3 @@ +{ + "parent": "cherry:block/cherry_pressure_plate" + } \ No newline at end of file