Skip to content

Conversation

@Owen1212055
Copy link
Contributor

This resolves issues when unboxing seems to not occur on method invocations that occur on superclass methods.
This most notably improves readability of certain codecs / block state definitions.

public static final Codec<DisplayInfo> CODEC = RecordCodecBuilder.create(
        instance -> instance.group(
                ItemStack.STRICT_CODEC.fieldOf("icon").forGetter(DisplayInfo::getIcon),
                ComponentSerialization.CODEC.fieldOf("title").forGetter(DisplayInfo::getTitle),
                ComponentSerialization.CODEC.fieldOf("description").forGetter(DisplayInfo::getDescription),
                ResourceLocation.CODEC.optionalFieldOf("background").forGetter(DisplayInfo::getBackground),
                AdvancementType.CODEC.optionalFieldOf("frame", AdvancementType.TASK).forGetter(DisplayInfo::getType),
-                Codec.BOOL.optionalFieldOf("show_toast", Boolean.valueOf(true)).forGetter(DisplayInfo::shouldShowToast),
-                Codec.BOOL.optionalFieldOf("announce_to_chat", Boolean.valueOf(true)).forGetter(DisplayInfo::shouldAnnounceChat),
-                Codec.BOOL.optionalFieldOf("hidden", Boolean.valueOf(false)).forGetter(DisplayInfo::isHidden)
+                Codec.BOOL.optionalFieldOf("show_toast", true).forGetter(DisplayInfo::shouldShowToast),
+                Codec.BOOL.optionalFieldOf("announce_to_chat", true).forGetter(DisplayInfo::shouldAnnounceChat),
+                Codec.BOOL.optionalFieldOf("hidden", false).forGetter(DisplayInfo::isHidden)
            )
            .apply(instance, DisplayInfo::new)
    );
this.registerDefaultState(
            this.stateDefinition
                .any()
-                .setValue(DISTANCE, Integer.valueOf(7))
-                .setValue(WATERLOGGED, Boolean.valueOf(false))
-                .setValue(BOTTOM, Boolean.valueOf(false))
+                .setValue(DISTANCE, 7)
+                .setValue(WATERLOGGED, false)
+                .setValue(BOTTOM, false)
        );

@Owen1212055 Owen1212055 force-pushed the fix/superclass-boxing branch from 536691b to 419e6dc Compare December 16, 2024 04:43
@Owen1212055 Owen1212055 changed the title Properly walk the inheritance tree when checking for possibly ambiguous unboxing calls Properly walk the inheritance tree when checking for possibly ambiguous unboxed calls Dec 16, 2024
Copy link
Member

@jaskarth jaskarth 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, thanks for the fix!

@jaskarth jaskarth added Subsystem: Writing Anything concerning how expressions are written Priority: Medium Medium priority bugfix Fixes a bug labels Dec 16, 2024
@jaskarth jaskarth merged commit d63fc67 into Vineflower:develop/1.11.0 Dec 16, 2024
4 checks passed
jaskarth pushed a commit that referenced this pull request Feb 24, 2025
jaskarth pushed a commit that referenced this pull request Feb 25, 2025
jaskarth pushed a commit that referenced this pull request Feb 25, 2025
jaskarth pushed a commit that referenced this pull request Feb 25, 2025
@Owen1212055 Owen1212055 deleted the fix/superclass-boxing branch June 28, 2025 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug Priority: Medium Medium priority Subsystem: Writing Anything concerning how expressions are written

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants