public class ExampleMod implements ModInitializer { // 对于 1.20 以下版本: // public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.of(Material.METAL).strength(4.0f)); // 对于 1.20.5 以下版本: // public static final Block EXAMPLE_BLOCK = new Block(FabricBlockSettings.create().strength(4.0f)); // 对于自 1.20.5 之后、1.21.2 之前的版本: public static final Block EXAMPLE_BLOCK = new Block(Block.Settings.create().strength(4.0f)); @Override public void onInitialize() { Registry.register(Registries.BLOCK, new Identifier("tutorial", "example_block"), EXAMPLE_BLOCK); // 对于 1.20.5 以下版本: // Registry.register(Registries.ITEM, new Identifier("tutorial", "example_block"), new BlockItem(EXAMPLE_BLOCK, new FabricItemSettings())); // 对于 1.21 以下版本: // Registry.register(Registries.ITEM, new Identifier("tutorial", "example_block"), new BlockItem(EXAMPLE_BLOCK, new Item.Settings())); // 对于 1.21 之后的版本: Registry.register(Registries.ITEM, Identifier.of("tutorial", "example_block"), new BlockItem(EXAMPLE_BLOCK, new Item.Settings())); } }