Running 1.21.9 #72

This commit is contained in:
Kr4ight
2026-04-07 21:53:48 +02:00
parent 64ab091807
commit c8860ab837
2 changed files with 39 additions and 39 deletions
@@ -46,50 +46,50 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public abstract class NametagsMixin { public abstract class NametagsMixin {
/** Guards against the recursive call we make with the replacement text. */ /** Guards against the recursive call we make with the replacement text. */
@Unique // @Unique
private static final ThreadLocal<Boolean> saturn$rendering = ThreadLocal.withInitial(() -> false); // private static final ThreadLocal<Boolean> saturn$rendering = ThreadLocal.withInitial(() -> false);
@Shadow // @Shadow
protected abstract <S extends EntityRenderState> void renderLabelIfPresent( // protected abstract <S extends EntityRenderState> void renderLabelIfPresent(
S state, Text text, // S state, Text text,
MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light); // MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light);
@Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true) // @Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
private <S extends EntityRenderState> void saturn$replaceNametag( // private <S extends EntityRenderState> void saturn$replaceNametag(
S state, Text text, // S state, Text text,
MatrixStack matrices, VertexConsumerProvider vertexConsumers, // MatrixStack matrices, VertexConsumerProvider vertexConsumers,
int light, CallbackInfo ci) { // int light, CallbackInfo ci) {
// Skip our own recursive call // // Skip our own recursive call
if (saturn$rendering.get()) // if (saturn$rendering.get())
return; // return;
if (!NametagsMod.shouldReplaceName()) // if (!NametagsMod.shouldReplaceName())
return; // return;
// Only living entities carry health data // // Only living entities carry health data
if (!(state instanceof LivingEntityRenderState living)) // if (!(state instanceof LivingEntityRenderState living))
return; // return;
if (!(living instanceof HealthRenderState hrs)) // if (!(living instanceof HealthRenderState hrs))
return; // return;
// Build the platform-neutral EntityState from the render-state snapshot // // Build the platform-neutral EntityState from the render-state snapshot
// (health/type were written by LivingEntityRendererMixin at extract time). // // (health/type were written by LivingEntityRendererMixin at extract time).
String customName = text != null ? text.getString() : null; // String customName = text != null ? text.getString() : null;
EntityFeatureImpl.RenderStateEntityState entityState = new EntityFeatureImpl.RenderStateEntityState( // EntityFeatureImpl.RenderStateEntityState entityState = new EntityFeatureImpl.RenderStateEntityState(
customName, hrs); // customName, hrs);
// Ask the feature for the replacement string // // Ask the feature for the replacement string
String replacement = NametagsMod.getNametagString(entityState); // String replacement = NametagsMod.getNametagString(entityState);
if (replacement == null) // if (replacement == null)
return; // feature decided not to replace this entity // return; // feature decided not to replace this entity
ci.cancel(); // ci.cancel();
saturn$rendering.set(true); // saturn$rendering.set(true);
try { // try {
renderLabelIfPresent(state, Text.literal(replacement), matrices, vertexConsumers, light); // renderLabelIfPresent(state, Text.literal(replacement), matrices, vertexConsumers, light);
} finally { // } finally {
saturn$rendering.set(false); // saturn$rendering.set(false);
} // }
} // }
} }
@@ -32,7 +32,7 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
* @reason Adds the Saturn Client icon to the player's name if they are online * @reason Adds the Saturn Client icon to the player's name if they are online
* with Saturn Client * with Saturn Client
*/ */
@Inject(method = "renderLabelIfPresent(Lnet/minecraft/client/render/entity/state/EntityRenderState;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"), cancellable = true) @Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
protected void renderLabelIfPresent(S state, MatrixStack matrices, OrderedRenderCommandQueue queue, protected void renderLabelIfPresent(S state, MatrixStack matrices, OrderedRenderCommandQueue queue,
CameraRenderState cameraRenderState, CallbackInfo ci) { CameraRenderState cameraRenderState, CallbackInfo ci) {
UUID uuid = isSaturn(state); UUID uuid = isSaturn(state);