Merge pull request #1964 from ZacSharp/master
Fix MovementDiagonal being safeToCancel while cornering over air 2.0
This commit is contained in:
commit
bf723deced
@ -31,6 +31,7 @@ import baritone.utils.pathing.MutableMoveResult;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -58,11 +59,32 @@ public class MovementDiagonal extends Movement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean safeToCancel(MovementState state) {
|
protected boolean safeToCancel(MovementState state) {
|
||||||
return ctx.playerFeet().equals(src) || ((
|
//too simple. backfill does not work after cornering with this
|
||||||
MovementHelper.canWalkOn(ctx, new BlockPos(src.x, src.y - 1, dest.z))
|
//return MovementHelper.canWalkOn(ctx, ctx.playerFeet().down());
|
||||||
) &&
|
EntityPlayerSP player = ctx.player();
|
||||||
MovementHelper.canWalkOn(ctx, new BlockPos(dest.x, src.y - 1, src.z)));
|
double offset = 0.25;
|
||||||
}
|
double x = player.posX;
|
||||||
|
double y = player.posY - 1;
|
||||||
|
double z = player.posZ;
|
||||||
|
//standard
|
||||||
|
if (ctx.playerFeet().equals(src)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//both corners are walkable
|
||||||
|
if (MovementHelper.canWalkOn(ctx, new BlockPos(src.x, src.y - 1, dest.z))
|
||||||
|
&& MovementHelper.canWalkOn(ctx, new BlockPos(dest.x, src.y - 1, src.z))){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//we are in a likely unwalkable corner, check for a supporting block
|
||||||
|
if (ctx.playerFeet().equals(new BetterBlockPos(src.x, src.y, dest.z))
|
||||||
|
|| ctx.playerFeet().equals(new BetterBlockPos(dest.x, src.y, src.z))){
|
||||||
|
return (MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z + offset))
|
||||||
|
|| MovementHelper.canWalkOn(ctx, new BetterBlockPos(x + offset, y, z - offset))
|
||||||
|
|| MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z + offset))
|
||||||
|
|| MovementHelper.canWalkOn(ctx, new BetterBlockPos(x - offset, y, z - offset)));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double calculateCost(CalculationContext context) {
|
public double calculateCost(CalculationContext context) {
|
||||||
|
Loading…
Reference in New Issue
Block a user