Skip to content

Mixin Cleanup & Fixes - #3905

Draft
AViewFromTheTop wants to merge 1 commit into
CaffeineMC:devfrom
AViewFromTheTop:dev
Draft

AViewFromTheTop wants to merge 1 commit into
CaffeineMC:devfrom
AViewFromTheTop:dev

Conversation

@AViewFromTheTop

@AViewFromTheTop AViewFromTheTop commented Sep 10, 2026 •

Copy link
Copy Markdown
  • Cleaned up duplicate/redundant invocations of Minecraft.getInstance()
  • Re-implemented a few mixin Overwrites without using Overwrite
  • Implemented missing Dry Foliage color optimization
  • Replaced multiple instances of mixin methods using cir.getReturnValue() with new methods simply using ModifyReturnValue
  • Misc. cleanup

I personally would argue for altering the codestyle of the mod altogether in some places if that's something the Sodium team is interested in, there are many places it can improve readability (especially mixin parameters/AT annotations.)

I have also noticed that many classes that only provide static methods aren't marked as final and don't have private constructors, and there is major inconsistency between whether methods, new fields, new methods, etc., in mixins are prefixed with "sodium$" or not, as wall as frequent usage of "var" for local variables instead of providing their proper types. For the sake of consistency and readability for new contributors, I would advocate for a consensus on these too!

As I am not a member of the Sodium team I opted to not alter the codestyle much, and only made changes where it seemed to benefit consistency given what was already there.

On a side-note, the name of this pull request is likely sub-optimal. I'm not sure what it should be changed to, but this description should explain it well enough.

- Cleaned up duplicate/redundant invocations of Minecraft.getInstance()
- Re-implemented a few mixin Overwrites without using Overwrite
- Implemented missing Dry Foliage color optimization
- Misc. cleanup

@douira douira left a comment

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.

I agree with most of the changes but I'm not quite sure about some of the changes from var to specific types. We have a lot of usage of var throughout the codebase and this is largely intentional as in many places the type is obvious or verbose. Can you explain why in these particular places you found it useful to expand to the full type?

if (this.xScale != 1.0F || this.yScale != 1.0F || this.zScale != 1.0F) {
matrixStack.scale(this.xScale, this.yScale, this.zScale);
}
@WrapWithCondition(

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.

can you explain what what this set of changes is doing and why?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is re-implementing the Overwrite, but using MixinExtras functionality in its place. I don’t like the conflict-heavy nature of Overwrite, but I also honestly didn’t expect this change in particular to be well-accepted.

}

var sb = new StringBuilder();
StringBuilder builder = new StringBuilder();

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.

why is this necessary or better?


private static void printCompatibilityReport(Collection<ScannedResourcePack> scanResults) {
var builder = new StringBuilder();
StringBuilder builder = new StringBuilder();

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.

is this better or necessary?

@douira

douira commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

We prefix mixin methods with sodium$ for a good reason: if we don't, then sometimes they can collide with the methods from other mods, breaking the game when both are used at once. I'm not sure when exactly we need to do this, but it would definitely be good if we had clearer rules on this and made it more consistent.
As for the usage of var I already commented on it in my review comment:

We have a lot of usage of var throughout the codebase and this is largely intentional as in many places the type is obvious or verbose.

@AViewFromTheTop

Copy link
Copy Markdown
Author

I agree with most of the changes but I'm not quite sure about some of the changes from var to specific types. We have a lot of usage of var throughout the codebase and this is largely intentional as in many places the type is obvious or verbose. Can you explain why in these particular places you found it useful to expand to the full type?

Simply for readability ^^
I didn’t like having to poke around a bit to see what certain things are, I felt this was a bit more friendly and easy to pick up on. It’s fine if you want it reverted though, I personally just avoid using var in my own mods unless the type is something that relies on an optional external dependency.

@douira

douira commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Well changing all the var usage would require much more than just these changes so it seemed arbitrary to me what you changed just these instances and thus assumed there was some more concrete justification. I don't care whether you revert it, since we don't apply var everywhere.

@codahq

This comment has been minimized.

@douira
douira marked this pull request as draft October 12, 2026 18:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants