Apply suggested reordering

This commit is contained in:
ZacSharp 2023-01-11 23:56:52 +01:00
parent f76283ebfe
commit de5f6d5fce
No known key found for this signature in database
GPG Key ID: 9453647B005083A3
3 changed files with 16 additions and 14 deletions

View File

@ -114,6 +114,7 @@ public class MovementDiagonal extends Movement {
return;
}
IBlockState destInto = context.get(destX, y, destZ);
IBlockState fromDown = context.get(x, y - 1, z);
boolean ascend = false;
IBlockState destWalkOn;
boolean descend = false;
@ -126,9 +127,9 @@ public class MovementDiagonal extends Movement {
destWalkOn = destInto;
} else {
destWalkOn = context.get(destX, y - 1, destZ);
boolean standingOnABlock = MovementHelper.mustBeSolidToWalkOn(context, x, y-1, z, context.get(x, y-1, z));
boolean standingOnABlock = MovementHelper.mustBeSolidToWalkOn(context, x, y - 1, z, fromDown);
frostWalker = standingOnABlock && MovementHelper.canUseFrostWalker(context, destWalkOn);
if (!MovementHelper.canWalkOn(context, destX, y - 1, destZ, destWalkOn) && !frostWalker) {
if (!frostWalker && !MovementHelper.canWalkOn(context, destX, y - 1, destZ, destWalkOn)) {
descend = true;
if (!context.allowDiagonalDescend || !MovementHelper.canWalkOn(context, destX, y - 2, destZ) || !MovementHelper.canWalkThrough(context, destX, y - 1, destZ, destWalkOn)) {
return;
@ -145,11 +146,11 @@ public class MovementDiagonal extends Movement {
} else if (destWalkOn.getBlock() == Blocks.WATER) {
multiplier += context.walkOnWaterOnePenalty * SQRT_2;
}
Block fromDown = context.get(x, y - 1, z).getBlock();
if (fromDown == Blocks.LADDER || fromDown == Blocks.VINE) {
Block fromDownBlock = fromDown.getBlock();
if (fromDownBlock == Blocks.LADDER || fromDownBlock == Blocks.VINE) {
return;
}
if (fromDown == Blocks.SOUL_SAND) {
if (fromDownBlock == Blocks.SOUL_SAND) {
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
}
Block cuttingOver1 = context.get(x, y - 1, destZ).getBlock();

View File

@ -101,7 +101,7 @@ public class MovementPillar extends Movement {
// if we're standing on water and assumeWalkOnWater is false, we must have ascended to here, or sneak backplaced, so it is possible to pillar again
return COST_INF;
}
if (fromDown.getBlock() instanceof BlockLiquid && (from == Blocks.WATERLILY || from == Blocks.CARPET)) {
if ((from == Blocks.WATERLILY || from == Blocks.CARPET) && fromDown.getBlock() instanceof BlockLiquid) {
// to ascend here we'd have to break the block we are standing on
return COST_INF;
}

View File

@ -71,10 +71,11 @@ public class MovementTraverse extends Movement {
IBlockState pb0 = context.get(destX, y + 1, destZ);
IBlockState pb1 = context.get(destX, y, destZ);
IBlockState destOn = context.get(destX, y - 1, destZ);
Block srcDown = context.getBlock(x, y - 1, z);
boolean standingOnABlock = MovementHelper.mustBeSolidToWalkOn(context, x, y-1, z, context.get(x, y-1, z));
IBlockState srcDown = context.get(x, y - 1, z);
Block srcDownBlock = srcDown.getBlock();
boolean standingOnABlock = MovementHelper.mustBeSolidToWalkOn(context, x, y-1, z, srcDown);
boolean frostWalker = standingOnABlock && !context.assumeWalkOnWater && MovementHelper.canUseFrostWalker(context, destOn);
if (MovementHelper.canWalkOn(context, destX, y - 1, destZ, destOn) || frostWalker) { //this is a walk, not a bridge
if (frostWalker || MovementHelper.canWalkOn(context, destX, y - 1, destZ, destOn)) { //this is a walk, not a bridge
double WC = WALK_ONE_BLOCK_COST;
boolean water = false;
if (MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock())) {
@ -88,7 +89,7 @@ public class MovementTraverse extends Movement {
} else if (destOn.getBlock() == Blocks.WATER) {
WC += context.walkOnWaterOnePenalty;
}
if (srcDown == Blocks.SOUL_SAND) {
if (srcDownBlock == Blocks.SOUL_SAND) {
WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
}
}
@ -106,13 +107,13 @@ public class MovementTraverse extends Movement {
}
return WC;
}
if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) {
if (srcDownBlock == Blocks.LADDER || srcDownBlock == Blocks.VINE) {
hardness1 *= 5;
hardness2 *= 5;
}
return WC + hardness1 + hardness2;
} else {//this is a bridge, so we need to place a block
if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) {
if (srcDownBlock == Blocks.LADDER || srcDownBlock == Blocks.VINE) {
return COST_INF;
}
if (MovementHelper.isReplaceable(destX, y - 1, destZ, destOn, context.bsi)) {
@ -143,14 +144,14 @@ public class MovementTraverse extends Movement {
}
}
// now that we've checked all possible directions to side place, we actually need to backplace
if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof BlockSlab && !((BlockSlab) srcDown).isDouble())) {
if (srcDownBlock == Blocks.SOUL_SAND || (srcDownBlock instanceof BlockSlab && !((BlockSlab) srcDownBlock).isDouble())) {
return COST_INF; // can't sneak and backplace against soul sand or half slabs (regardless of whether it's top half or bottom half) =/
}
if (!standingOnABlock) { // standing on water / swimming
return COST_INF; // this is obviously impossible
}
Block blockSrc = context.getBlock(x, y, z);
if (srcDown instanceof BlockLiquid && (blockSrc == Blocks.WATERLILY || blockSrc == Blocks.CARPET)) {
if ((blockSrc == Blocks.WATERLILY || blockSrc == Blocks.CARPET) && srcDownBlock instanceof BlockLiquid) {
return COST_INF; // we can stand on these but can't place against them
}
WC = WC * (SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST);//since we are sneak backplacing, we are sneaking lol