Skip to content

Commit

Permalink
Slightly change body rotation interpolation in <= 1.19.3 (#542)
Browse files Browse the repository at this point in the history
* Add Old Body Rotation Interpolation <=1.19.3

* Rename method as requested

Co-authored-by: EnZaXD <[email protected]>

* Add comment as requested

Co-authored-by: EnZaXD <[email protected]>

---------

Co-authored-by: lowercasebtw <[email protected]>
Co-authored-by: EnZaXD <[email protected]>
  • Loading branch information
3 people authored Aug 24, 2024
1 parent ef174f8 commit b7d152c
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -112,6 +114,20 @@ private boolean allowPlayerToBeMovedByEntityPackets(LivingEntity instance) {
}
}

@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()) {
Expand Down

0 comments on commit b7d152c

Please sign in to comment.