From 20a017e68600f662bc235824f187770dc666c986 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 2 Jun 2021 10:07:36 +1200 Subject: [PATCH] Don't bother with nms to get block combined id for 1.12 --- .../params/types/custom/ParamInfoItemBlock.java | 2 +- .../utilities/reflection/ReflectionManager.java | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoItemBlock.java b/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoItemBlock.java index 06d35c16..933df8a2 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoItemBlock.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoItemBlock.java @@ -43,7 +43,7 @@ public class ParamInfoItemBlock extends ParamInfoItemStack { @Override public Object fromString(String string) { - String[] split = string.split("[ -]", -1); + String[] split = string.split("[:, -]", -1); if (split.length > (NmsVersion.v1_13.isSupported() ? 1 : 3)) { throw new IllegalArgumentException(); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java b/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java index 36e32b14..1bb7be5b 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java @@ -1530,18 +1530,12 @@ public class ReflectionManager { public static int getCombinedIdByItemStack(ItemStack itemStack) { try { - Object nmsBlock; - - if (NmsVersion.v1_13.isSupported()) { - nmsBlock = magicGetBlock.invoke(null, itemStack.getType()); - } else { - Object nmsItem = getNmsItem(itemStack); - - Object item = getNmsItem.invoke(nmsItem); - - nmsBlock = getOldItemAsBlock.invoke(null, item); + if (!NmsVersion.v1_13.isSupported()) { + return itemStack.getType().ordinal() + (itemStack.getDurability() << 12); } + Object nmsBlock = magicGetBlock.invoke(null, itemStack.getType()); + Object iBlockData = getBlockData.invoke(nmsBlock); return (int) getBlockDataAsId.invoke(null, iBlockData);