NametagsMixin hooked EntityRenderer.renderLabelIfPresent with a VertexConsumerProvider, which 1.21.9 moved to the render command queue, so custom nametags only worked before 1.21.9 (#30). LivingEntityRendererMixin already captures health and entity type at the end of LivingEntityRenderer.updateRenderState. It now also applies NametagsMod's replacement to state.displayName there, the label the renderer draws later. This works the same on every version, so NametagsMixin and its features.mixins.json entry are gone. As before, only entities that already show a label get a replacement. For players, the role icon is added after this (PlayerEntityRendererMixin), so it now comes before the replaced name and keeps its colour, instead of being folded into the replacement text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
5.6 KiB
Version guide
How Saturn Client supports several Minecraft versions, and how to change or add one.
Layout
Every supported Minecraft version (1.21.4 to 1.21.11) builds from one copy of the version-specific code with Stonecutter:
common/: all version-independent code (mods, UI, cosmetics, the server client). It has no Minecraft dependency and reaches the game only through the interfaces inorg.saturnclient.common.src/: the version-specific code (providers, refs, mixins and the three mixin configs), one copy for every version. Where Minecraft's API differs between versions, the code goes behind version comments (see below).versions/<mc>/: each version'sgradle.properties(Minecraft, Yarn, Fabric Loader and Fabric API versions), plus itsbuild/andrun/folders. Each version is the Gradle project:<mc>.
settings.gradle.kts lists the versions in stonecutterVersions. The root build.gradle.kts builds each version, and stonecutter.gradle.kts configures the root project (shared repositories, the common wiring and buildAll). Loom's version is loom_version in the root gradle.properties.
Version-specific code with Stonecutter
The code in src/ is always plain Java for the active version (1.21.11, set in stonecutter.gradle.kts). Code for other versions sits in comments that Stonecutter swaps before building each version:
//? if >=1.21.9 {
public void render(MatrixStack matrices, OrderedRenderCommandQueue queue, int light, PlayerEntityRenderState state, float limbAngle, float limbDistance) {
//?} else
//public void render(MatrixStack matrices, VertexConsumerProvider consumers, int light, PlayerEntityRenderState state, float limbAngle, float limbDistance) {
A condition without braces covers the next line only. For several lines, use braces and wrap the inactive block in /* … */:
//? if >=1.21.11 {
import net.minecraft.client.render.RenderLayers;
import net.minecraft.client.render.RenderSetup;
//?} else {
/*import net.minecraft.client.render.RenderPhase.Textures;
*///?}
Stonecutter rewrites inactive code into its own layout when switching versions (a single inactive line becomes //code), so write it that way to begin with, or run a switch and a reset before committing.
When a newer version leaves something out that an older one implements, keep the older version's code behind a condition and mark the newer branch with a TODO, rather than dropping it for every version. The panorama in SaturnScreenFabric.render is an example. Search for TODO to find what newer versions still lack (tracked in #30), and remove the condition once a version gap is fixed.
A whole class that only exists for some versions (such as MatrixStackMixin, which only makes sense before 1.21.6's GUI rewrite) can keep an empty class body on the other versions. Before splitting a class like that, look for a hook that works on every version: nametags used to hook label rendering, which 1.21.9 changed, and now replace the name while the render state is built (LivingEntityRendererMixin), with no version condition at all. An empty mixin changes nothing, and it keeps the mixin configs the same for every version, since JSON can't hold version comments.
Inactive code sits inside a /* … */ comment, so it can't contain /* … */ comments itself: use // comments in code that's only active for some versions. For the same reason, don't nest multi-line version blocks; use //?} else if <condition> { for more than two version ranges, as in PlayerEntityRendererMixin and SaturnRenderState.
./gradlew "Set active project to <mc>"(or the Stonecutter IntelliJ plugin) rewritessrc/so that version's code is the uncommented one, for editing it in the IDE../gradlew "Reset active project"switches back to 1.21.11. Run it before committing, sosrc/is always committed with 1.21.11 active.- Each version's processed copy is compiled from
versions/<mc>/build/generated/stonecutter/, which is also where to look when a non-active version fails to compile.
The emotes repository uses the same setup, and its BentCubeRenderer and PlayerModelMixin are small examples of version comments.
Checking a change on every version
Since every version shares src/, a change applies to all of them at once. Code that uses the Minecraft API may still only compile on some, so build them all:
./gradlew compileJava
The Check workflow runs the same compile on every pull request, so a version a change doesn't compile on fails before merging. Mixins whose target changed fail at startup rather than at compile time, so launch the versions a change touches with ./gradlew :<mc>:runClient.
For bigger changes, ./gradlew buildAll builds every version's jar into build/allJars/.
Adding a Minecraft version
- Create
versions/<new>/gradle.propertieswithminecraft_version,yarn_mappings,loader_versionandfabric_api_version(copy 1.21.11's and change the values; they're listed at https://fabricmc.net/develop). Loom's version is shared, in the rootgradle.properties. - Add
<new>tostonecutterVersionsinsettings.gradle.kts. - Build it with
./gradlew :<new>:compileJavaand put what Minecraft changed behind version comments. Check the mixin configs insrc/main/resources/*.mixins.jsonas well: a mixin whose target changed fails at startup, not at compile time, so launch it with./gradlew :<new>:runClient. - The release workflow builds everything through
buildAll, and "Publish to Modrinth" takes the game version from each jar's name, so neither needs changing.