Interface RegistryHasher<DirectType>

Type Parameters:
DirectType - the type this hasher hashes. Only used for registry hashers that can hash holders.
All Superinterfaces:
MinecraftHasher<Integer>
All Known Implementing Classes:
RegistryHasher.RegistryHasherWithDirectHasher

public interface RegistryHasher<DirectType> extends MinecraftHasher<Integer>
RegistryHashers are hashers that hash a network integer ID to a namespaced identifier. RegistryHashers can be created using static utility methods in this class, and all registry hashers should be kept in here.

The RegistryHasher parameter is only used for registry hashers that are able to encode Holders, and must be left as a ? if this functionality is not in use. This makes it clear the hasher is not supposed to be able to encode holders.

To create a hasher that can encode a Holder, a direct hasher should be created that hashes a RegistryHasher (in case of a custom holder), and registry(JavaRegistryKey, MinecraftHasher) should be used to create the registry hasher. holder() can then be used to obtain a hasher that encodes a holder of RegistryHasher.

Along with RegistryHashers, this class also contains a bunch of hashers for various Minecraft objects. For organisational purposes, these are grouped in various sections with comments.

  • Field Details

    • BLOCK

      static final RegistryHasher<?> BLOCK
    • ITEM

      static final RegistryHasher<?> ITEM
    • ENTITY_TYPE

      static final RegistryHasher<?> ENTITY_TYPE
    • ENTITY_TYPE_KEY

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType> ENTITY_TYPE_KEY
    • BLOCK_ENTITY_TYPE_KEY

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.level.block.BlockEntityType> BLOCK_ENTITY_TYPE_KEY
    • ENCHANTMENT

      static final RegistryHasher<?> ENCHANTMENT
    • ATTRIBUTE

      static final RegistryHasher<?> ATTRIBUTE
    • DATA_COMPONENT_TYPE

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType<?>> DATA_COMPONENT_TYPE
    • EFFECT

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.entity.Effect> EFFECT
    • EFFECT_ID

      static final RegistryHasher<?> EFFECT_ID
    • POTION

      static final RegistryHasher<?> POTION
    • VILLAGER_TYPE

      static final RegistryHasher<?> VILLAGER_TYPE
    • BUILTIN_SOUND

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.level.sound.BuiltinSound> BUILTIN_SOUND
    • CUSTOM_SOUND

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.level.sound.CustomSound> CUSTOM_SOUND
    • SOUND_EVENT

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound> SOUND_EVENT
    • DAMAGE_TYPE

      static final RegistryHasher<?> DAMAGE_TYPE
    • DIRECT_INSTRUMENT

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.Instrument> DIRECT_INSTRUMENT
    • INSTRUMENT

      static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.Instrument> INSTRUMENT
    • DIRECT_TRIM_MATERIAL

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim.TrimMaterial> DIRECT_TRIM_MATERIAL
    • TRIM_MATERIAL

      static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim.TrimMaterial> TRIM_MATERIAL
    • DIRECT_TRIM_PATTERN

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim.TrimPattern> DIRECT_TRIM_PATTERN
    • TRIM_PATTERN

      static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim.TrimPattern> TRIM_PATTERN
    • DIRECT_JUKEBOX_SONG

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.JukeboxSong> DIRECT_JUKEBOX_SONG
    • JUKEBOX_SONG

      static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.JukeboxSong> JUKEBOX_SONG
    • DIRECT_BANNER_PATTERN

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BannerPatternLayer.BannerPattern> DIRECT_BANNER_PATTERN
    • WOLF_VARIANT

      static final RegistryHasher<?> WOLF_VARIANT
    • WOLF_SOUND_VARIANT

      static final RegistryHasher<?> WOLF_SOUND_VARIANT
    • PIG_VARIANT

      static final RegistryHasher<?> PIG_VARIANT
    • PIG_SOUND_VARIANT

      static final RegistryHasher<?> PIG_SOUND_VARIANT
    • COW_VARIANT

      static final RegistryHasher<?> COW_VARIANT
    • COW_SOUND_VARIANT

      static final RegistryHasher<?> COW_SOUND_VARIANT
    • CHICKEN_VARIANT

      static final RegistryHasher<?> CHICKEN_VARIANT
    • CHICKEN_SOUND_VARIANT

      static final RegistryHasher<?> CHICKEN_SOUND_VARIANT
    • ZOMBIE_NAUTILUS_VARIANT

      static final RegistryHasher<?> ZOMBIE_NAUTILUS_VARIANT
    • FROG_VARIANT

      static final RegistryHasher<?> FROG_VARIANT
    • PAINTING_VARIANT

      static final RegistryHasher<?> PAINTING_VARIANT
    • CAT_VARIANT

      static final RegistryHasher<?> CAT_VARIANT
    • CAT_SOUND_VARIANT

      static final RegistryHasher<?> CAT_SOUND_VARIANT
    • FOX_VARIANT

      static final MinecraftHasher<Integer> FOX_VARIANT
    • SALMON_VARIANT

      static final MinecraftHasher<Integer> SALMON_VARIANT
    • PARROT_VARIANT

      static final MinecraftHasher<Integer> PARROT_VARIANT
    • TROPICAL_FISH_PATTERN

      static final MinecraftHasher<Integer> TROPICAL_FISH_PATTERN
    • MOOSHROOM_VARIANT

      static final MinecraftHasher<Integer> MOOSHROOM_VARIANT
    • RABBIT_VARIANT

      static final MinecraftHasher<Integer> RABBIT_VARIANT
    • HORSE_VARIANT

      static final MinecraftHasher<Integer> HORSE_VARIANT
    • LLAMA_VARIANT

      static final MinecraftHasher<Integer> LLAMA_VARIANT
    • AXOLOTL_VARIANT

      static final MinecraftHasher<Integer> AXOLOTL_VARIANT
    • DATA_COMPONENT_KEY

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent<?,?>> DATA_COMPONENT_KEY
    • DATA_COMPONENT_VALUE

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent<?,?>> DATA_COMPONENT_VALUE
    • DATA_COMPONENTS

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents> DATA_COMPONENTS
    • ITEM_STACK

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack> ITEM_STACK
    • MOB_EFFECT_DETAILS

      static final MapBuilder<org.geysermc.mcprotocollib.protocol.data.game.item.component.MobEffectDetails> MOB_EFFECT_DETAILS
    • MOB_EFFECT_INSTANCE

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.MobEffectInstance> MOB_EFFECT_INSTANCE
    • ATTRIBUTE_MODIFIER_OPERATION

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.ModifierOperation> ATTRIBUTE_MODIFIER_OPERATION
    • ITEM_ENCHANTMENTS

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemEnchantments> ITEM_ENCHANTMENTS
    • CONTAINER_SLOT

      static final MinecraftHasher<ItemContainerSlot> CONTAINER_SLOT
    • ITEM_CONTAINER_CONTENTS

      static final MinecraftHasher<List<Optional<org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack>>> ITEM_CONTAINER_CONTENTS
    • BLOCK_PREDICATE

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.AdventureModePredicate.BlockPredicate> BLOCK_PREDICATE
    • ADVENTURE_MODE_PREDICATE

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.AdventureModePredicate> ADVENTURE_MODE_PREDICATE
    • ATTRIBUTE_MODIFIER_DISPLAY_TYPE

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemAttributeModifiers.DisplayType> ATTRIBUTE_MODIFIER_DISPLAY_TYPE
    • ATTRIBUTE_MODIFIER_DISPLAY

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemAttributeModifiers.Display> ATTRIBUTE_MODIFIER_DISPLAY
    • ATTRIBUTE_MODIFIER_ENTRY

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemAttributeModifiers.Entry> ATTRIBUTE_MODIFIER_ENTRY
    • ITEM_USE_ANIMATION

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.Consumable.ItemUseAnimation> ITEM_USE_ANIMATION
    • CONSUME_EFFECT

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ConsumeEffect> CONSUME_EFFECT
    • SUSPICIOUS_STEW_EFFECT

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.SuspiciousStewEffect> SUSPICIOUS_STEW_EFFECT
    • TOOL_RULE

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ToolData.Rule> TOOL_RULE
    • BLOCKS_ATTACKS_DAMAGE_REDUCTION

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BlocksAttacks.DamageReduction> BLOCKS_ATTACKS_DAMAGE_REDUCTION
    • BLOCKS_ATTACKS_ITEM_DAMAGE_FUNCTION

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BlocksAttacks.ItemDamageFunction> BLOCKS_ATTACKS_ITEM_DAMAGE_FUNCTION
    • KINETIC_WEAPON_CONDITION

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.KineticWeapon.Condition> KINETIC_WEAPON_CONDITION
    • SWING_ANIMATION_TYPE

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.SwingAnimation.Type> SWING_ANIMATION_TYPE
    • ARMOR_TRIM

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim> ARMOR_TRIM
    • FIREWORK_EXPLOSION_SHAPE

      static final MinecraftHasher<Integer> FIREWORK_EXPLOSION_SHAPE
    • FIREWORK_EXPLOSION

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.Fireworks.FireworkExplosion> FIREWORK_EXPLOSION
    • BEEHIVE_OCCUPANT

      static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BeehiveOccupant> BEEHIVE_OCCUPANT
  • Method Details

    • registry

      static RegistryHasher<?> registry(JavaRegistryKey<?> registry)
      Creates a hasher that uses the JavaRegistryKey.key(GeyserSession, int) method to turn a network ID into a Key, and then encodes this key.
      Parameters:
      registry - the registry to create a hasher for.
    • registry

      static <DirectType> RegistryHasher<DirectType> registry(JavaRegistryKey<?> registry, MinecraftHasher<DirectType> directHasher)
      Creates a hasher that encodes network IDs using registry(JavaRegistryKey), and is also able to encode Holders by using the directHasher.

      A hasher that encodes Holders can be obtained by using holder()

      Type Parameters:
      DirectType - the type of custom objects.
      Parameters:
      registry - the registry to create a hasher for.
      directHasher - the hasher that encodes a custom object.
      See Also:
    • holder

      default MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.Holder<DirectType>> holder()
      Creates a hasher that encodes a Holder of RegistryHasher. If the holder has an ID, the RegistryHasher is used to encode it. If the holder is custom, a direct hasher specified in registry(JavaRegistryKey, MinecraftHasher) is used to encode it.

      This method can only be used if this hasher has a direct hasher attached to it. That is only the case if RegistryHasher is not ?. If this hasher doesn't have a direct hasher, a IllegalStateException will be thrown upon use.

      Throws:
      IllegalStateException - when this hasher does not have a direct hasher attached to it.
    • holderSet

      default MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet> holderSet()
      Creates a hasher that hashes a HolderSet of the registry. HolderSets can encode as a hash-prefixed tag, a single namespaced ID, or a list of namespaced IDs.

      The hasher throws a IllegalStateException if the holder set does not have a tag nor a list of IDs. This should never happen.

    • enumRegistry

      static <EnumConstant extends Enum<EnumConstant>> MinecraftHasher<EnumConstant> enumRegistry()
      Creates a hasher that uses Enum.name() (lowercased) to create a key in the minecraft namespace, and then hashes it.

      Please be aware that you are using literal enum constants as key paths here, meaning that if there is a typo in a constant, or a constant changes name, things may break. Use cautiously.

      Type Parameters:
      EnumConstant - the enum.
    • enumIdRegistry

      static <EnumConstant extends Enum<EnumConstant>> RegistryHasher<?> enumIdRegistry(EnumConstant[] values)
      Uses Enum.name() (lowercased) to create a function that creates a Key from a RegistryHasher, and uses this as toKey function in enumIdRegistry(Enum[], Function).

      Please be aware that you are using literal enum constants as key paths here, meaning that if there is a typo in a constant, or a constant changes name, things may break. Use cautiously.

      Type Parameters:
      EnumConstant - the enum.
      Parameters:
      values - the array of RegistryHashers.
      See Also:
    • enumIdRegistry

      static <EnumConstant extends Enum<EnumConstant>> RegistryHasher<?> enumIdRegistry(EnumConstant[] values, Function<EnumConstant,net.kyori.adventure.key.Key> toKey)
      Creates a hasher that looks up a network ID in the array of RegistryHashers, and then uses toKey to turn the constant into a key, which it then hashes.
      Type Parameters:
      EnumConstant - the enum.
      Parameters:
      values - the array of RegistryHashers.
      toKey - the function that turns a RegistryHasher into a Key.
      See Also: