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 DirectType 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 DirectType (in case of a custom holder), and registry(Registry, MinecraftHasher)
should be used to create the registry hasher. holder() can then be used to obtain a hasher that encodes a holder of DirectType.
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<AdventureModePredicate> static final MinecraftHasher<ArmorTrim> static final RegistryHasher<?> static final MinecraftHasher<ItemAttributeModifiers.Display> static final MinecraftHasher<ItemAttributeModifiers.DisplayType> static final MinecraftHasher<ItemAttributeModifiers.Entry> static final MinecraftHasher<ModifierOperation> static final MinecraftHasher<Integer> static final MinecraftHasher<Holder<BannerPatternLayer.BannerPattern>> static final MinecraftHasher<BannerPatternLayer> static final RegistryHasher<?> static final MinecraftHasher<AdventureModePredicate.BlockPredicate> static final MinecraftHasher<BlocksAttacks.DamageReduction> static final MinecraftHasher<BlocksAttacks.ItemDamageFunction> static final MinecraftHasher<BuiltinSound> static final RegistryHasher<?> static final MinecraftHasher<ConsumeEffect> static final MinecraftHasher<ConsumeEffectType> static final MinecraftHasher<ItemContainerSlot> static final RegistryHasher<?> static final MinecraftHasher<CustomSound> static final RegistryHasher<?> static final MinecraftHasher<DataComponent<?, ?>> static final MinecraftHasher<DataComponentType<?>> static final MinecraftHasher<DataComponent<?, ?>> static final MinecraftHasher<DataComponents> static final MinecraftHasher<BannerPatternLayer.BannerPattern> static final MinecraftHasher<InstrumentComponent.Instrument> static final MinecraftHasher<JukeboxPlayable.JukeboxSong> static final MinecraftHasher<PaintingVariant> static final MinecraftHasher<ArmorTrim.TrimMaterial> static final MinecraftHasher<ArmorTrim.TrimPattern> static final MinecraftHasher<Effect> static final RegistryHasher<?> static final RegistryHasher<?> static final RegistryHasher<?> static final MinecraftHasher<Fireworks.FireworkExplosion> static final MinecraftHasher<Integer> static final MinecraftHasher<Integer> static final RegistryHasher<?> static final MinecraftHasher<Integer> static final MinecraftHasher<Holder<InstrumentComponent.Instrument>> static final MinecraftHasher<InstrumentComponent> static final RegistryHasher<?> static final MinecraftHasher<List<ItemStack>> static final MinecraftHasher<ItemEnchantments> static final MinecraftHasher<ItemStack> static final MinecraftHasher<Consumable.ItemUseAnimation> static final MinecraftHasher<JukeboxPlayable> static final MinecraftHasher<Holder<JukeboxPlayable.JukeboxSong>> static final MinecraftHasher<Integer> static final MapBuilder<MobEffectDetails> static final MinecraftHasher<MobEffectInstance> static final MinecraftHasher<Integer> static final MinecraftHasher<Holder<PaintingVariant>> static final MinecraftHasher<Integer> static final RegistryHasher<?> static final RegistryHasher<?> static final MinecraftHasher<ProvidesTrimMaterial> static final MinecraftHasher<Integer> static final MinecraftHasher<Integer> static final MinecraftHasher<Sound> static final MinecraftHasher<SuspiciousStewEffect> static final MinecraftHasher<ToolData.Rule> static final MinecraftHasher<Holder<ArmorTrim.TrimMaterial>> static final MinecraftHasher<Holder<ArmorTrim.TrimPattern>> static final MinecraftHasher<Integer> static final RegistryHasher<?> static final RegistryHasher<?> static final RegistryHasher<?> Fields inherited from interface 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, KYORI_KEY, KYORI_KEY_REMOVAL, LONG, MNBT, NBT_LIST, NBT_MAP, POS, RARITY, SHORT, STRING, TAG, UNIT, UUID -
Method Summary
Modifier and TypeMethodDescriptionstatic RegistryHasher<?> dynamicRegistry(DynamicRegistry<?> registry) Creates a hasher that encodes registry IDs, and is also able to encodeHolders by using thedirectHasher.static <EnumConstant extends Enum<EnumConstant>>
RegistryHasher<?> enumIdRegistry(EnumConstant[] values) UsesEnum.name()(lowercased) to create a function that creates aKeyfrom aEnumConstant, and uses this astoKeyfunction inenumIdRegistry(Enum[], Function).static <EnumConstant extends Enum<EnumConstant>>
RegistryHasher<?> enumIdRegistry(EnumConstant[] values, Function<EnumConstant, String> toKey) Creates a hasher that looks up a network ID in the array ofEnumConstants, 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<Holder<DirectType>> holder()Creates a hasher that encodes aHolderofDirectType.static <T> MinecraftHasher<Holder<T>> holderIdOnly(MinecraftHasher<T> direct) default MinecraftHasher<HolderSet> Creates a hasher that hashes aHolderSetof the registry.static RegistryHasher<?> Creates a hasher that encodes registry IDs, and is also able to encodeHolders by using thedirectHasher.static <DirectType>
RegistryHasher<DirectType> registry(Registry<?> registry, MinecraftHasher<DirectType> directHasher) Creates a hasher that usingregistry(Registry)that is also able to encodeHolders by using thedirectHasher.Methods inherited from interface MinecraftHasher
cast, dispatch, dispatch, filterable, hash, list
-
Field Details
-
BLOCK
-
ITEM
-
ENTITY_TYPE
-
ENCHANTMENT
-
ATTRIBUTE
-
DATA_COMPONENT_TYPE
-
EFFECT
-
EFFECT_ID
-
POTION
-
VILLAGER_TYPE
-
BUILTIN_SOUND
-
CUSTOM_SOUND
-
SOUND_EVENT
-
DIRECT_INSTRUMENT
-
INSTRUMENT
-
DIRECT_TRIM_MATERIAL
-
TRIM_MATERIAL
-
DIRECT_TRIM_PATTERN
-
TRIM_PATTERN
-
DIRECT_JUKEBOX_SONG
-
JUKEBOX_SONG
-
DIRECT_BANNER_PATTERN
-
BANNER_PATTERN
-
WOLF_VARIANT
-
WOLF_SOUND_VARIANT
-
PIG_VARIANT
-
COW_VARIANT
-
FROG_VARIANT
-
DIRECT_PAINTING_VARIANT
-
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
-
DATA_COMPONENT_VALUE
-
DATA_COMPONENTS
-
ITEM_STACK
-
MOB_EFFECT_DETAILS
-
MOB_EFFECT_INSTANCE
-
ATTRIBUTE_MODIFIER_OPERATION
-
ITEM_ENCHANTMENTS
-
CONTAINER_SLOT
-
ITEM_CONTAINER_CONTENTS
-
BLOCK_PREDICATE
-
ADVENTURE_MODE_PREDICATE
-
ATTRIBUTE_MODIFIER_DISPLAY_TYPE
-
ATTRIBUTE_MODIFIER_DISPLAY
-
ATTRIBUTE_MODIFIER_ENTRY
-
ITEM_USE_ANIMATION
-
CONSUME_EFFECT_TYPE
-
CONSUME_EFFECT
-
SUSPICIOUS_STEW_EFFECT
-
INSTRUMENT_COMPONENT
-
TOOL_RULE
-
DAMAGE_TYPE
-
BLOCKS_ATTACKS_DAMAGE_REDUCTION
-
BLOCKS_ATTACKS_ITEM_DAMAGE_FUNCTION
-
PROVIDES_TRIM_MATERIAL
-
ARMOR_TRIM
-
JUKEBOX_PLAYABLE
-
BANNER_PATTERN_LAYER
-
FIREWORK_EXPLOSION_SHAPE
-
FIREWORK_EXPLOSION
-
-
Method Details
-
registry
Creates a hasher that encodes registry IDs, and is also able to encodeHolders by using thedirectHasher.- Parameters:
registry- the registry to create a hasher for.
-
dynamicRegistry
Creates a hasher that encodes registry IDs, and is also able to encodeHolders by using thedirectHasher.- Parameters:
registry- the registry to create a hasher for.
-
registry
static <DirectType> RegistryHasher<DirectType> registry(Registry<?> registry, MinecraftHasher<DirectType> directHasher) Creates a hasher that usingregistry(Registry)that 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 aHolderofDirectType. If the holder has an ID, theRegistryHasheris used to encode it. If the holder is custom, a direct hasher specified inregistry(Registry, 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
DirectTypeis 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.
-
holderIdOnly
-
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 aEnumConstant, 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 ofEnumConstants.- See Also:
-
enumIdRegistry
static <EnumConstant extends Enum<EnumConstant>> RegistryHasher<?> enumIdRegistry(EnumConstant[] values, Function<EnumConstant, String> toKey) Creates a hasher that looks up a network ID in the array ofEnumConstants, and then usestoKeyto turn the constant into a key, which it then hashes.- Type Parameters:
EnumConstant- the enum.- Parameters:
values- the array ofEnumConstants.toKey- the function that turns aEnumConstantinto aKey.- See Also:
-