Skip to content
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

Network synced registries #866

Merged
merged 67 commits into from
Aug 9, 2024

Conversation

booky10
Copy link
Collaborator

@booky10 booky10 commented Jun 30, 2024

TODO

  • Implement to/from nbt encode/decoding for:
    • Biomes
    • Chat Types
    • Trim Patterns
    • Trim Materials
    • Wolf Variants
    • Painting Variants
    • Dimension Types
    • Damage Types (thanks to @libraryaddict)
    • Banner Patterns
    • Enchantments
    • Jukebox Songs (thanks to @libraryaddict)
  • Migrate all synchronized registries to generic VersionedRegistry
  • Update dimension type handling (especially world height) and fix legacy handling
  • Support non-vanilla entries on registry load (load from data if available, otherwise lookup in vanilla registry)
  • For 1.16 to 1.20.1: Use new registries while reading packet on game join
  • Fix biome mappings for older versions
  • Reduce memory usage by only caching each registry once per "server"
    • Make decoding/encoding everything optional, except for dimension types
  • Account changes in encoding/decoding across versions (@libraryaddict already did this for biomes)

Changes

  • Added new abstract registry system and migrated all network synchronized registries
  • Added nbt decoding/encoding logic for all network synchronized registries
    • Enchantments were a bit more complicated, as they now also use components for storing effects
  • Migrated dimension type handling from Dimension to new DimensionType
  • Registries are now read in config phase or on login and re-build from sent data
    • If the server decides to not send vanilla data (or data of custom datapacks), the vanilla registry is used as a fallback
    • → When using the same custom datapack on multiple backend servers behind a proxy, this will break with this solution

Breaking Changes

  • Some define methods in network synchronized registries
  • Dimension/world related methods (which aren't getters) no longer work in User

Fixes #908
Fixes #869
Fixes #861
Fixes #850
Fixes #849
Fixes #803

booky10 added 24 commits July 1, 2024 12:38
Biome registry is required for wolf variant registry to fully work
Reference gets resolved when calling the getter, this allows legacy version registries to be swapped before resolving the new dimension type
Theoretically required for full support of biome data serialization
@retrooper
Copy link
Owner

image
Received this exception, hopefully it helps.

@booky10
Copy link
Collaborator Author

booky10 commented Aug 4, 2024

which minecraft version?

@retrooper
Copy link
Owner

which minecraft version?

Paper 1.21

@libraryaddict
Copy link
Contributor

Reduce memory usage by only caching each registry once per "server"

What happens if a plugin decides to add a new registry entry that isn't shared by all players on a server? Would that be explicitly unsupported?

@booky10
Copy link
Collaborator Author

booky10 commented Aug 5, 2024

With caching enabled, yes

Each kind of registry has a VersionedRegistry. This VersionedRegistry now contains a SimpleRegistry as a cache. If the cache is not null, it will be used globally. This makes the usage of registries convenient for PacketEvents users as they no longer need to access them within each user instance. If the plugin is on proxy, we shall store all registries for each user. If the plugin is not on proxy, we shall only store the dimension type registry for each user and globally cache the rest.
@retrooper
Copy link
Owner

The very last commit is untested, noticed that I forgot the legacy registries.

@retrooper retrooper marked this pull request as ready for review August 6, 2024 04:53
Copy link
Owner

@retrooper retrooper left a comment

Choose a reason for hiding this comment

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

Looks good. Will be included in 2.5.0-SNAPSHOT for users to conveniently test until the release.

@retrooper retrooper merged commit fc93419 into retrooper:2.0 Aug 9, 2024
1 check passed
@retrooper
Copy link
Owner

Thanks for the PR @booky10 and @libraryaddict!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants