Minecraft中有許多方塊不是立方體的形狀,例如按鈕、樓梯、柵欄以及門,這些方塊有些小有些大,明顯不能以正常方塊的形式註冊,所以我們需要額外去處理他們,今天我們來註冊一些這種方塊。
public static final Block SIDERITE_STAIRS = registerBlock("siderite_stairs",
new StairsBlock(ModBlocks.SIDERITE_BLOCK.getDefaultState(),FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)));
public static final Block SIDERITE_SLAB = registerBlock("siderite_slab",
new SlabBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)));
public static final Block SIDERITE_BUTTON = registerBlock("siderite_button",
new ButtonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK), BlockSetType.WOOD,10,true));
public static final Block SIDERITE_PRESSURE_PLATE = registerBlock("siderite_pressure_plate",
new PressurePlateBlock(PressurePlateBlock.ActivationRule.EVERYTHING ,FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)
, BlockSetType.IRON ));
public static final Block SIDERITE_FENCE = registerBlock("siderite_fence",
new FenceBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)));
public static final Block SIDERITE_FENCE_GATE = registerBlock("siderite_fence_gate",
new FenceGateBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK), WoodType.ACACIA));
public static final Block SIDERITE_WALL = registerBlock("siderite_wall",
new WallBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK)));
public static final Block SIDERITE_DOOR = registerBlock("siderite_door",
new DoorBlock(FabricBlockSettings.copyOf(Blocks.IRON_DOOR) , BlockSetType.STONE));
public static final Block SIDERITE_TRAPDOOR = registerBlock("siderite_trapdoor",
new TrapdoorBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), BlockSetType.STONE));
我們註冊了stairs(樓梯)、slab(半磚)、button(按鈕)、pressure_plate(壓力版)、fence(柵欄)、fence_gate(柵欄門)、wall(石柵欄)、door(門)、trapdoor(陷阱門),每個種類都有自己的建構函式,通常都是名子+Block,方塊設定都是copy相同類型的鐵製方塊或是鐵磚,有些方塊有自己獨特的設定,我一一講解。
BuutonBlock中,第二個參數設定的是決定按鈕的聲音,第三個參數10是按鈕的紅石強度,第四個參數是指這個按鈕的行為是否比照木質按鈕,例如可以被弓箭觸發。