Pick up water from bucket during fall

This commit is contained in:
Howard Stark 2018-08-08 14:44:16 -07:00
parent f175d09390
commit 04571426fe
No known key found for this signature in database
GPG Key ID: 9FA4E350B33067F3

View File

@ -32,7 +32,8 @@ import net.minecraft.util.math.Vec3d;
public class MovementFall extends Movement { public class MovementFall extends Movement {
private static final ItemStack STACK_WATER_BUCKET = new ItemStack(Items.WATER_BUCKET); private static final ItemStack STACK_BUCKET_WATER = new ItemStack(Items.WATER_BUCKET);
private static final ItemStack STACK_BUCKET_AIR = new ItemStack(Items.BUCKET);
public MovementFall(BlockPos src, BlockPos dest) { public MovementFall(BlockPos src, BlockPos dest) {
super(src, dest, MovementFall.buildPositionsToBreak(src, dest), new BlockPos[] { dest.down() }); super(src, dest, MovementFall.buildPositionsToBreak(src, dest), new BlockPos[] { dest.down() });
@ -67,12 +68,12 @@ public class MovementFall extends Movement {
state.setStatus(MovementStatus.RUNNING); state.setStatus(MovementStatus.RUNNING);
case RUNNING: case RUNNING:
BlockPos playerFeet = playerFeet(); BlockPos playerFeet = playerFeet();
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > 3) { if (!BlockStateInterface.isWater(dest) && playerFeet().getY() - dest.getY() > 3) {
if (!player().inventory.hasItemStack(STACK_WATER_BUCKET) || world().provider.isNether()) { if (!player().inventory.hasItemStack(STACK_BUCKET_WATER) || world().provider.isNether()) {
state.setStatus(MovementStatus.UNREACHABLE); state.setStatus(MovementStatus.UNREACHABLE);
return state; return state;
} }
player().inventory.currentItem = player().inventory.getSlotFor(STACK_WATER_BUCKET); player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_WATER);
LookBehaviorUtils.reachable(dest).ifPresent(rotation -> LookBehaviorUtils.reachable(dest).ifPresent(rotation ->
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true) state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true)
.setTarget(new MovementTarget(rotation)) .setTarget(new MovementTarget(rotation))
@ -81,8 +82,13 @@ public class MovementFall extends Movement {
Rotation rotationToBlock = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(dest, world())); Rotation rotationToBlock = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(dest, world()));
state.setTarget(new MovementTarget(rotationToBlock)); state.setTarget(new MovementTarget(rotationToBlock));
} }
if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.01 || BlockStateInterface.isWater(dest))) if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.01
|| (BlockStateInterface.isWater(dest) && !player().inventory.hasItemStack(STACK_BUCKET_AIR)))) {
if (BlockStateInterface.isWater(dest) && player().inventory.hasItemStack(STACK_BUCKET_AIR)) {
return state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true);
}
return state.setStatus(MovementStatus.SUCCESS); return state.setStatus(MovementStatus.SUCCESS);
}
Vec3d destCenter = Utils.calcCenterFromCoords(dest, world()); Vec3d destCenter = Utils.calcCenterFromCoords(dest, world());
if (Math.abs(player().posX - destCenter.x) > 0.2 || Math.abs(player().posZ - destCenter.z) > 0.2) { if (Math.abs(player().posX - destCenter.x) > 0.2 || Math.abs(player().posZ - destCenter.z) > 0.2) {
state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);