From 0587223da8aa6559fee32e4636c4a6d1e9e5f4d9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 14 Jul 2022 22:02:19 -0700 Subject: [PATCH] better constants --- .../pathing/precompute/PrecomputedData.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/baritone/pathing/precompute/PrecomputedData.java b/src/main/java/baritone/pathing/precompute/PrecomputedData.java index 5b5bbc52..72eb575b 100644 --- a/src/main/java/baritone/pathing/precompute/PrecomputedData.java +++ b/src/main/java/baritone/pathing/precompute/PrecomputedData.java @@ -29,32 +29,32 @@ public class PrecomputedData { // TODO add isFullyPassable private final int[] data = new int[Block.BLOCK_STATE_IDS.size()]; - private final int completedMask = 1 << 0; - private final int canWalkOnMask = 1 << 1; - private final int canWalkOnSpecialMask = 1 << 2; - private final int canWalkThroughMask = 1 << 3; - private final int canWalkThroughSpecialMask = 1 << 4; + private static final int COMPLETED_MASK = 1 << 0; + private static final int CAN_WALK_ON_MASK = 1 << 1; + private static final int CAN_WALK_ON_SPECIAL_MASK = 1 << 2; + private static final int CAN_WALK_THROUGH_MASK = 1 << 3; + private static final int CAN_WALK_THROUGH_SPECIAL_MASK = 1 << 4; private int fillData(int id, IBlockState state) { int blockData = 0; Ternary canWalkOnState = MovementHelper.canWalkOnBlockState(state); if (canWalkOnState == YES) { - blockData |= canWalkOnMask; + blockData |= CAN_WALK_ON_MASK; } if (canWalkOnState == MAYBE) { - blockData |= canWalkOnSpecialMask; + blockData |= CAN_WALK_ON_SPECIAL_MASK; } Ternary canWalkThroughState = MovementHelper.canWalkThroughBlockState(state); if (canWalkThroughState == YES) { - blockData |= canWalkThroughMask; + blockData |= CAN_WALK_THROUGH_MASK; } if (canWalkOnState == MAYBE) { - blockData |= canWalkThroughSpecialMask; + blockData |= CAN_WALK_THROUGH_SPECIAL_MASK; } - blockData |= completedMask; + blockData |= COMPLETED_MASK; data[id] = blockData; // in theory, this is thread "safe" because every thread should compute the exact same int to write? return blockData; @@ -64,14 +64,14 @@ public class PrecomputedData { // TODO add isFullyPassable int id = Block.BLOCK_STATE_IDS.get(state); int blockData = data[id]; - if ((blockData & completedMask) == 0) { // we need to fill in the data + if ((blockData & COMPLETED_MASK) == 0) { // we need to fill in the data blockData = fillData(id, state); } - if ((blockData & canWalkOnSpecialMask) != 0) { + if ((blockData & CAN_WALK_ON_SPECIAL_MASK) != 0) { return MovementHelper.canWalkOnPosition(bsi, x, y, z, state); } else { - return (blockData & canWalkOnMask) != 0; + return (blockData & CAN_WALK_ON_MASK) != 0; } } @@ -79,14 +79,14 @@ public class PrecomputedData { // TODO add isFullyPassable int id = Block.BLOCK_STATE_IDS.get(state); int blockData = data[id]; - if ((blockData & completedMask) == 0) { // we need to fill in the data + if ((blockData & COMPLETED_MASK) == 0) { // we need to fill in the data blockData = fillData(id, state); } - if ((blockData & canWalkThroughSpecialMask) != 0) { + if ((blockData & CAN_WALK_THROUGH_SPECIAL_MASK) != 0) { return MovementHelper.canWalkThroughPosition(bsi, x, y, z, state); } else { - return (blockData & canWalkThroughMask) != 0; + return (blockData & CAN_WALK_THROUGH_MASK) != 0; } } }