introduction of pressure plate

This commit is contained in:
Justin Parsell 2021-03-20 22:06:03 -04:00
parent 4bf3a96749
commit 75ffe5fad7
6 changed files with 46 additions and 1 deletions

View File

@ -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));
}
}

View File

@ -13,6 +13,7 @@ import net.minecraft.block.FenceBlock;
import net.minecraft.block.FenceGateBlock; import net.minecraft.block.FenceGateBlock;
import net.minecraft.block.LeavesBlock; import net.minecraft.block.LeavesBlock;
import net.minecraft.block.PillarBlock; import net.minecraft.block.PillarBlock;
import net.minecraft.block.PressurePlateBlock;
import net.minecraft.block.SlabBlock; import net.minecraft.block.SlabBlock;
import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.RenderLayer;
import net.minecraft.util.Identifier; 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 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 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 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) { private static Block registerBlock(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) {
Block block = new Block(settings); Block block = new Block(settings);
@ -66,6 +67,13 @@ public class CherryBlocks {
return block; 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) { private static Block registerFence(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread) {
Block block = new FenceBlock(settings); Block block = new FenceBlock(settings);
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block); Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);

View File

@ -0,0 +1,10 @@
{
"variants": {
"powered=false": {
"model": "cherry:block/cherry_pressure_plate"
},
"powered=true": {
"model": "cherry:block/cherry_pressure_plate_down"
}
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/pressure_plate_up",
"textures": {
"texture": "cherry:block/cherry_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/pressure_plate_down",
"textures": {
"texture": "cherry:block/cherry_planks"
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "cherry:block/cherry_pressure_plate"
}