Skip to content

Mixin 0.8.5

Latest
Compare
Choose a tag to compare
@Mumfrey Mumfrey released this 02 Dec 16:06
· 57 commits to master since this release

If you only care about the headlines then here's the lowdown on this release:

  • Adds module imports for the new module names for Gson and Guava which ship with Minecraft 1.18. This fixes an issue where mixin was failing to load because it imported the old module names.
  • Fixes an issue with the AP which was preventing generation of mappings for anonymous classes
  • The AP now detects IntelliJ IDEA and disables some warnings in the same way it previously did for Eclipse
  • All AP message levels (eg. warning, error) are configurable

Configuring AP Messaging

Improving the behaviour of the AP when running in the IDE also exposed some opportunities to give you, as a developer, more control over the AP's behaviour. Every single error, warning, or informational message generated by the AP is now configurable via the MessageType enum. This means that in addition to the site-specific @SuppressWarnings support defined in SuppressedBy it's now possible to globally control the message level for individual messages.

Message levels can be controlled by their type code, but don't worry, it's not necessary to look up the code in the MessageType enum every time, since controlling the message levels is fully supported by MixinGradle:

To find out the message type code for a particular message being generated by your build, simply specify the showMessageTypes option in the mixin closure:

mixin {
   config "mixins.mymod.json"
   add sourceSets.main, "mixins.mymod.refmap.json"
   
   // add this line
   showMessageTypes = true
}

Now when you run your build, each message will be prefixed with the message type in square brackets:

MixinRegionFileStorage.java:40: warning: [MIXIN_SOFT_TARGET_IS_PUBLIC] Mixin target
net/minecraft/world/level/chunk/storage/RegionFileStorage is public and should be specified in value
@Mixin(targets = "net/minecraft/world/level/chunk/storage/RegionFileStorage")
^

Now that you know the message type code (MIXIN_SOFT_TARGET_IS_PUBLIC) you can define a new level for the message in your mixin closure. Specify a closure for messages as follows:

mixin {
   config "mixins.mymod.json"
   add sourceSets.main, "mixins.mymod.refmap.json"
   
   showMessageTypes = true
   messages {
      MIXIN_SOFT_TARGET_IS_PUBLIC = 'error'
   }
}

Now when you run your build, the warning has been upgraded to error:

MixinRegionFileStorage.java:40: error: [MIXIN_SOFT_TARGET_IS_PUBLIC] Mixin target
net/minecraft/world/level/chunk/storage/RegionFileStorage is public and must be specified in value
@Mixin(targets = "net/minecraft/world/level/chunk/storage/RegionFileStorage")
^

Likewise, you can downgrade error to warning or warning to note. You can specify any of the following levels:

  • disabled - disables the message entirely
  • note - display the message at the note level, essentially an informational message
  • warning - set the message as a warning
  • error - set the message as an error

Downgrading messages can be useful to suppress errors and warnings globally. Upgrading messages can be useful if you want to have your build treat warnings as errors in order to make your build more robust.

Note that you can comment out the showMessageTypes = true line once you're done tuning message levels.