From e553ee93b82a8669f3cd975e2dd0a8d8667f3541 Mon Sep 17 00:00:00 2001 From: leijurv Date: Tue, 28 Aug 2018 21:10:41 -0700 Subject: [PATCH] 20% improvement to cached chunk check performance --- .../utils/pathing/PathingBlockType.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/utils/pathing/PathingBlockType.java b/src/main/java/baritone/utils/pathing/PathingBlockType.java index a05b0b2b..61dbf2fc 100644 --- a/src/main/java/baritone/utils/pathing/PathingBlockType.java +++ b/src/main/java/baritone/utils/pathing/PathingBlockType.java @@ -23,7 +23,7 @@ package baritone.utils.pathing; */ public enum PathingBlockType { - AIR (0b00), + AIR(0b00), WATER(0b01), AVOID(0b10), SOLID(0b11); @@ -31,7 +31,7 @@ public enum PathingBlockType { private final boolean[] bits; PathingBlockType(int bits) { - this.bits = new boolean[] { + this.bits = new boolean[]{ (bits & 0b10) != 0, (bits & 0b01) != 0 }; @@ -42,11 +42,18 @@ public enum PathingBlockType { } public static PathingBlockType fromBits(boolean b1, boolean b2) { - for (PathingBlockType type : values()) - if (type.bits[0] == b1 && type.bits[1] == b2) - return type; - - // This will never happen, but if it does, assume it's just AIR - return PathingBlockType.AIR; + if (b1) { + if (b2) { + return PathingBlockType.SOLID; + } else { + return PathingBlockType.AVOID; + } + } else { + if (b2) { + return PathingBlockType.WATER; + } else { + return PathingBlockType.AIR; + } + } } }