From de5f6d5fced796fa6af88092e6202f5e18289562 Mon Sep 17 00:00:00 2001 From: ZacSharp <68165024+ZacSharp@users.noreply.github.com> Date: Wed, 11 Jan 2023 23:56:52 +0100 Subject: [PATCH] Apply suggested reordering --- .../movement/movements/MovementDiagonal.java | 11 ++++++----- .../movement/movements/MovementPillar.java | 2 +- .../movement/movements/MovementTraverse.java | 17 +++++++++-------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index f72a0446..9a17d22b 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -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(); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 5d8d32a8..cfa9d926 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -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; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 473b1439..c8a3528e 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -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