Fill five version gaps from #30
Check / compile (pull_request) Successful in 2m31s

- 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 <[email protected]>
This commit is contained in:
2026-09-27 06:59:18 +02:00
co-authored by claude
parent 771ed93992
commit 48118f6a84
5 changed files with 19 additions and 18 deletions
@@ -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;
}
}
@@ -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);
@@ -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 <A extends PlayerLikeEntity & ClientPlayerLikeEntity> 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());
}
}
//?}
}
@@ -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);