Class GeyserHolderSet<T>
java.lang.Object
org.geysermc.geyser.session.cache.tags.GeyserHolderSet<T>
Similar to vanilla Minecraft's HolderSets, stores either:
- A single reference to a tag, which holds the list of IDs,
- A list of IDs (can also be represented as a single ID),
- A list of inline elements (only supported by some sets, can also be represented as a single inline element), or,
- A list with both IDs and inline elements (only supported by some sets).
Because HolderSets may utilise tags, when loading a HolderSet, Geyser must store tags for the registry the HolderSet is for. This is done for all registries registered in
JavaRegistries.
GeyserHolderSets can be constructed using the empty(JavaRegistryKey), ofTag(JavaRegistryKey, Tag),
and of(JavaRegistryKey, List) methods.-
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(JavaRegistryProvider registries, @Nullable T object) Resolves this set, and checks if the givenobjectis in it.booleanempty()static <T> GeyserHolderSet<T> empty(JavaRegistryKey<T> registry) Constructs an emptyGeyserHolderSet.static <T> GeyserHolderSet<T> fromMCPL(JavaRegistryKey<T> registry, org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet holderSet) Constructs aGeyserHolderSetfrom a MCPLHolderSet.static <T> GeyserHolderSet<T> of(JavaRegistryKey<T> registry, int id) Constructs aGeyserHolderSetholding a single registry reference (ID holder).static <T> GeyserHolderSet<T> of(JavaRegistryKey<T> registry, it.unimi.dsi.fastutil.ints.IntList ids) Constructs aGeyserHolderSetholding a list of registry reference (ID holder).static <T> GeyserHolderSet<T> of(JavaRegistryKey<T> registry, List<org.geysermc.mcprotocollib.protocol.data.game.Holder<T>> holders) Constructs aGeyserHolderSetholding a list of holders (either ID or custom holders).static <T> GeyserHolderSet<T> of(JavaRegistryKey<T> registry, T element) Constructs aGeyserHolderSetholding a single inline element (custom holder).static <T> GeyserHolderSet<T> ofTag(JavaRegistryKey<T> registry, net.kyori.adventure.key.Key tag) Constructs aGeyserHolderSetfor the giventag.static <T> GeyserHolderSet<T> ofTag(JavaRegistryKey<T> registry, Tag<T> tag) Constructs aGeyserHolderSetfor the giventag.static <T> GeyserHolderSet<T> readHolderSet(JavaRegistryProvider registries, JavaRegistryKey<T> registry, String locale, @Nullable Object holderSet) Reads a HolderSet from a NBT object.static <T> GeyserHolderSet<T> readHolderSet(GeyserSession session, JavaRegistryKey<T> registry, @Nullable Object holderSet) Reads a HolderSet from a NBT object.registry()resolve(JavaRegistryProvider registries) Resolves this set to a list ofGeyserHolderSets.resolveHolders(JavaRegistryProvider registries) Resolves this set to a list ofHolders, which may either be anHolder.IdHolderor aHolder.CustomHolder(depending on the registry, both can be present in the list at once).int[]resolveRawHolders(JavaRegistryProvider registries) Deprecated.tag()
-
Method Details
-
empty
Constructs an emptyGeyserHolderSet.- Type Parameters:
T- the type of the set- Parameters:
registry- the registry the set is bound to- Returns:
- a new empty
GeyserHolderSetfor the given registry
-
ofTag
public static <T> GeyserHolderSet<T> ofTag(JavaRegistryKey<T> registry, net.kyori.adventure.key.Key tag) Constructs aGeyserHolderSetfor the giventag.- Type Parameters:
T- the type of the set- Parameters:
registry- the registry the set is bound totag- the tag of the set- Returns:
- the constructed
GeyserHolderSet
-
ofTag
Constructs aGeyserHolderSetfor the giventag.- Type Parameters:
T- the type of the set- Parameters:
registry- the registry the set is bound totag- the tag of the set- Returns:
- the constructed
GeyserHolderSet
-
of
Constructs aGeyserHolderSetholding a single registry reference (ID holder).- Type Parameters:
T- the type of the set- Parameters:
registry- the registry the set is bound toid- the single ID- Returns:
- the constructed
GeyserHolderSet
-
of
Constructs aGeyserHolderSetholding a single inline element (custom holder).- Type Parameters:
T- the type of the set- Parameters:
registry- the registry the set is bound toelement- the single inline element- Returns:
- the constructed
GeyserHolderSet
-
of
public static <T> GeyserHolderSet<T> of(JavaRegistryKey<T> registry, it.unimi.dsi.fastutil.ints.IntList ids) Constructs aGeyserHolderSetholding a list of registry reference (ID holder).- Type Parameters:
T- the type of the set- Parameters:
registry- the registry the set is bound toids- the list of references- Returns:
- the constructed
GeyserHolderSet
-
of
public static <T> GeyserHolderSet<T> of(JavaRegistryKey<T> registry, List<org.geysermc.mcprotocollib.protocol.data.game.Holder<T>> holders) Constructs aGeyserHolderSetholding a list of holders (either ID or custom holders).- Type Parameters:
T- the type of the set- Parameters:
registry- the registry the set is bound toholders- the list of holders- Returns:
- the constructed
GeyserHolderSet
-
fromMCPL
public static <T> GeyserHolderSet<T> fromMCPL(JavaRegistryKey<T> registry, org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet holderSet) Constructs aGeyserHolderSetfrom a MCPLHolderSet.- Type Parameters:
T- the type of the set- Parameters:
registry- the registry the set is bound toholderSet- the MCPLHolderSet- Returns:
- the constructed
GeyserHolderSet
-
tag
- Returns:
- the tag of this set, if this set is tag-based
-
contains
Resolves this set, and checks if the givenobjectis in it.- Parameters:
registries- theJavaRegistryProviderobject- theobjectto check for- Returns:
- true if the given
objectwas in this set, false otherwise
-
resolveHolders
public List<org.geysermc.mcprotocollib.protocol.data.game.Holder<T>> resolveHolders(JavaRegistryProvider registries) Resolves this set to a list ofHolders, which may either be anHolder.IdHolderor aHolder.CustomHolder(depending on the registry, both can be present in the list at once).- Parameters:
registries- theJavaRegistryProvider- Returns:
- the resolved set as a list of
Holders
-
resolveRawHolders
Deprecated.Resolves this set to a raw int-array of network IDs. This will not work for sets that have any inline holders.This method is deprecated: prefer using
resolveHolders(JavaRegistryProvider)orresolve(JavaRegistryProvider)as much as possible, which also won't fail on inline holders.- Parameters:
registries- theGeyserSession- Returns:
- the resolved set as a raw int-array of network IDs
-
resolve
Resolves this set to a list ofGeyserHolderSets. This callsresolveHolders(JavaRegistryProvider), and maps theHolder.IdHolders to aGeyserHolderSetusingJavaRegistryKey.get(JavaRegistryProvider, int).- Parameters:
registries- theJavaRegistryProvider- Returns:
- the resolved set as a list of
Holders
-
readHolderSet
public static <T> GeyserHolderSet<T> readHolderSet(GeyserSession session, JavaRegistryKey<T> registry, @Nullable Object holderSet) Reads a HolderSet from a NBT object. When the HolderSet contains inline elements, and a suitable reader exists inJavaRegistryReaders, that reader will be used to parse the inline element.- Type Parameters:
T- the type of the registry/HolderSet- Parameters:
session- theGeyserSessionregistry- the registry the HolderSet contains elements fromholderSet- the HolderSet as an NBT object
-
readHolderSet
public static <T> GeyserHolderSet<T> readHolderSet(JavaRegistryProvider registries, JavaRegistryKey<T> registry, String locale, @Nullable Object holderSet) Reads a HolderSet from a NBT object. When the HolderSet contains inline elements, and a suitable reader exists inJavaRegistryReaders, that reader will be used to parse the inline element.This method should generally only be used in a
JavaRegistryReader, whereGeyserSessions may not always be present. Outside of registry readers, you should generally usereadHolderSet(GeyserSession, JavaRegistryKey, Object).- Type Parameters:
T- the type of the registry/HolderSet- Parameters:
registries- theJavaRegistryProviderregistry- the registry the HolderSet contains elements fromlocale- the locale to use when translating messagesholderSet- the HolderSet as an NBT object
-
registry
-
empty
public boolean empty()
-