Skip to content

Commit

Permalink
Merge pull request #2 from LeoCTH/chickenturnleft
Browse files Browse the repository at this point in the history
barp
  • Loading branch information
pluiedev authored Aug 24, 2020
2 parents 3c6f1e9 + 23c395d commit 20d187d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,4 @@ public static float hackChangeAngle(ChickenEntity entity, float headYaw, float t
}
return MathHelper.wrapDegrees(h);
}

public static float noHackChangeAngle(float headYaw, float targetYaw, float yawSpeed) {
float f = MathHelper.subtractAngles(headYaw, targetYaw);
float g = MathHelper.clamp(f, -yawSpeed, yawSpeed);
return MathHelper.wrapDegrees(headYaw + g);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
@Mixin(LookControl.class)
public abstract class MixinLookControl {

@Shadow abstract float changeAngle(float from, float to, float max);

@Redirect(
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ai/control/LookControl;changeAngle(FFF)F", ordinal = 0),
method = "tick"
)
private float redirectHeadChangeAngle(LookControl self, float headYaw, float targetYaw, float yawSpeed) {
return (entity instanceof ChickenEntity)
? ChickenTurnLeftImpl.hackChangeAngle((ChickenEntity) entity, headYaw, targetYaw, yawSpeed, ChickenTurnLeftCallback.TurnLeftType.HEAD)
: ChickenTurnLeftImpl.noHackChangeAngle(headYaw, targetYaw, yawSpeed);
: this.changeAngle(headYaw, targetYaw, yawSpeed);
}

@Redirect(
Expand All @@ -34,7 +36,7 @@ private float redirectHeadChangeAngle(LookControl self, float headYaw, float tar
private float redirectBodyChangeAngle(LookControl self, float headYaw, float targetYaw, float yawSpeed) {
return (entity instanceof ChickenEntity)
? ChickenTurnLeftImpl.hackChangeAngle((ChickenEntity) entity, headYaw, targetYaw, yawSpeed, ChickenTurnLeftCallback.TurnLeftType.BODY)
: ChickenTurnLeftImpl.noHackChangeAngle(headYaw, targetYaw, yawSpeed);
: this.changeAngle(headYaw, targetYaw, yawSpeed);
}

@Shadow @Final private MobEntity entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
@Mixin(MoveControl.class)
public abstract class MixinMoveControl {

@Shadow abstract float changeAngle(float from, float to, float max);

@Redirect(
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ai/control/MoveControl;changeAngle(FFF)F", ordinal = 0),
method = "tick"
)
private float redirectBodyChangeAngle(MoveControl self, float headYaw, float targetYaw, float yawSpeed) {
return (entity instanceof ChickenEntity)
? ChickenTurnLeftImpl.hackChangeAngle((ChickenEntity) entity, headYaw, targetYaw, yawSpeed, ChickenTurnLeftCallback.TurnLeftType.BODY)
: ChickenTurnLeftImpl.noHackChangeAngle(headYaw, targetYaw, yawSpeed);
: this.changeAngle(headYaw, targetYaw, yawSpeed);
}

@Shadow @Final private MobEntity entity;
Expand Down

0 comments on commit 20d187d

Please sign in to comment.