center pillar regardless of timing

This commit is contained in:
Leijurv 2018-10-10 21:07:59 -07:00
parent 089037663e
commit 9bd205f190
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -35,18 +35,11 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
public class MovementPillar extends Movement { public class MovementPillar extends Movement {
private int numTicks = 0;
public MovementPillar(BetterBlockPos start, BetterBlockPos end) { public MovementPillar(BetterBlockPos start, BetterBlockPos end) {
super(start, end, new BetterBlockPos[]{start.up(2)}, start); super(start, end, new BetterBlockPos[]{start.up(2)}, start);
} }
@Override
public void reset() {
super.reset();
numTicks = 0;
}
@Override @Override
protected double calculateCost(CalculationContext context) { protected double calculateCost(CalculationContext context) {
return cost(context, src.x, src.y, src.z); return cost(context, src.x, src.y, src.z);
@ -202,13 +195,10 @@ public class MovementPillar extends Movement {
return state.setStatus(MovementStatus.UNREACHABLE); return state.setStatus(MovementStatus.UNREACHABLE);
} }
numTicks++;
// If our Y coordinate is above our goal, stop jumping // If our Y coordinate is above our goal, stop jumping
state.setInput(InputOverrideHandler.Input.JUMP, player().posY < dest.getY()); state.setInput(InputOverrideHandler.Input.JUMP, player().posY < dest.getY());
state.setInput(InputOverrideHandler.Input.SNEAK, true); state.setInput(InputOverrideHandler.Input.SNEAK, true);
// Otherwise jump
if (numTicks > 20) {
double diffX = player().posX - (dest.getX() + 0.5); double diffX = player().posX - (dest.getX() + 0.5);
double diffZ = player().posZ - (dest.getZ() + 0.5); double diffZ = player().posZ - (dest.getZ() + 0.5);
double dist = Math.sqrt(diffX * diffX + diffZ * diffZ); double dist = Math.sqrt(diffX * diffX + diffZ * diffZ);
@ -219,7 +209,7 @@ public class MovementPillar extends Movement {
// If it's been more than forty ticks of trying to jump and we aren't done yet, go forward, maybe we are stuck // If it's been more than forty ticks of trying to jump and we aren't done yet, go forward, maybe we are stuck
state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
} }
}
if (!blockIsThere) { if (!blockIsThere) {
Block fr = BlockStateInterface.get(src).getBlock(); Block fr = BlockStateInterface.get(src).getBlock();