fix wrong y coordinate on path beginning

This commit is contained in:
Leijurv 2018-09-15 07:38:53 -07:00
parent 5513d0669f
commit 1745ce6a62
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
3 changed files with 21 additions and 9 deletions

View File

@ -20,13 +20,11 @@ package baritone.pathing.path;
import baritone.Baritone; import baritone.Baritone;
import baritone.api.event.events.TickEvent; import baritone.api.event.events.TickEvent;
import baritone.pathing.movement.*; import baritone.pathing.movement.*;
import baritone.pathing.movement.movements.MovementDescend; import baritone.pathing.movement.movements.*;
import baritone.pathing.movement.movements.MovementDiagonal;
import baritone.pathing.movement.movements.MovementFall;
import baritone.pathing.movement.movements.MovementTraverse;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import baritone.utils.Helper; import baritone.utils.Helper;
import baritone.utils.Utils; import baritone.utils.Utils;
import baritone.utils.pathing.BetterBlockPos;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.util.Tuple; import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -78,9 +76,16 @@ public class PathExecutor implements Helper {
if (pathPosition >= path.length() - 1) { if (pathPosition >= path.length() - 1) {
return true; // stop bugging me, I'm done return true; // stop bugging me, I'm done
} }
BlockPos whereShouldIBe = path.positions().get(pathPosition); BetterBlockPos whereShouldIBe = path.positions().get(pathPosition);
BlockPos whereAmI = playerFeet(); BetterBlockPos whereAmI = playerFeet();
if (!whereShouldIBe.equals(whereAmI)) { 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); //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 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 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

View File

@ -18,11 +18,11 @@
package baritone.utils; package baritone.utils;
import baritone.Baritone; import baritone.Baritone;
import baritone.utils.pathing.BetterBlockPos;
import net.minecraft.block.BlockSlab; import net.minecraft.block.BlockSlab;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
@ -52,9 +52,9 @@ public interface Helper {
return mc.world; return mc.world;
} }
default BlockPos playerFeet() { default BetterBlockPos playerFeet() {
// TODO find a better way to deal with soul sand!!!!! // 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) { if (BlockStateInterface.get(feet).getBlock() instanceof BlockSlab) {
return feet.up(); return feet.up();
} }
@ -75,6 +75,7 @@ public interface Helper {
/** /**
* Send a message to chat only if chatDebug is on * Send a message to chat only if chatDebug is on
*
* @param message * @param message
*/ */
default void logDebug(String 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) * 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 * @param message
*/ */
default void logDirect(String message) { default void logDirect(String message) {

View File

@ -19,6 +19,7 @@ package baritone.utils.pathing;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3i; import net.minecraft.util.math.Vec3i;
/** /**
@ -59,6 +60,10 @@ public final class BetterBlockPos extends BlockPos {
this.hashCode = hash; 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) { public BetterBlockPos(BlockPos pos) {
this(pos.getX(), pos.getY(), pos.getZ()); this(pos.getX(), pos.getY(), pos.getZ());
} }