fix wrong y coordinate on path beginning
This commit is contained in:
parent
5513d0669f
commit
1745ce6a62
@ -20,13 +20,11 @@ package baritone.pathing.path;
|
||||
import baritone.Baritone;
|
||||
import baritone.api.event.events.TickEvent;
|
||||
import baritone.pathing.movement.*;
|
||||
import baritone.pathing.movement.movements.MovementDescend;
|
||||
import baritone.pathing.movement.movements.MovementDiagonal;
|
||||
import baritone.pathing.movement.movements.MovementFall;
|
||||
import baritone.pathing.movement.movements.MovementTraverse;
|
||||
import baritone.pathing.movement.movements.*;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.Helper;
|
||||
import baritone.utils.Utils;
|
||||
import baritone.utils.pathing.BetterBlockPos;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@ -78,9 +76,16 @@ public class PathExecutor implements Helper {
|
||||
if (pathPosition >= path.length() - 1) {
|
||||
return true; // stop bugging me, I'm done
|
||||
}
|
||||
BlockPos whereShouldIBe = path.positions().get(pathPosition);
|
||||
BlockPos whereAmI = playerFeet();
|
||||
BetterBlockPos whereShouldIBe = path.positions().get(pathPosition);
|
||||
BetterBlockPos whereAmI = playerFeet();
|
||||
if (!whereShouldIBe.equals(whereAmI)) {
|
||||
|
||||
if (pathPosition == 0 && whereAmI.equals(whereShouldIBe.up()) && Math.abs(player().motionY) < 0.1) {
|
||||
// avoid the Wrong Y coordinate bug
|
||||
new MovementDownward(whereAmI, whereShouldIBe).update();
|
||||
return false;
|
||||
}
|
||||
|
||||
//System.out.println("Should be at " + whereShouldIBe + " actually am at " + whereAmI);
|
||||
if (!Blocks.AIR.equals(BlockStateInterface.getBlock(whereAmI.down()))) {//do not skip if standing on air, because our position isn't stable to skip
|
||||
for (int i = 0; i < pathPosition - 1 && i < path.length(); i++) {//this happens for example when you lag out and get teleported back a couple blocks
|
||||
|
@ -18,11 +18,11 @@
|
||||
package baritone.utils;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.utils.pathing.BetterBlockPos;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
@ -52,9 +52,9 @@ public interface Helper {
|
||||
return mc.world;
|
||||
}
|
||||
|
||||
default BlockPos playerFeet() {
|
||||
default BetterBlockPos playerFeet() {
|
||||
// TODO find a better way to deal with soul sand!!!!!
|
||||
BlockPos feet = new BlockPos(player().posX, player().posY + 0.1251, player().posZ);
|
||||
BetterBlockPos feet = new BetterBlockPos(player().posX, player().posY + 0.1251, player().posZ);
|
||||
if (BlockStateInterface.get(feet).getBlock() instanceof BlockSlab) {
|
||||
return feet.up();
|
||||
}
|
||||
@ -75,6 +75,7 @@ public interface Helper {
|
||||
|
||||
/**
|
||||
* Send a message to chat only if chatDebug is on
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
default void logDebug(String message) {
|
||||
@ -88,6 +89,7 @@ public interface Helper {
|
||||
|
||||
/**
|
||||
* Send a message to chat regardless of chatDebug (should only be used for critically important messages, or as a direct response to a chat command)
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
default void logDirect(String message) {
|
||||
|
@ -19,6 +19,7 @@ package baritone.utils.pathing;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
/**
|
||||
@ -59,6 +60,10 @@ public final class BetterBlockPos extends BlockPos {
|
||||
this.hashCode = hash;
|
||||
}
|
||||
|
||||
public BetterBlockPos(double x, double y, double z) {
|
||||
this(MathHelper.floor(x), MathHelper.floor(y), MathHelper.floor(z));
|
||||
}
|
||||
|
||||
public BetterBlockPos(BlockPos pos) {
|
||||
this(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user