Skip to content

Feature/26.3 registries - #14

Open
eclipseisoffline wants to merge 13 commits into
feature/26.3from
feature/26.3-registries
Open

eclipseisoffline wants to merge 13 commits into
feature/26.3from
feature/26.3-registries

Conversation

@eclipseisoffline

Copy link
Copy Markdown
Owner

Summary of changes:

  • GeyserHolderSets support heterogeneous NBT lists using text-serializer-nbt's implementation.
  • JavaRegistryProvider now provides both Java registry and tag data, allowing tags to be used in gametests.
    • Is implemented by JavaRegistryTagCache in Geyser. RegistryCache and TagCache still exist, but are not used directly anymore.
  • JavaRegistryLookup and JavaRegistryKey's get* methods now either return an optional or throw when an element is missing, enforcing safety. The exception notes the registry name and lookup details.
  • SimpleJavaRegistry was reworked significantly:
    • It now keeps multiple maps for ID <-> entry, key <-> entry, and entry <-> ID/key lookups, reducing lookup time for all lookups except for ID -> entry (these lookups were previously done by iterating all entries, resulting in a performance penalty).
    • It now has a frozen and mutable state, and a RegistryEntryData can be unbound (unknown) before freezing (see Javadocs).
    • A new interface hierarchy has been created:
      • At the top there is JavaRegistryLookup providing simple access to one or more registry entries.
      • JavaRegistry extends JavaRegistryLookup with methods to iterate over the entire registry.
      • MutableJavaRegistry extends JavaRegistry and has a mutable and frozen state, and is implemented by SimpleJavaRegistry.
  • Registries for Java blocks, items, and entity types are now kept in a new BuiltInJavaRegistries class, and use SimpleJavaRegistrys, which allows using the same ID/key/entry <-> ID/key/entry lookups as per-session registries, and allows a clean incorporation with per-session registries.
  • Registry readers have been moved out of RegistryCache and into a new JavaRegistryReaders class, and a distinction has been made between readers that depend on the entry's key and those that do not (see Javadocs).
  • Across the codebase, passing around GeyserSession just for registry access has been removed, preferring to pass the weakened JavaRegistryProvider instance instead.
  • Most Java registry classes have been relocated to the org.geysermc.geyser.registry.java, except for the session-cache classes.
  • GeyserHolderSet now has gametests.
  • Item#javaIdentifier() (returning a string representation of the Key) has been removed, preferring to use Keys when possible instead.

All registry classes have received up-to-date Javadocs giving a thorough explanation of their inner workings and usage.

@onebeastchris onebeastchris left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome! Don't have much to say tbh; structure wise i (without claude this time, heh) like this. Great to see more tests too 👀

EntityDamageCause cause = session.getRegistryCache().registry(JavaRegistries.DAMAGE_TYPE).byId(packet.getSourceTypeId());
if (cause == null) {
cause = EntityDamageCause.OVERRIDE;
Optional<EntityDamageCause> cause = JavaRegistries.DAMAGE_TYPE.get(session.javaRegistries(), packet.getSourceTypeId());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EntityDamageCause cause = JavaRegistries.DAMAGE_TYPE.get(session.javaRegistries(), packet.getSourceTypeId())
        .orElse(EntityDamageCause.OVERRIDE);

Don't see why we'd need the optional :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants