Class TagCache

java.lang.Object
org.geysermc.geyser.session.cache.TagCache

public final class TagCache extends Object
Manages information sent from the ClientboundUpdateTagsPacket. If that packet is not sent, all lists here will remain empty, matching Java Edition behavior. Looking up a tag that wasn't listed in that packet will return an empty array. Only tags from registries in JavaRegistries are stored. Read JavaRegistryKey for more information.

To simply check if an element is in a tag, it's preferred to use the element's "is" method, if available. For example:

  • Constructor Details

  • Method Details

    • loadPacket

      public void loadPacket(org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundUpdateTagsPacket packet)
    • is

      public boolean is(@NonNull Tag<?> tag, int id)
      Should only be used when the network ID of an element is already known. If not, prefer using the is(Tag, Object) shorthand method.
    • is

      public <T> boolean is(@NonNull Tag<T> tag, @NonNull T object)
    • is

      public <T> boolean is(@NonNull GeyserHolderSet<T> holderSet, @Nullable T object)
      Returns:
      true if the specified network ID is in the given GeyserHolderSet.
    • is

      public <T> boolean is(@Nullable org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet holderSet, @NonNull JavaRegistryKey<T> registry, int id)
      Returns:
      true if the specified network ID is in the given HolderSet set.
    • get

      public <T> List<T> get(@NonNull Tag<T> tag)
    • getRaw

      public int[] getRaw(@NonNull Tag<?> tag)
      Returns:
      the network IDs in the given tag. This can be an empty array.
    • mapRawArray

      public static <T> List<T> mapRawArray(GeyserSession session, int[] array, JavaRegistryKey<T> registry)
      Maps a raw array of network IDs to their respective objects.