Static Declaration
Declaration
Section titled “Declaration”Custom Items are declared as MetaItem objects.
You can declare them as static to references to them later.
// provide a custom identifiernew MetaItem.Builder(new Identifier("foo:custom_item")).build()Item Registry
Section titled “Item Registry”It is highly recommended to create a such registry to register all your items.
public class ItemRegistry { @Getter private static final Registry<MetaItem> ITEMS = new Registry<>(MetaItem.class);
// Registry<>#register passes the MetaItem inputed to its output public static final MetaItem CUSTOM_ITEM = ITEMS.register( new MetaItem.Builder(new Identifier("foo:custom_item")).build() );}The MinecraftProject object you created can then register that ITEMS registry directly.
// create a projectMinecraftProject project = new MinecraftProject(NAME, VERSION, ID);
// register the registry and compileproject.register(ItemRegistry.getITEMS());project.compile(...);Customizing the item
Section titled “Customizing the item”Data components
Section titled “Data components”Learn more on the data components page.
new MetaItem.Builder(new Identifier("foo:custom_item")) .withComponent(VanillaItemComponent.ITEM_MODEL, new Identifier("foo:custom_item")) .build()