Slightly change body rotation interpolation in <= 1.19.3 (#542)

* Add Old Body Rotation Interpolation <=1.19.3

* Rename method as requested

Co-authored-by: EnZaXD <florian.michael07@gmail.com>

* Add comment as requested

Co-authored-by: EnZaXD <florian.michael07@gmail.com>

---------

Co-authored-by: lowercasebtw <lowercasebtw@gmail.com>
Co-authored-by: EnZaXD <florian.michael07@gmail.com>
This commit is contained in:
lowercasebtw 2024-08-24 07:30:53 -04:00 committed by GitHub
parent ef174f8c14
commit b7d152c1cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -74,6 +74,8 @@ public abstract class MixinLivingEntity extends Entity {
@Shadow
public abstract boolean hasStatusEffect(RegistryEntry<StatusEffect> effect);
@Shadow public float bodyYaw;
public MixinLivingEntity(EntityType<?> type, World world) {
super(type, world);
}
@ -112,6 +114,20 @@ public abstract class MixinLivingEntity extends Entity {
}
}
@Redirect(method = "turnHead", at = @At(value = "INVOKE", target = "Ljava/lang/Math;abs(F)F"))
private float changeBodyRotationInterpolation(float g) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
g = MathHelper.clamp(g, -75.0F, 75.0F);
this.bodyYaw = this.getYaw() - g;
if (Math.abs(g) > 50.0F) {
this.bodyYaw += g * 0.2F;
}
return Float.MIN_VALUE; // Causes the if to always fail
} else {
return Math.abs(g);
}
}
@Inject(method = "tickCramming", at = @At("HEAD"), cancellable = true)
private void preventEntityPush(CallbackInfo ci) {
if (DebugSettings.global().preventEntityCramming.isEnabled()) {