Move this to a helper method and add missing cases
This commit is contained in:
parent
45c0b38156
commit
c14be17e53
@ -374,6 +374,26 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
&& ((Integer) state.getValue(BlockLiquid.LEVEL)) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* If movements make us stand/walk on this block, will it have a top to walk on?
|
||||
*/
|
||||
static boolean mustBeSolidToWalkOn(CalculationContext context, int x, int y, int z, IBlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block == Blocks.LADDER || block == Blocks.VINE) {
|
||||
return false;
|
||||
}
|
||||
if (block instanceof BlockLiquid) {
|
||||
if (context.assumeWalkOnWater) {
|
||||
return false;
|
||||
}
|
||||
Block blockAbove = context.getBlock(x, y+1, z);
|
||||
if (blockAbove instanceof BlockLiquid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z) {
|
||||
return canPlaceAgainst(bsi, x, y, z, bsi.get0(x, y, z));
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class MovementDiagonal extends Movement {
|
||||
destWalkOn = destInto;
|
||||
} else {
|
||||
destWalkOn = context.get(destX, y - 1, destZ);
|
||||
boolean standingOnABlock = !(context.getBlock(x, y - 1, z) instanceof BlockLiquid) || (!context.assumeWalkOnWater && !(context.getBlock(x, y, z) instanceof BlockLiquid));
|
||||
boolean standingOnABlock = MovementHelper.mustBeSolidToWalkOn(context, x, y-1, z, context.get(x, y-1, z));
|
||||
frostWalker = standingOnABlock && MovementHelper.canUseFrostWalker(context, destWalkOn);
|
||||
if (!MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destWalkOn) && !frostWalker) {
|
||||
descend = true;
|
||||
|
@ -73,8 +73,7 @@ public class MovementTraverse extends Movement {
|
||||
IBlockState pb1 = context.get(destX, y, destZ);
|
||||
IBlockState destOn = context.get(destX, y - 1, destZ);
|
||||
Block srcDown = context.getBlock(x, y - 1, z);
|
||||
// if we are on water but are neither in water nor can stand on water we must have placed a block to get here
|
||||
boolean standingOnABlock = !(srcDown instanceof BlockLiquid) || (!context.assumeWalkOnWater && !(context.getBlock(x, y, z) instanceof BlockLiquid));
|
||||
boolean standingOnABlock = MovementHelper.mustBeSolidToWalkOn(context, x, y-1, z, context.get(x, y-1, z));
|
||||
boolean frostWalker = standingOnABlock && MovementHelper.canUseFrostWalker(context, destOn);
|
||||
if (MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destOn) || frostWalker) { //this is a walk, not a bridge
|
||||
double WC = WALK_ONE_BLOCK_COST;
|
||||
|
Loading…
x
Reference in New Issue
Block a user