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;
|
package org.saturnclient.impl.modules.mixins;
|
||||||
|
|
||||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
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.LivingEntity;
|
||||||
import net.minecraft.entity.mob.HostileEntity;
|
import net.minecraft.entity.mob.HostileEntity;
|
||||||
import net.minecraft.entity.passive.PassiveEntity;
|
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.
|
* The injection target and strategy are unchanged from the original.
|
||||||
*/
|
*/
|
||||||
@Mixin(LivingEntityRenderer.class)
|
@Mixin(LivingEntityRenderer.class)
|
||||||
public abstract class LivingEntityRendererMixin<T extends LivingEntity, S extends LivingEntityRenderState> {
|
public abstract class LivingEntityRendererMixin {
|
||||||
|
|
||||||
@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<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.VertexConsumerProvider;
|
||||||
import net.minecraft.client.render.entity.EntityRenderer;
|
import net.minecraft.client.render.entity.EntityRenderer;
|
||||||
import net.minecraft.client.render.entity.state.EntityRenderState;
|
// import net.minecraft.client.render.entity.state.EntityRenderState;
|
||||||
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
// import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
@@ -48,47 +48,47 @@ public abstract class NametagsMixin {
|
|||||||
@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 (!NametagsFeature.shouldReplaceName())
|
// if (!NametagsFeature.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;
|
||||||
EntityModuleFabric.RenderStateEntityState entityState = new EntityModuleFabric.RenderStateEntityState(
|
// EntityModuleFabric.RenderStateEntityState entityState = new EntityModuleFabric.RenderStateEntityState(
|
||||||
customName, hrs);
|
// customName, hrs);
|
||||||
|
|
||||||
// Ask the feature for the replacement string
|
// // Ask the feature for the replacement string
|
||||||
String replacement = NametagsFeature.getNametagString(entityState);
|
// String replacement = NametagsFeature.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);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,6 @@ public class TpsMixin {
|
|||||||
|
|
||||||
@Inject(method = "onWorldTimeUpdate", at = @At("HEAD"))
|
@Inject(method = "onWorldTimeUpdate", at = @At("HEAD"))
|
||||||
private void onWorldTimeUpdate(WorldTimeUpdateS2CPacket packet, CallbackInfo ci) {
|
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);
|
AnimationStack animationStack = PlayerAnimationAccess.getPlayerAnimLayer(player);
|
||||||
|
|
||||||
if (emoteIdOrNull != null && !emoteIdOrNull.isEmpty()) {
|
if (emoteIdOrNull != null && !emoteIdOrNull.isEmpty()) {
|
||||||
if (animationStack.isActive() && animationStack.getPriority() == 1000) {
|
if (animationStack.isActive()) {
|
||||||
animationStack.removeLayer(1000);
|
animationStack.removeLayer(1000);
|
||||||
}
|
}
|
||||||
animationStack.addAnimLayer(1000,
|
animationStack.addAnimLayer(1000,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
"GameRendererMixin",
|
"GameRendererMixin",
|
||||||
"LightmapTextureManagerMixin",
|
"LightmapTextureManagerMixin",
|
||||||
"LivingEntityRendererMixin",
|
"LivingEntityRendererMixin",
|
||||||
"LivingEntityRenderStateMixin",
|
|
||||||
"NametagsMixin",
|
"NametagsMixin",
|
||||||
"RenderMixin",
|
"RenderMixin",
|
||||||
"TpsMixin"
|
"TpsMixin"
|
||||||
|
|||||||
Reference in New Issue
Block a user