Class GeyserHolderSet<T>

java.lang.Object
org.geysermc.geyser.session.cache.tags.GeyserHolderSet<T>

public final class GeyserHolderSet<T> extends Object
Similar to vanilla Minecraft's HolderSets, stores either a tag or a list of IDs (this list can also be represented as a single ID in vanilla HolderSets).

Because HolderSets utilise tags, when loading a HolderSet, Geyser must store tags for the registry the HolderSet is for (see JavaRegistryKey).

Use the readHolderSet(org.geysermc.geyser.session.GeyserSession, org.geysermc.geyser.session.cache.registry.JavaRegistryKey<T>, java.lang.Object, java.util.function.ToIntFunction<net.kyori.adventure.key.Key>) method to easily read a HolderSet from NBT sent by a server. To turn the HolderSet into a list of network IDs, use the resolveRaw(org.geysermc.geyser.session.cache.TagCache) method. To turn the HolderSet into a list of objects, use the resolve(org.geysermc.geyser.session.GeyserSession) method.

  • Constructor Details

    • GeyserHolderSet

      public GeyserHolderSet(JavaRegistryKey<T> registry, int @NonNull [] holders)
    • GeyserHolderSet

      public GeyserHolderSet(JavaRegistryKey<T> registry, @NonNull Tag<T> tagId)
  • Method Details

    • fromHolderSet

      public static <T> GeyserHolderSet<T> fromHolderSet(JavaRegistryKey<T> registry, @NonNull org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet holderSet)
      Constructs a GeyserHolderSet from a MCPL HolderSet.
    • resolve

      public List<T> resolve(GeyserSession session)
      Resolves the HolderSet, and automatically maps the network IDs to their respective object types. If the HolderSet is a list of IDs, this will be returned. If it is a tag, the tag will be resolved from the tag cache.
      Returns:
      the HolderSet turned into a list of objects.
    • resolveRaw

      public int[] resolveRaw(TagCache tagCache)
      Resolves the HolderSet. If the HolderSet is a list of IDs, this will be returned. If it is a tag, the tag will be resolved from the tag cache.
      Returns:
      the HolderSet turned into a list of objects.
    • readHolderSet

      public static <T> GeyserHolderSet<T> readHolderSet(GeyserSession session, JavaRegistryKey<T> registry, @Nullable Object holderSet, ToIntFunction<net.kyori.adventure.key.Key> keyIdMapping)
      Reads a HolderSet from an object from NBT.
      Parameters:
      session - session, only used for logging purposes.
      registry - the registry the HolderSet contains IDs from.
      holderSet - the HolderSet as an object from NBT.
      keyIdMapping - a function that maps resource location IDs in the HolderSet's registry to their network IDs.
    • getRegistry

      public JavaRegistryKey<T> getRegistry()
    • getTag

      public @Nullable Tag<T> getTag()
    • getHolders

      public int @Nullable [] getHolders()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object