From cf12cbbcf48011525407639264c41e626bbce0b3 Mon Sep 17 00:00:00 2001 From: Logan Darklock Date: Sat, 31 Aug 2019 20:58:22 -0700 Subject: [PATCH] Don't care about meta in bom if we have none --- .../java/baritone/api/utils/BlockOptionalMeta.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/api/java/baritone/api/utils/BlockOptionalMeta.java b/src/api/java/baritone/api/utils/BlockOptionalMeta.java index 836cbbc5..098dc269 100644 --- a/src/api/java/baritone/api/utils/BlockOptionalMeta.java +++ b/src/api/java/baritone/api/utils/BlockOptionalMeta.java @@ -104,7 +104,7 @@ public final class BlockOptionalMeta { block = Block.REGISTRY.getObject(id); meta = noMeta ? 0 : Integer.parseInt(matchResult.group(2)); - blockstates = getStates(block, noMeta ? null : meta); + blockstates = getStates(block, getMeta()); stateHashes = getStateHashes(blockstates); stackHashes = getStackHashes(blockstates); } @@ -114,7 +114,7 @@ public final class BlockOptionalMeta { } public Integer getMeta() { - return meta; + return noMeta ? null : meta; } public boolean matches(@Nonnull Block block) { @@ -128,12 +128,18 @@ public final class BlockOptionalMeta { public boolean matches(ItemStack stack) { //noinspection ConstantConditions - return stackHashes.contains(((IItemStack) (Object) stack).getBaritoneHash()); + int hash = ((IItemStack) (Object) stack).getBaritoneHash(); + + if (noMeta) { + hash -= stack.getItemDamage(); + } + + return stackHashes.contains(hash); } @Override public String toString() { - return String.format("BlockOptionalMeta{block=%s,meta=%s}", block, meta); + return String.format("BlockOptionalMeta{block=%s,meta=%s}", block, getMeta()); } public static IBlockState blockStateFromStack(ItemStack stack) {