Class RegistryItem<T extends net.minecraft.world.item.Item>
java.lang.Object
net.xun.lib.common.api.registries.RegistryHolder<net.minecraft.world.item.Item,T>
net.xun.lib.common.api.registries.RegistryItem<T>
- Type Parameters:
T- The concrete item type (must extendItem)
- All Implemented Interfaces:
Supplier<T>,net.minecraft.core.Holder<net.minecraft.world.item.Item>,net.minecraft.world.level.ItemLike,net.neoforged.neoforge.common.extensions.IHolderExtension<net.minecraft.world.item.Item>,net.neoforged.neoforge.registries.datamaps.IWithData<net.minecraft.world.item.Item>
public class RegistryItem<T extends net.minecraft.world.item.Item>
extends RegistryHolder<net.minecraft.world.item.Item,T>
implements net.minecraft.world.level.ItemLike
A specialized registry holder implementation for items that implements
ItemLike.
This class provides convenient methods for working with items, including creating item stacks of varying sizes.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.core.Holder
net.minecraft.core.Holder.Direct<T>, net.minecraft.core.Holder.Kind, net.minecraft.core.Holder.Reference<T> -
Field Summary
Fields inherited from class net.xun.lib.common.api.registries.RegistryHolder
key -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRegistryItem(net.minecraft.resources.ResourceKey<net.minecraft.world.item.Item> key, Supplier<T> supplier) Constructs a new item registry holder. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.item.ItemasItem()Gets this item instance.voidbind(net.minecraft.core.Holder<net.minecraft.world.item.Item> holder) Binds this holder to a concrete registry holder.static <T extends net.minecraft.world.item.Item>
RegistryItem<T> createItem(net.minecraft.resources.ResourceKey<net.minecraft.world.item.Item> key, Supplier<T> supplier) Creates a new item registry holder using aResourceKey.static <T extends net.minecraft.world.item.Item>
RegistryItem<T> createItem(net.minecraft.resources.ResourceLocation key, Supplier<T> supplier) Creates a new item registry holder using aResourceLocation.net.minecraft.world.item.ItemStacktoStack()Creates anItemStackof this item with a count of 1.net.minecraft.world.item.ItemStacktoStack(int count) Creates anItemStackof this item with the specified count.Methods inherited from class net.xun.lib.common.api.registries.RegistryHolder
canSerializeIn, create, equals, get, getSupplier, hashCode, holder, is, is, is, is, is, isBound, kind, tags, unwrap, unwrapKey, valueMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.core.Holder
getRegisteredNameMethods inherited from interface net.neoforged.neoforge.common.extensions.IHolderExtension
getDelegate, getKey, unwrapLookupMethods inherited from interface net.neoforged.neoforge.registries.datamaps.IWithData
getData
-
Constructor Details
-
Method Details
-
toStack
public net.minecraft.world.item.ItemStack toStack()Creates anItemStackof this item with a count of 1.- Returns:
- The created item stack
- Throws:
IllegalStateException- If the created stack is unexpectedly empty
-
toStack
public net.minecraft.world.item.ItemStack toStack(int count) Creates anItemStackof this item with the specified count.- Parameters:
count- The stack size- Returns:
- The created item stack
- Throws:
IllegalStateException- If the created stack is unexpectedly empty
-
createItem
public static <T extends net.minecraft.world.item.Item> RegistryItem<T> createItem(net.minecraft.resources.ResourceLocation key, Supplier<T> supplier) Creates a new item registry holder using aResourceLocation.- Type Parameters:
T- The concrete item type- Parameters:
key- The resource location identifying the itemsupplier- Supplier providing the item instance- Returns:
- The created registry holder
-
createItem
public static <T extends net.minecraft.world.item.Item> RegistryItem<T> createItem(net.minecraft.resources.ResourceKey<net.minecraft.world.item.Item> key, Supplier<T> supplier) Creates a new item registry holder using aResourceKey.- Type Parameters:
T- The concrete item type- Parameters:
key- The resource key identifying the itemsupplier- Supplier providing the item instance- Returns:
- The created registry holder
-
asItem
public net.minecraft.world.item.Item asItem()Gets this item instance.- Specified by:
asItemin interfacenet.minecraft.world.level.ItemLike- Returns:
- The item itself
-
bind
public void bind(net.minecraft.core.Holder<net.minecraft.world.item.Item> holder) Binds this holder to a concrete registry holder.- Overrides:
bindin classRegistryHolder<net.minecraft.world.item.Item,T extends net.minecraft.world.item.Item> - Parameters:
holder- The concrete holder from the registry
-