From 48118f6a84c0a44f8990130a5e49645f1c27fa7a Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sun, 27 Sep 2026 06:59:18 +0200 Subject: [PATCH] Fill five version gaps from #30 - World age on 1.21.11: World.getTime() was a shortcut for getLevelProperties().getTime(), which every version has, so getWorldAge uses that everywhere (the TPS feature and day counter got 0 on 1.21.11). - Screen resize on 1.21.11: override resize(int, int), the new signature. - Splash loading-bar border on 1.21.9+: drawBorder was renamed drawStrokedRectangle. - Drag deltas on 1.21.9+: mouseDragged(Click, offsetX, offsetY) gets the deltas as offsetX/offsetY; Saturn's screens got 0.0 before. - Role icon in player names on 1.21.4-1.21.7: only storing the player in the render state needs Fabric API's render state data (1.21.8+). The updateRenderState hook now runs on every version and only the setData call is limited to 1.21.8+. Co-Authored-By: Claude Opus 5.5 --- VERSION_GUIDE.md | 2 +- .../impl/features/world/WorldFeatureImpl.java | 7 ++----- .../saturnclient/impl/ui/SaturnScreenFabric.java | 13 +++++++++---- .../mixin/PlayerEntityRendererMixin.java | 10 ++++------ .../saturnclient/mixin/SplashOverlayMixin.java | 5 +++-- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/VERSION_GUIDE.md b/VERSION_GUIDE.md index 6f45e2e..795f1d9 100644 --- a/VERSION_GUIDE.md +++ b/VERSION_GUIDE.md @@ -36,7 +36,7 @@ import net.minecraft.client.render.RenderSetup; 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. `WorldFeatureImpl.getWorldAge` and `SaturnScreenFabric.resize` are examples. Search for `TODO` to find what newer versions still lack. +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. `NametagsMixin` and the panorama in `SaturnScreenFabric.render` are examples. 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 `NametagsMixin`, which hooks a method that 1.21.9 changed) can keep an empty class body on the other versions. An empty mixin changes nothing, and it keeps the mixin configs the same for every version, since JSON can't hold version comments. diff --git a/src/main/java/org/saturnclient/impl/features/world/WorldFeatureImpl.java b/src/main/java/org/saturnclient/impl/features/world/WorldFeatureImpl.java index 97facd1..691917d 100644 --- a/src/main/java/org/saturnclient/impl/features/world/WorldFeatureImpl.java +++ b/src/main/java/org/saturnclient/impl/features/world/WorldFeatureImpl.java @@ -31,10 +31,7 @@ public class WorldFeatureImpl implements WorldFeature { */ @Override public long getWorldAge() { - //? if >=1.21.11 { - // TODO: not implemented on 1.21.11 yet. - return 0L; - //?} else - //return hasWorld() ? mc.world.getTime() : 0L; + // World.getTime() was a shortcut for this, and 1.21.11 removed it. + return hasWorld() ? mc.world.getLevelProperties().getTime() : 0L; } } diff --git a/src/main/java/org/saturnclient/impl/ui/SaturnScreenFabric.java b/src/main/java/org/saturnclient/impl/ui/SaturnScreenFabric.java index 672f1e4..62a93a8 100644 --- a/src/main/java/org/saturnclient/impl/ui/SaturnScreenFabric.java +++ b/src/main/java/org/saturnclient/impl/ui/SaturnScreenFabric.java @@ -115,8 +115,8 @@ public class SaturnScreenFabric extends Screen implements ScreenProvider { @Override public boolean mouseDragged(Click click, double offsetX, double offsetY) { - // TODO: 1.21.8 passes the drag deltas; check whether offsetX/offsetY are the same on 1.21.9+. - if (screen.mouseDragged(click.x(), click.y(), click.button(), 0.0, 0.0)) { + // offsetX and offsetY are the drag deltas, as mouseDragged's deltaX and deltaY were before 1.21.9. + if (screen.mouseDragged(click.x(), click.y(), click.button(), offsetX, offsetY)) { return true; } @@ -184,8 +184,13 @@ public class SaturnScreenFabric extends Screen implements ScreenProvider { } *///?} - // TODO: resize isn't hooked on 1.21.11 yet. - //? if <1.21.11 { + //? if >=1.21.11 { + @Override + public void resize(int width, int height) { + screen.resize(width, height); + super.resize(width, height); + } + //?} else { /*@Override public void resize(MinecraftClient client, int width, int height) { screen.resize(width, height); diff --git a/src/main/java/org/saturnclient/saturnclient/mixin/PlayerEntityRendererMixin.java b/src/main/java/org/saturnclient/saturnclient/mixin/PlayerEntityRendererMixin.java index e02da40..de848a3 100644 --- a/src/main/java/org/saturnclient/saturnclient/mixin/PlayerEntityRendererMixin.java +++ b/src/main/java/org/saturnclient/saturnclient/mixin/PlayerEntityRendererMixin.java @@ -40,16 +40,15 @@ public abstract class PlayerEntityRendererMixin this.addFeature(new CloakFeatureRenderer(this, ctx.getEquipmentModelLoader())); } - // Stores the SaturnPlayer in the render state and adds the role icon to the name. Render state - // data only exists from 1.21.8. - // TODO: 1.21.6 and 1.21.7 don't show the role icon in player names. + // Adds the role icon to the player's name, and stores the SaturnPlayer in the render state for the + // cloak and hat (Fabric API only has render state data from 1.21.8). //? if >=1.21.9 { @Inject(method = "updateRenderState", at = @At("TAIL")) public void updateRenderState( A entity, PlayerEntityRenderState state, float f, CallbackInfo ci) { saturn$applyPlayer(entity, state); } - //?} else if >=1.21.8 { + //?} else { /*@Inject(method = "updateRenderState", at = @At("TAIL")) public void updateRenderState( AbstractClientPlayerEntity entity, PlayerEntityRenderState state, float f, CallbackInfo ci) { @@ -57,7 +56,6 @@ public abstract class PlayerEntityRendererMixin } *///?} - //? if >=1.21.8 { private void saturn$applyPlayer(Entity entity, PlayerEntityRenderState state) { if (entity == null) { return; @@ -65,6 +63,7 @@ public abstract class PlayerEntityRendererMixin SaturnPlayer player = SaturnPlayer.get(entity.getUuid()); + //? if >=1.21.8 state.setData(SaturnRenderState.saturnDataKey, player); if (player != null && state.displayName != null) { @@ -77,5 +76,4 @@ public abstract class PlayerEntityRendererMixin .append(state.displayName.copy()); } } - //?} } \ No newline at end of file diff --git a/src/main/java/org/saturnclient/saturnclient/mixin/SplashOverlayMixin.java b/src/main/java/org/saturnclient/saturnclient/mixin/SplashOverlayMixin.java index 545063d..9eea165 100644 --- a/src/main/java/org/saturnclient/saturnclient/mixin/SplashOverlayMixin.java +++ b/src/main/java/org/saturnclient/saturnclient/mixin/SplashOverlayMixin.java @@ -126,8 +126,9 @@ public abstract class SplashOverlayMixin { private void renderProgressBar(RenderScope scope, DrawContext context, int screenWidth, int screenHeight, int alpha) { int progressY = ((screenHeight - 5) / 2) + 25; - // TODO: the loading bar's border isn't drawn on 1.21.9+ yet. - //? if <1.21.9 + //? if >=1.21.9 { + context.drawStrokedRectangle((screenWidth - 120) / 2, progressY, 120, 5, Theme.withAlpha(alpha, 0xFFFFFFFF)); + //?} else //context.drawBorder((screenWidth - 120) / 2, progressY, 120, 5, Theme.withAlpha(alpha, 0xFFFFFFFF)); int progressWidth = Math.min((int) (progress * 120), 120); -- 2.54.0