- 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:
+1
-1
@@ -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.
|
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.
|
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.
|
||||||
|
|
||||||
|
|||||||
@@ -31,10 +31,7 @@ public class WorldFeatureImpl implements WorldFeature {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long getWorldAge() {
|
public long getWorldAge() {
|
||||||
//? if >=1.21.11 {
|
// World.getTime() was a shortcut for this, and 1.21.11 removed it.
|
||||||
// TODO: not implemented on 1.21.11 yet.
|
return hasWorld() ? mc.world.getLevelProperties().getTime() : 0L;
|
||||||
return 0L;
|
|
||||||
//?} else
|
|
||||||
//return hasWorld() ? mc.world.getTime() : 0L;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ public class SaturnScreenFabric extends Screen implements ScreenProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseDragged(Click click, double offsetX, double offsetY) {
|
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+.
|
// 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(), 0.0, 0.0)) {
|
if (screen.mouseDragged(click.x(), click.y(), click.button(), offsetX, offsetY)) {
|
||||||
return true;
|
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
|
/*@Override
|
||||||
public void resize(MinecraftClient client, int width, int height) {
|
public void resize(MinecraftClient client, int width, int height) {
|
||||||
screen.resize(width, height);
|
screen.resize(width, height);
|
||||||
|
|||||||
@@ -40,16 +40,15 @@ public abstract class PlayerEntityRendererMixin
|
|||||||
this.addFeature(new CloakFeatureRenderer(this, ctx.getEquipmentModelLoader()));
|
this.addFeature(new CloakFeatureRenderer(this, ctx.getEquipmentModelLoader()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stores the SaturnPlayer in the render state and adds the role icon to the name. Render state
|
// Adds the role icon to the player's name, and stores the SaturnPlayer in the render state for the
|
||||||
// data only exists from 1.21.8.
|
// cloak and hat (Fabric API only has render state data from 1.21.8).
|
||||||
// TODO: 1.21.6 and 1.21.7 don't show the role icon in player names.
|
|
||||||
//? if >=1.21.9 {
|
//? if >=1.21.9 {
|
||||||
@Inject(method = "updateRenderState", at = @At("TAIL"))
|
@Inject(method = "updateRenderState", at = @At("TAIL"))
|
||||||
public <A extends PlayerLikeEntity & ClientPlayerLikeEntity> void updateRenderState(
|
public <A extends PlayerLikeEntity & ClientPlayerLikeEntity> void updateRenderState(
|
||||||
A entity, PlayerEntityRenderState state, float f, CallbackInfo ci) {
|
A entity, PlayerEntityRenderState state, float f, CallbackInfo ci) {
|
||||||
saturn$applyPlayer(entity, state);
|
saturn$applyPlayer(entity, state);
|
||||||
}
|
}
|
||||||
//?} else if >=1.21.8 {
|
//?} else {
|
||||||
/*@Inject(method = "updateRenderState", at = @At("TAIL"))
|
/*@Inject(method = "updateRenderState", at = @At("TAIL"))
|
||||||
public void updateRenderState(
|
public void updateRenderState(
|
||||||
AbstractClientPlayerEntity entity, PlayerEntityRenderState state, float f, CallbackInfo ci) {
|
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) {
|
private void saturn$applyPlayer(Entity entity, PlayerEntityRenderState state) {
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return;
|
return;
|
||||||
@@ -65,6 +63,7 @@ public abstract class PlayerEntityRendererMixin
|
|||||||
|
|
||||||
SaturnPlayer player = SaturnPlayer.get(entity.getUuid());
|
SaturnPlayer player = SaturnPlayer.get(entity.getUuid());
|
||||||
|
|
||||||
|
//? if >=1.21.8
|
||||||
state.setData(SaturnRenderState.saturnDataKey, player);
|
state.setData(SaturnRenderState.saturnDataKey, player);
|
||||||
|
|
||||||
if (player != null && state.displayName != null) {
|
if (player != null && state.displayName != null) {
|
||||||
@@ -77,5 +76,4 @@ public abstract class PlayerEntityRendererMixin
|
|||||||
.append(state.displayName.copy());
|
.append(state.displayName.copy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//?}
|
|
||||||
}
|
}
|
||||||
@@ -126,8 +126,9 @@ public abstract class SplashOverlayMixin {
|
|||||||
private void renderProgressBar(RenderScope scope, DrawContext context, int screenWidth, int screenHeight,
|
private void renderProgressBar(RenderScope scope, DrawContext context, int screenWidth, int screenHeight,
|
||||||
int alpha) {
|
int alpha) {
|
||||||
int progressY = ((screenHeight - 5) / 2) + 25;
|
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));
|
//context.drawBorder((screenWidth - 120) / 2, progressY, 120, 5, Theme.withAlpha(alpha, 0xFFFFFFFF));
|
||||||
|
|
||||||
int progressWidth = Math.min((int) (progress * 120), 120);
|
int progressWidth = Math.min((int) (progress * 120), 120);
|
||||||
|
|||||||
Reference in New Issue
Block a user