fix the fire thing in a slightly different way
This commit is contained in:
parent
5daaaf5282
commit
6a402b4a2b
@ -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.
|
* Clamps the specified pitch value between -90 and 90.
|
||||||
*
|
*
|
||||||
|
@ -151,9 +151,10 @@ public abstract class Movement implements IMovement, MovementHelper {
|
|||||||
somethingInTheWay = true;
|
somethingInTheWay = true;
|
||||||
Optional<Rotation> reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance());
|
Optional<Rotation> reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance());
|
||||||
if (reachable.isPresent()) {
|
if (reachable.isPresent()) {
|
||||||
|
Rotation rotTowardsBlock = reachable.get();
|
||||||
MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, blockPos));
|
MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, blockPos));
|
||||||
state.setTarget(new MovementState.MovementTarget(reachable.get(), true));
|
state.setTarget(new MovementState.MovementTarget(rotTowardsBlock, true));
|
||||||
if (Objects.equals(ctx.getSelectedBlock().orElse(null), blockPos)) {
|
if (Objects.equals(ctx.getSelectedBlock().orElse(null), blockPos) || ctx.playerRotations().isReallyCloseTo(rotTowardsBlock)) {
|
||||||
state.setInput(Input.CLICK_LEFT, true);
|
state.setInput(Input.CLICK_LEFT, true);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user