fixed descend into water

This commit is contained in:
Leijurv 2018-08-09 12:53:34 -07:00
parent f55686295c
commit a1dc98589c
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -32,7 +32,7 @@ import net.minecraft.util.math.BlockPos;
public class MovementDescend extends Movement { public class MovementDescend extends Movement {
public MovementDescend(BlockPos start, BlockPos end) { public MovementDescend(BlockPos start, BlockPos end) {
super(start, end, new BlockPos[] { end.up(2), end.up(), end }, new BlockPos[] { end.down() }); super(start, end, new BlockPos[]{end.up(2), end.up(), end}, new BlockPos[]{end.down()});
} }
@Override @Override
@ -61,7 +61,7 @@ public class MovementDescend extends Movement {
case RUNNING: case RUNNING:
BlockPos playerFeet = playerFeet(); BlockPos playerFeet = playerFeet();
if (playerFeet.equals(dest) && player().posY - playerFeet.getY() < 0.01) { if (playerFeet.equals(dest) && (BlockStateInterface.isLiquid(dest) || player().posY - playerFeet.getY() < 0.01)) {
// Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately // Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately
state.setStatus(MovementStatus.SUCCESS); state.setStatus(MovementStatus.SUCCESS);
return state; return state;
@ -74,9 +74,8 @@ public class MovementDescend extends Movement {
double diffX2 = player().posX - (fakeDest.getX() + 0.5); double diffX2 = player().posX - (fakeDest.getX() + 0.5);
double diffZ2 = player().posZ - (fakeDest.getZ() + 0.5); double diffZ2 = player().posZ - (fakeDest.getZ() + 0.5);
double d = Math.sqrt(diffX2 * diffX2 + diffZ2 * diffZ2); double d = Math.sqrt(diffX2 * diffX2 + diffZ2 * diffZ2);
if (d > ab) MovementHelper.moveTowards(state, fakeDest);
MovementHelper.moveTowards(state, fakeDest); if (d <= ab) {
else {
state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, false); state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, false);
state.setInput(InputOverrideHandler.Input.MOVE_BACK, true); state.setInput(InputOverrideHandler.Input.MOVE_BACK, true);
} }