Items
Creating your Item​
Similarly to how a Block can be created, you can create an Item through the ItemBase
class.
You can customize it through FabricItemSettings()
.
public static final Item RUBY = new ItemBase(YOURMOD_GROUP);
public static final Item YOURMOD_ITEM = new ItemBase(new FabricItemSettings());
Registering​
Registering is done with the RegistryHandler
class.
You can register your Item with registerGeneratedItem()
if it represents a generic item, or registerHandheldItem()
if it represents a tool.
RegistryHandler.registerGeneratedItem("yourmodid", "ruby", RUBY);
Result​
Your code should now look something like this:
MyMod.java
public static final Block RUBY_ORE = new BlockBase(Material.STONE, 2.5f, 7.0f, BlockSoundGroup.STONE);
public static final ItemGroup YOURMOD_GROUP = new ItemGroupBase("yourmodid", "itemgroup", RUBY_ORE).group;
public static final Item RUBY = new ItemBase(YOURMOD_GROUP);
@Override
public void onInitialize() {
RegistryHandler.registerBlockAndItem("yourmodid", "ruby_ore", RUBY_ORE, YOURMOD_GROUP);
RegistryHandler.registerGeneratedItem("yourmodid", "ruby", RUBY);
}