fix the fire thing in a slightly different way

This commit is contained in:
Leijurv 2018-11-29 20:36:19 -08:00
parent 5daaaf5282
commit 6a402b4a2b
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 14 additions and 2 deletions

View File

@ -110,6 +110,17 @@ public class Rotation {
);
}
/**
* Is really close to
*
* @param other another rotation
* @return are they really close
*/
public boolean isReallyCloseTo(Rotation other) {
float yawDiff = Math.abs(this.yaw - other.yaw); // you cant fool me
return (yawDiff < 0.01 || yawDiff > 359.9) && Math.abs(this.pitch - other.pitch) < 0.01;
}
/**
* Clamps the specified pitch value between -90 and 90.
*

View File

@ -151,9 +151,10 @@ public abstract class Movement implements IMovement, MovementHelper {
somethingInTheWay = true;
Optional<Rotation> reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance());
if (reachable.isPresent()) {
Rotation rotTowardsBlock = reachable.get();
MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, blockPos));
state.setTarget(new MovementState.MovementTarget(reachable.get(), true));
if (Objects.equals(ctx.getSelectedBlock().orElse(null), blockPos)) {
state.setTarget(new MovementState.MovementTarget(rotTowardsBlock, true));
if (Objects.equals(ctx.getSelectedBlock().orElse(null), blockPos) || ctx.playerRotations().isReallyCloseTo(rotTowardsBlock)) {
state.setInput(Input.CLICK_LEFT, true);
}
return false;