Class RegistryHolder<R,T extends R>
java.lang.Object
net.xun.lib.common.api.registries.RegistryHolder<R,T>
- Type Parameters:
R- The base registry type (e.g.Item)T- The concrete type of the held object (must extendR)
- All Implemented Interfaces:
Supplier<T>,net.minecraft.core.Holder<R>,net.neoforged.neoforge.common.extensions.IHolderExtension<R>,net.neoforged.neoforge.registries.datamaps.IWithData<R>
- Direct Known Subclasses:
RegistryBlock,RegistryItem
public class RegistryHolder<R,T extends R>
extends Object
implements net.minecraft.core.Holder<R>, Supplier<T>
A registry-backed holder implementation that wraps a registry entry and its supplier.
This class acts as a bridge between Holder and Supplier, allowing lazy initialization
and late binding to actual registry entries.
-
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 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRegistryHolder(net.minecraft.resources.ResourceKey<R> key, Supplier<T> supplier) Creates a new RegistryHolder instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidBinds this holder to a concrete registry holder.booleancanSerializeIn(net.minecraft.core.HolderOwner<R> holderOwner) static <R,T extends R>
RegistryHolder<R, T> booleanget()Gets the underlying supplier for the held object.inthashCode()net.minecraft.core.Holder<R> holder()Gets the underlying registry holder.booleanbooleanDeprecated.booleanbooleanis(net.minecraft.resources.ResourceLocation resourceLocation) booleanbooleanisBound()net.minecraft.core.Holder.Kindkind()tags()unwrap()value()Methods 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
-
Field Details
-
key
Resource key identifying the held object in the registry
-
-
Constructor Details
-
RegistryHolder
Creates a new RegistryHolder instance.- Parameters:
key- Resource key identifying the object in the registrysupplier- Supplier providing the concrete instance of the object
-
-
Method Details
-
create
public static <R,T extends R> RegistryHolder<R,T> create(net.minecraft.resources.ResourceKey<R> key, Supplier<T> supplier) -
getSupplier
Gets the underlying supplier for the held object.- Returns:
- The supplier providing the concrete instance
-
bind
Binds this holder to a concrete registry holder.This should be called during registry initialization to link the holder to the actual registry entry.
- Parameters:
holder- The concrete holder from the registry- Throws:
IllegalStateException- If already bound
-
holder
Gets the underlying registry holder.- Returns:
- The bound holder instance
-
value
- Specified by:
valuein interfacenet.minecraft.core.Holder<R>- Throws:
NullPointerException- If accessed before binding
-
get
- Specified by:
getin interfaceSupplier<R>- Throws:
NullPointerException- If accessed before binding
-
isBound
public boolean isBound()- Specified by:
isBoundin interfacenet.minecraft.core.Holder<R>
-
is
public boolean is(net.minecraft.resources.ResourceLocation resourceLocation) - Specified by:
isin interfacenet.minecraft.core.Holder<R>
-
is
- Specified by:
isin interfacenet.minecraft.core.Holder<R>
-
is
- Specified by:
isin interfacenet.minecraft.core.Holder<R>
-
is
- Specified by:
isin interfacenet.minecraft.core.Holder<R>
-
is
Deprecated.- Specified by:
isin interfacenet.minecraft.core.Holder<R>
-
tags
- Specified by:
tagsin interfacenet.minecraft.core.Holder<R>
-
unwrap
- Specified by:
unwrapin interfacenet.minecraft.core.Holder<R>
-
unwrapKey
- Specified by:
unwrapKeyin interfacenet.minecraft.core.Holder<R>
-
kind
public net.minecraft.core.Holder.Kind kind()- Specified by:
kindin interfacenet.minecraft.core.Holder<R>
-
canSerializeIn
- Specified by:
canSerializeInin interfacenet.minecraft.core.Holder<R>
-
equals
-
hashCode
public int hashCode()
-