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
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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.AdventureModePredicate>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim>static final RegistryHasher<?>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemAttributeModifiers.Entry>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.ModifierOperation>static final MinecraftHasher<Integer>static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BannerPatternLayer.BannerPattern>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BannerPatternLayer>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BeehiveOccupant>static final RegistryHasher<?>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.AdventureModePredicate.BlockPredicate>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BlocksAttacks.DamageReduction>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BlocksAttacks.ItemDamageFunction>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.level.sound.BuiltinSound>static final RegistryHasher<?>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ConsumeEffect>static final MinecraftHasher<ConsumeEffectType>static final MinecraftHasher<ItemContainerSlot>static final RegistryHasher<?>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.level.sound.CustomSound>static final RegistryHasher<?>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent<?,?>> static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType<?>>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent<?,?>> static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BannerPatternLayer.BannerPattern>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.InstrumentComponent.Instrument>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.JukeboxPlayable.JukeboxSong>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.PaintingVariant>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim.TrimMaterial>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim.TrimPattern>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.entity.Effect>static final RegistryHasher<?>static final RegistryHasher<?>static final RegistryHasher<?>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.Fireworks.FireworkExplosion>static final MinecraftHasher<Integer>static final MinecraftHasher<Integer>static final RegistryHasher<?>static final MinecraftHasher<Integer>static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.InstrumentComponent.Instrument>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.InstrumentComponent>static final RegistryHasher<?>static final MinecraftHasher<List<org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack>>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemEnchantments>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.Consumable.ItemUseAnimation>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.JukeboxPlayable>static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.JukeboxPlayable.JukeboxSong>static final MinecraftHasher<Integer>static final MapBuilder<org.geysermc.mcprotocollib.protocol.data.game.item.component.MobEffectDetails>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.MobEffectInstance>static final MinecraftHasher<Integer>static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.PaintingVariant>static final MinecraftHasher<Integer>static final RegistryHasher<?>static final RegistryHasher<?>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ProvidesTrimMaterial>static final MinecraftHasher<Integer>static final MinecraftHasher<Integer>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.SuspiciousStewEffect>static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ToolData.Rule>static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim.TrimMaterial>static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim.TrimPattern>static final MinecraftHasher<Integer>static final RegistryHasher<?>static final RegistryHasher<?>static final RegistryHasher<?>Fields inherited from interface org.geysermc.geyser.item.hashing.MinecraftHasher
BOOL, BYTE, DOUBLE, DYE_COLOR, EQUIPMENT_SLOT, EQUIPMENT_SLOT_GROUP, FLOAT, GAME_PROFILE, GAME_PROFILE_PROPERTY, GLOBAL_POS, INT, INT_ARRAY, KEY, KEY_REMOVAL, LONG, NBT_LIST, NBT_MAP, POS, RARITY, SHORT, STRING, TAG, UNIT, UUID -
Method Summary
Modifier and TypeMethodDescriptionstatic <EnumConstant extends Enum<EnumConstant>>
RegistryHasher<?>enumIdRegistry(EnumConstant[] values) UsesEnum.name()(lowercased) to create a function that creates aKeyfrom aRegistryHasher, and uses this astoKeyfunction inenumIdRegistry(Enum[], Function).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 ofRegistryHashers, and then usestoKeyto turn the constant into a key, which it then hashes.static <EnumConstant extends Enum<EnumConstant>>
MinecraftHasher<EnumConstant>Creates a hasher that usesEnum.name()(lowercased) to create a key in theminecraftnamespace, and then hashes it.default MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.Holder<DirectType>>holder()Creates a hasher that encodes aHolderofRegistryHasher.default MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet>Creates a hasher that hashes aHolderSetof the registry.static RegistryHasher<?>registry(JavaRegistryKey<?> registry) Creates a hasher that uses theJavaRegistryKey.keyFromNetworkId(GeyserSession, int)method to turn a network ID into aKey, and then encodes this key.static <DirectType>
RegistryHasher<DirectType>registry(JavaRegistryKey<?> registry, MinecraftHasher<DirectType> directHasher) Creates a hasher that encodes network IDs usingregistry(JavaRegistryKey), and is also able to encodeHolders by using thedirectHasher.Methods inherited from interface org.geysermc.geyser.item.hashing.MinecraftHasher
cast, dispatch, dispatch, filterable, hash, list, sessionCast
-
Field Details
-
BLOCK
-
ITEM
-
ENTITY_TYPE
-
ENCHANTMENT
-
ATTRIBUTE
-
DATA_COMPONENT_TYPE
static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType<?>> DATA_COMPONENT_TYPE -
EFFECT
-
EFFECT_ID
-
POTION
-
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
-
DIRECT_INSTRUMENT
static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.InstrumentComponent.Instrument> DIRECT_INSTRUMENT -
INSTRUMENT
static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.InstrumentComponent.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.JukeboxPlayable.JukeboxSong> DIRECT_JUKEBOX_SONG -
JUKEBOX_SONG
static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.JukeboxPlayable.JukeboxSong> JUKEBOX_SONG -
DIRECT_BANNER_PATTERN
static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BannerPatternLayer.BannerPattern> DIRECT_BANNER_PATTERN -
BANNER_PATTERN
static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BannerPatternLayer.BannerPattern> BANNER_PATTERN -
WOLF_VARIANT
-
WOLF_SOUND_VARIANT
-
PIG_VARIANT
-
COW_VARIANT
-
FROG_VARIANT
-
DIRECT_PAINTING_VARIANT
static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.PaintingVariant> DIRECT_PAINTING_VARIANT -
PAINTING_VARIANT
static final RegistryHasher<org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.PaintingVariant> PAINTING_VARIANT -
CAT_VARIANT
-
FOX_VARIANT
-
SALMON_VARIANT
-
PARROT_VARIANT
-
TROPICAL_FISH_PATTERN
-
MOOSHROOM_VARIANT
-
RABBIT_VARIANT
-
HORSE_VARIANT
-
LLAMA_VARIANT
-
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
-
ITEM_CONTAINER_CONTENTS
static final MinecraftHasher<List<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_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_TYPE
-
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 -
INSTRUMENT_COMPONENT
static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.InstrumentComponent> INSTRUMENT_COMPONENT -
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 -
PROVIDES_TRIM_MATERIAL
static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ProvidesTrimMaterial> PROVIDES_TRIM_MATERIAL -
ARMOR_TRIM
static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim> ARMOR_TRIM -
JUKEBOX_PLAYABLE
static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.JukeboxPlayable> JUKEBOX_PLAYABLE -
BANNER_PATTERN_LAYER
static final MinecraftHasher<org.geysermc.mcprotocollib.protocol.data.game.item.component.BannerPatternLayer> BANNER_PATTERN_LAYER -
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
Creates a hasher that uses theJavaRegistryKey.keyFromNetworkId(GeyserSession, int)method to turn a network ID into aKey, 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 usingregistry(JavaRegistryKey), and is also able to encodeHolders by using thedirectHasher.A hasher that encodes
Holders can be obtained by usingholder()- 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
Creates a hasher that encodes aHolderofRegistryHasher. If the holder has an ID, theRegistryHasheris used to encode it. If the holder is custom, a direct hasher specified inregistry(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
RegistryHasheris not?. If this hasher doesn't have a direct hasher, aIllegalStateExceptionwill 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 aHolderSetof the registry.HolderSets can encode as a hash-prefixed tag, a single namespaced ID, or a list of namespaced IDs.The hasher throws a
IllegalStateExceptionif the holder set does not have a tag nor a list of IDs. This should never happen. -
enumRegistry
Creates a hasher that usesEnum.name()(lowercased) to create a key in theminecraftnamespace, 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) UsesEnum.name()(lowercased) to create a function that creates aKeyfrom aRegistryHasher, and uses this astoKeyfunction inenumIdRegistry(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 ofRegistryHashers.- 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 ofRegistryHashers, and then usestoKeyto turn the constant into a key, which it then hashes.- Type Parameters:
EnumConstant- the enum.- Parameters:
values- the array ofRegistryHashers.toKey- the function that turns aRegistryHasherinto aKey.- See Also:
-