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

Fix custom ingredient serialization with allowEmpty #3389

Merged
merged 3 commits into from
Nov 2, 2023

Conversation

Technici4n
Copy link
Member

@jaredlll08 told me that custom ingredients did not serialize correctly with the allowEmpty codec. This is because the serialization code in our modified codec actually tried to serialize using the vanilla codec first, which fails when the ingredient is empty if allowEmpty is false but succeeds if allowEmpty is true, thus writing an empty array []. I rewrote this using an either codec, cleaning up the code a bit and fixing the bug.

@Technici4n Technici4n requested a review from a team October 24, 2023 10:37
@modmuss50 modmuss50 added the bug Something isn't working label Oct 24, 2023
Copy link
Member

@modmuss50 modmuss50 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, just fix the build.

}

// Decode/encode the first codec, if that fails return the result of the second.
record First<T>(Codec<T> first, Codec<T> second) implements Codec<T> {
Copy link
Member

Choose a reason for hiding this comment

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

Nice to get rid of this, thanks ;)

@modmuss50 modmuss50 added the merge me please Pull requests that are ready to merge label Oct 29, 2023
@modmuss50 modmuss50 merged commit 6ed720c into FabricMC:1.20.3 Nov 2, 2023
5 checks passed
modmuss50 pushed a commit that referenced this pull request Nov 2, 2023
* Fix custom ingredient serialization with allowEmpty

* Remove custom First codec

* Fix checkstyle

(cherry picked from commit 6ed720c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working merge me please Pull requests that are ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants