-
-
Notifications
You must be signed in to change notification settings - Fork 686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve tag loading and load non-vanilla tags as well #4849
Improve tag loading and load non-vanilla tags as well #4849
Conversation
core/src/main/java/org/geysermc/geyser/session/cache/TagCache.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/geysermc/geyser/session/cache/tags/TagRegistry.java
Outdated
Show resolved
Hide resolved
…y#getVanillaTags return original map
…rics # Conflicts: # core/src/main/java/org/geysermc/geyser/entity/type/living/animal/PigEntity.java # core/src/main/java/org/geysermc/geyser/entity/type/living/animal/RabbitEntity.java # core/src/main/java/org/geysermc/geyser/entity/type/living/animal/StriderEntity.java # core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/CamelEntity.java # core/src/main/java/org/geysermc/geyser/item/enchantment/Enchantment.java # core/src/main/java/org/geysermc/geyser/session/cache/RegistryCache.java
A lot has changed now, generics have been implemented for type safety and some stuff has moved around or been added. Pretty happy with how it looks now, but this definitely still needs testing. |
core/src/main/java/org/geysermc/geyser/session/cache/tags/HolderSet.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/geysermc/geyser/session/cache/tags/HolderSet.java
Outdated
Show resolved
Hide resolved
Both of @Camotoy's reviews have been addressed in the latest commit. I've also done some basic gameplay testing and let Geyser make a printout of all loaded tags to confirm both vanilla- and non-vanilla tags loaded successfully. |
This PR improves the way Geyser loads tags sent by the server, which allows both vanilla and non-vanilla tags to be loaded. It also makes it easier to add new registries to load tags for. Loading all tags for a registry, and not just vanilla ones, is important for datapack support and matches the behaviour of the Java client. Datapacks can define custom tags and then use these elsewhere, such as in custom enchantments.
To start with, the PR adds a new
JavaRegistryKey<T>
record, which is used to define a Java registry (can be both hardcoded or data-driven). The record doesn't store the contents of a registry (this is done byRegistryCache
or other classes for hardcoded registries), rather, it stores its registry key, and optionally a network serializer- and deserializer for translating between network IDs and registry objects.JavaRegistryKey<T>
is used to define registries that Geyser should load data-driven objects (inRegistryCache
) or tags (inTagCache
) for. Instances of this record are created and stored in the newJavaRegistries
class, which also has methods to allow for easy creation of the registry keys.Along with this, the PR also adds a new
Tag<T>
record, which stores aJavaRegistryKey<T>
and aKey
- the first being the registry of the tag and the second being the actual tag key.TagCache
now uses theTag<T>
record for tag lookup. The old way of looking tags up inint[][]
arrays has been replaced by a simpleMap<Tag<?>, int[]
.TagCache
now loads all registries listed inJavaRegistries
, as long as they satisfy the requirements for loading tags - that is, they must have a network serializer- and deserializer registered to be able to translate between network IDs and registry objects, which is required for the functionality ofTagCache
.Along with the changes to tag loading, this PR also adds a new
HolderSet
class, which makes loading and using Minecraft's holder sets easier within Geyser, and has a better integration with Geyser's tag cache.Basic gameplay testing, as well as confirming both vanilla- and non-vanilla tags load by letting Geyser make a printout of loaded tags, has been done.