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

Add Codecs to serializable classes #718

Draft
wants to merge 77 commits into
base: main
Choose a base branch
from

Conversation

Master-Bw3
Copy link
Contributor

@Master-Bw3 Master-Bw3 commented Aug 17, 2024

adds codecs to serializable classes like Iotas, Continuation Frames, HexPattern, etc. Although codecs are not necessary for 1.20.1, this should help us migrate to future versions more easily.

Changes

All serialize() and deserialize() methods in classes with codecs have been marked as deprecated as they should be removed in future versions. The implementations of those methods have also been altered to use codecs.

2 new extension functions have been added to HexUtils.kt to aid with using codecs:
<T : Any> T.serializeWithCodec(codec: Codec<T>): Tag?
<T : Any> Tag.deserializeWithCodec(codec: Codec<T>): T?

All codecs were designed to be backwards compatible, so iotas from previous versions should load correctly.

Entity Iotas have been changed to accommodate codecs:

  • Entity iotas no longer hold a direct reference to an entity
  • List<Iota>.getEntity and related functions now require a world argument
  • When an entity iota is deserialized, if the entity can't be found in the world, it will instead deserialize to a Null iota. If the entity is a player, then the iota will be marked as a truename.

@walksanatora
Copy link
Contributor

q: why do the singleton iotas (null/garbage) go through codec deserialization when they are Codec.unit's cant you just safely assume that the iota is just the unit

@gamma-delta
Copy link
Collaborator

Can you rebase this into fewer commits please? Like one commit for the codec implementation, and one commit where you switch everything over to using the new codecs.

Auroali and others added 23 commits August 29, 2024 15:11
…by defaulting all readable items to read NullIota() if no iota contained. Fixed behaviour of OpRead and similar if no IotaHolder found.
…from things with nothing in them), remove references to Hands in places where they aren't needed.
…adding a writeable() method to IotaHolderItem.
…ackets unnecessarily, getting names of patterns for every cast and only using if a mishap occurs)
navarchus and others added 28 commits August 29, 2024 15:19
….overcast.player" still needs to be defined in ru_ru and zh_cn.
Co-authored-by: [object Object] <[email protected]>
Co-authored-by: [object Object] <[email protected]>
@gamma-delta
Copy link
Collaborator

I think we should probably delay this until after the 1.20.1 release. @object-Object I think you had similar thoughts?

@object-Object
Copy link
Member

object-Object commented Sep 6, 2024

yeah, I have the project entry planned for "some future 0.11.x release" currently. I think we discussed it on Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

Successfully merging this pull request may close these issues.