Temporarily fixed mixins
This commit is contained in:
-59
@@ -1,59 +0,0 @@
|
||||
package org.saturnclient.impl.modules.mixins;
|
||||
|
||||
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||
|
||||
import org.saturnclient.common.module.EntityModule;
|
||||
import org.saturnclient.impl.modules.HealthRenderState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
/**
|
||||
* Implements {@link HealthRenderState} on
|
||||
* {@link LivingEntityRenderState}, injecting health and entity-type
|
||||
* storage into every living entity's render-state snapshot.
|
||||
*
|
||||
* Previously imported {@code NametagsInterface.EntityType}; the enum
|
||||
* now lives in {@link EntityModule.EntityType} which is the single
|
||||
* canonical definition shared by the mixin layer and the feature layer.
|
||||
*
|
||||
* The stored values are written by
|
||||
* {@link LivingEntityRendererMixin#saturn$captureHealth} each time a
|
||||
* render state is extracted from a live entity, and read by
|
||||
* {@link NametagsMixin} at render time.
|
||||
*/
|
||||
@Mixin(LivingEntityRenderState.class)
|
||||
public class LivingEntityRenderStateMixin implements HealthRenderState {
|
||||
|
||||
@Unique
|
||||
private float saturn$health = 0f;
|
||||
@Unique
|
||||
private float saturn$maxHealth = 1f;
|
||||
@Unique
|
||||
private EntityModule.EntityType saturn$entityType = EntityModule.EntityType.OTHER;
|
||||
|
||||
@Override
|
||||
public float saturn$getHealth() {
|
||||
return saturn$health;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float saturn$getMaxHealth() {
|
||||
return saturn$maxHealth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saturn$setHealth(float health, float maxHealth) {
|
||||
this.saturn$health = health;
|
||||
this.saturn$maxHealth = maxHealth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityModule.EntityType saturn$getEntityType() {
|
||||
return saturn$entityType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saturn$setEntityType(EntityModule.EntityType type) {
|
||||
saturn$entityType = type;
|
||||
}
|
||||
}
|
||||
+27
-23
@@ -1,7 +1,7 @@
|
||||
package org.saturnclient.impl.modules.mixins;
|
||||
|
||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||
// import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.mob.HostileEntity;
|
||||
import net.minecraft.entity.passive.PassiveEntity;
|
||||
@@ -26,26 +26,30 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
* The injection target and strategy are unchanged from the original.
|
||||
*/
|
||||
@Mixin(LivingEntityRenderer.class)
|
||||
public abstract class LivingEntityRendererMixin<T extends LivingEntity, S extends LivingEntityRenderState> {
|
||||
|
||||
@Inject(method = "updateRenderState", at = @At("TAIL"))
|
||||
private void saturn$captureHealth(T entity, S state, float tickDelta, CallbackInfo ci) {
|
||||
if (!(state instanceof HealthRenderState hrs))
|
||||
return;
|
||||
|
||||
hrs.saturn$setHealth(entity.getHealth(), entity.getMaxHealth());
|
||||
|
||||
// Classify entity type for the nametag feature's filtering logic
|
||||
EntityModule.EntityType type;
|
||||
if (entity instanceof PlayerEntity)
|
||||
type = EntityModule.EntityType.PLAYER;
|
||||
else if (entity instanceof HostileEntity)
|
||||
type = EntityModule.EntityType.HOSTILE;
|
||||
else if (entity instanceof PassiveEntity)
|
||||
type = EntityModule.EntityType.PASSIVE;
|
||||
else
|
||||
type = EntityModule.EntityType.OTHER;
|
||||
|
||||
hrs.saturn$setEntityType(type);
|
||||
}
|
||||
public abstract class LivingEntityRendererMixin {
|
||||
}
|
||||
// public abstract class LivingEntityRendererMixin<T extends LivingEntity, S
|
||||
// extends LivingEntityRenderState> {
|
||||
|
||||
// @Inject(method = "updateRenderState", at = @At("TAIL"))
|
||||
// private void saturn$captureHealth(T entity, S state, float tickDelta,
|
||||
// CallbackInfo ci) {
|
||||
// if (!(state instanceof HealthRenderState hrs))
|
||||
// return;
|
||||
|
||||
// hrs.saturn$setHealth(entity.getHealth(), entity.getMaxHealth());
|
||||
|
||||
// // Classify entity type for the nametag feature's filtering logic
|
||||
// EntityModule.EntityType type;
|
||||
// if (entity instanceof PlayerEntity)
|
||||
// type = EntityModule.EntityType.PLAYER;
|
||||
// else if (entity instanceof HostileEntity)
|
||||
// type = EntityModule.EntityType.HOSTILE;
|
||||
// else if (entity instanceof PassiveEntity)
|
||||
// type = EntityModule.EntityType.PASSIVE;
|
||||
// else
|
||||
// type = EntityModule.EntityType.OTHER;
|
||||
|
||||
// hrs.saturn$setEntityType(type);
|
||||
// }
|
||||
// }
|
||||
|
||||
+38
-38
@@ -2,8 +2,8 @@ package org.saturnclient.impl.modules.mixins;
|
||||
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRenderer;
|
||||
import net.minecraft.client.render.entity.state.EntityRenderState;
|
||||
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||
// import net.minecraft.client.render.entity.state.EntityRenderState;
|
||||
// import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
@@ -48,47 +48,47 @@ public abstract class NametagsMixin {
|
||||
@Unique
|
||||
private static final ThreadLocal<Boolean> saturn$rendering = ThreadLocal.withInitial(() -> false);
|
||||
|
||||
@Shadow
|
||||
protected abstract <S extends EntityRenderState> void renderLabelIfPresent(
|
||||
S state, Text text,
|
||||
MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light);
|
||||
// @Shadow
|
||||
// protected abstract <S extends EntityRenderState> void renderLabelIfPresent(
|
||||
// S state, Text text,
|
||||
// MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light);
|
||||
|
||||
@Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
|
||||
private <S extends EntityRenderState> void saturn$replaceNametag(
|
||||
S state, Text text,
|
||||
MatrixStack matrices, VertexConsumerProvider vertexConsumers,
|
||||
int light, CallbackInfo ci) {
|
||||
// @Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
|
||||
// private <S extends EntityRenderState> void saturn$replaceNametag(
|
||||
// S state, Text text,
|
||||
// MatrixStack matrices, VertexConsumerProvider vertexConsumers,
|
||||
// int light, CallbackInfo ci) {
|
||||
|
||||
// Skip our own recursive call
|
||||
if (saturn$rendering.get())
|
||||
return;
|
||||
// // Skip our own recursive call
|
||||
// if (saturn$rendering.get())
|
||||
// return;
|
||||
|
||||
if (!NametagsFeature.shouldReplaceName())
|
||||
return;
|
||||
// if (!NametagsFeature.shouldReplaceName())
|
||||
// return;
|
||||
|
||||
// Only living entities carry health data
|
||||
if (!(state instanceof LivingEntityRenderState living))
|
||||
return;
|
||||
if (!(living instanceof HealthRenderState hrs))
|
||||
return;
|
||||
// // Only living entities carry health data
|
||||
// if (!(state instanceof LivingEntityRenderState living))
|
||||
// return;
|
||||
// if (!(living instanceof HealthRenderState hrs))
|
||||
// return;
|
||||
|
||||
// Build the platform-neutral EntityState from the render-state snapshot
|
||||
// (health/type were written by LivingEntityRendererMixin at extract time).
|
||||
String customName = text != null ? text.getString() : null;
|
||||
EntityModuleFabric.RenderStateEntityState entityState = new EntityModuleFabric.RenderStateEntityState(
|
||||
customName, hrs);
|
||||
// // Build the platform-neutral EntityState from the render-state snapshot
|
||||
// // (health/type were written by LivingEntityRendererMixin at extract time).
|
||||
// String customName = text != null ? text.getString() : null;
|
||||
// EntityModuleFabric.RenderStateEntityState entityState = new EntityModuleFabric.RenderStateEntityState(
|
||||
// customName, hrs);
|
||||
|
||||
// Ask the feature for the replacement string
|
||||
String replacement = NametagsFeature.getNametagString(entityState);
|
||||
if (replacement == null)
|
||||
return; // feature decided not to replace this entity
|
||||
// // Ask the feature for the replacement string
|
||||
// String replacement = NametagsFeature.getNametagString(entityState);
|
||||
// if (replacement == null)
|
||||
// return; // feature decided not to replace this entity
|
||||
|
||||
ci.cancel();
|
||||
saturn$rendering.set(true);
|
||||
try {
|
||||
renderLabelIfPresent(state, Text.literal(replacement), matrices, vertexConsumers, light);
|
||||
} finally {
|
||||
saturn$rendering.set(false);
|
||||
}
|
||||
}
|
||||
// ci.cancel();
|
||||
// saturn$rendering.set(true);
|
||||
// try {
|
||||
// renderLabelIfPresent(state, Text.literal(replacement), matrices, vertexConsumers, light);
|
||||
// } finally {
|
||||
// saturn$rendering.set(false);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -25,6 +25,6 @@ public class TpsMixin {
|
||||
|
||||
@Inject(method = "onWorldTimeUpdate", at = @At("HEAD"))
|
||||
private void onWorldTimeUpdate(WorldTimeUpdateS2CPacket packet, CallbackInfo ci) {
|
||||
TpsFeature.onTimePacket(packet.time());
|
||||
TpsFeature.onTimePacket(packet.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class SaturnProviderImpl implements SaturnProvider {
|
||||
AnimationStack animationStack = PlayerAnimationAccess.getPlayerAnimLayer(player);
|
||||
|
||||
if (emoteIdOrNull != null && !emoteIdOrNull.isEmpty()) {
|
||||
if (animationStack.isActive() && animationStack.getPriority() == 1000) {
|
||||
if (animationStack.isActive()) {
|
||||
animationStack.removeLayer(1000);
|
||||
}
|
||||
animationStack.addAnimLayer(1000,
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
"GameRendererMixin",
|
||||
"LightmapTextureManagerMixin",
|
||||
"LivingEntityRendererMixin",
|
||||
"LivingEntityRenderStateMixin",
|
||||
"NametagsMixin",
|
||||
"RenderMixin",
|
||||
"TpsMixin"
|
||||
|
||||
Reference in New Issue
Block a user