public class ExampleMod implements ModInitializer { // 对于 1.21 之前的版本,将 `Identifier.of` 替换为 `new Identifier`。 public static final Block BOX_BLOCK = Registry.register(Registries.BLOCK, Identifier.of("tutorial", "box_block"), new BoxBlock(AbstractBlock.Settings.copyOf(Blocks.CHEST))); public static final BlockItem BOX_BLOCK_ITEM = Registry.register(Registries.ITEM, Identifier.of("tutorial", "block"), new BlockItem(BOX_BLOCK, new Item.Settings())); public static final BlockEntityType BOX_BLOCK_ENTITY = Registry.register(Registry.BLOCK_ENTITY_TYPE, Identifier.of("tutorial", "box_block"), BlockEntityType.Builder.create(BoxBlockEntity::new, BOX_BLOCK).build()); // 在 1.17 使用 FabricBlockEntityTypeBuilder 而不是 BlockEntityType.Builder // public static final BlockEntityType BOX_BLOCK_ENTITY = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier("tutorial", "box_block"), // FabricBlockEntityTypeBuilder.create(BoxBlockEntity::new, BOX_BLOCK).build(null));; @Override public void onInitialize() { } }