Skip to content

Clean up sync API & fix issues relating to generic type erasure#4489

Merged
gustovafing merged 58 commits into1.20.1-v8.0.0from
gus/syncsystem-fixes
Jan 31, 2026
Merged

Clean up sync API & fix issues relating to generic type erasure#4489
gustovafing merged 58 commits into1.20.1-v8.0.0from
gus/syncsystem-fixes

Conversation

@gustovafing
Copy link
Copy Markdown
Member

  • Index value transformers by Type instead of Class<?>, so that a single class can have multiple value transformers based on generic args

  • Remove @FieldDataModifier and @CustomDataField, as the custom data functionality provided by them can be replicated using value transformers.

  • Refactor value transformers API, and add more jdoc to most public methods.

  • Add multiple new general transformer types:

    • ResourceLocationReferenceTransformer for values which are serialised based on a resource location (e.g. materials and recipe types)
    • CodecTransformer, which just takes an existing Codec implementation for use as the transformer.

@gustovafing gustovafing requested a review from a team as a code owner January 23, 2026 10:22
@github-actions github-actions bot added 1.20.1 Tests: Failed Game Tests have failed on this PR labels Jan 23, 2026
@github-actions github-actions bot added Tests: Passed Game Tests have passed on this PR and removed Tests: Failed Game Tests have failed on this PR labels Jan 23, 2026
@github-actions github-actions bot added Tests: Failed Game Tests have failed on this PR and removed Tests: Passed Game Tests have passed on this PR labels Jan 23, 2026
@github-actions github-actions bot added Tests: Failed Game Tests have failed on this PR and removed Tests: Passed Game Tests have passed on this PR labels Jan 28, 2026
@github-actions github-actions bot added Tests: Passed Game Tests have passed on this PR and removed Tests: Failed Game Tests have failed on this PR labels Jan 29, 2026

import javax.annotation.Nullable;

public class NBTSerializableTransformer implements ValueTransformer<INBTSerializable<Tag>> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this have a generic for the type of tag INBTSerializable takes in?
Most INBTSerializable implementations don't use a raw Tag as the generic type, usually it's CompoundTag, ListTag, etc., no?

}

for (Field field : clazz.getDeclaredFields()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove blank line

@Getter
private final Type rawType;
@Getter
private final @Nullable Class<?> classValue;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does this represent. It's not clear from the var name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The Class<?> of the type, if present.

private final TypeDeclaration[] genericTypeArgs;
private final @Nullable TypeDeclaration arrayComponentType;

public TypeDeclaration(Type type) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can make this class a record, then extract this constructor logic out into a static factory method.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's fine like this IMO

@github-actions github-actions bot added Tests: Failed Game Tests have failed on this PR and removed Tests: Passed Game Tests have passed on this PR labels Jan 31, 2026
@github-actions github-actions bot added Tests: Passed Game Tests have passed on this PR and removed Tests: Failed Game Tests have failed on this PR labels Jan 31, 2026
@gustovafing gustovafing merged commit 5ecfe6d into 1.20.1-v8.0.0 Jan 31, 2026
4 checks passed
@gustovafing gustovafing deleted the gus/syncsystem-fixes branch January 31, 2026 02:21
screret pushed a commit to screret/GregTech-Modern that referenced this pull request Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.20.1 Tests: Passed Game Tests have passed on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants