我們今天來做熔煉的部分,首先我們先做出銀礦的方塊
public static final RegistryObject<Block> SILVER_ORE = registerBlock("silver_ore",
()-> new Block(BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(1f)));
Material選擇Stone,礦物型的都是stone。
接下來我們把這個方塊的分類歸類為自然方塊,Natural_blocks
if (event.getTab()== CreativeModeTabs.NATURAL_BLOCKS){
event.accept(ModBlocks.SILVER_ORE);
}
我們還需要三個json檔
blockstate
{
"variants": {
"" :{ "model": "pokerfirstmod:block/silver_ore"
}
}
}
model/block
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "pokerfirstmod:block/silver_ore"
}
}
model/item
{
"parent": "pokerfirstmod:block/silver_ore"
}
材質
我們在recipe資料夾加入一個新json檔
{
"type": "minecraft:smelting",
"ingredient": {
"item": "pokerfirstmod:silver_ore"
},
"result": "pokerfirstmod:silver_ingot",
"experience": 1,
"cookingtime": 1
}
smelting是熔煉的type
experience是熔煉成功後給予的經驗值
cookingtime是熔煉時間
測試後發現熔煉可以完成一次,但是之後的物品會直接快速完成,沒有預定的cookingtime,我會慢慢排除錯誤