首發於Enaium的我的博客json
public class ExampleMod implements ModInitializer { // an instance of our new block public static final Block END_HEART_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).build()); [...] }
public class ExampleMod implements ModInitializer { // block creation […] @Override public void onInitialize() { Registry.register(Registry.BLOCK, new Identifier("endarmor", "end_heart_block"), END_HEART_BLOCK); } }
運行遊戲發現沒法找到方塊是由於沒有建立方塊物品 可是可使用命令在建立這個方塊ide
直接註冊就行ui
public class ExampleMod implements ModInitializer { // block creation […] @Override public void onInitialize() { // block registration [...] Registry.register(Registry.ITEM, new Identifier("endarmor", "end_heart_block"), new BlockItem(END_HEART_BLOCK, new Item.Settings().itemGroup(ItemGroup.MISC))); } }
Blockstate: src/main/resources/assets/endarmor/blockstates/end_heart_block.json Block Model: src/main/resources/assets/endarmor/models/block/end_heart_block.json Item Model: src/main/resources/assets/endarmor/models/item/end_heart_block.json Block Texture: src/main/resources/assets/endarmor/textures/block/end_heart_block.png
blockstates/end_heart_block.jsonspa
{ "variants": { "": { "model": "endarmor:block/end_heart_block" } } }
models/block/end_heart_block.jsoncode
{ "parent": "block/cube_all", "textures": { "all": "endarmor:block/end_heart_block" } }
models/item/end_heart_block.jsonblog
{ "parent": "endarmor:block/end_heart_block" }
textures/block/end_heart_block.png遊戲
位置 \src\main\resources\data\endarmor\loot_tables\blocks\end_heart_block.json
rem
{ "type": "minecraft:block", "pools": [ { "rolls": 1, "entries": [ { "type": "minecraft:item", "name": "endarmor:end_heart_block" } ], "conditions": [ { "condition": "minecraft:survives_explosion" } ] } ] }
public class ExampleBlock extends Block { public ExampleBlock(Settings settings) { super(settings); } }
private static final EndHeartBlock END_HEART_BLOCK = new EndHeartBlock(FabricBlockSettings.of(Material.METAL).build());