Don't bother with nms to get block combined id for 1.12

This commit is contained in:
libraryaddict 2021-06-02 10:07:36 +12:00
parent 84d95b5b2b
commit 20a017e686
2 changed files with 5 additions and 11 deletions

View File

@ -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();

View File

@ -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);