Don't bother with nms to get block combined id for 1.12
This commit is contained in:
parent
84d95b5b2b
commit
20a017e686
@ -43,7 +43,7 @@ public class ParamInfoItemBlock extends ParamInfoItemStack {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object fromString(String string) {
|
public Object fromString(String string) {
|
||||||
String[] split = string.split("[ -]", -1);
|
String[] split = string.split("[:, -]", -1);
|
||||||
|
|
||||||
if (split.length > (NmsVersion.v1_13.isSupported() ? 1 : 3)) {
|
if (split.length > (NmsVersion.v1_13.isSupported() ? 1 : 3)) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
@ -1530,18 +1530,12 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
public static int getCombinedIdByItemStack(ItemStack itemStack) {
|
public static int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||||
try {
|
try {
|
||||||
Object nmsBlock;
|
if (!NmsVersion.v1_13.isSupported()) {
|
||||||
|
return itemStack.getType().ordinal() + (itemStack.getDurability() << 12);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object nmsBlock = magicGetBlock.invoke(null, itemStack.getType());
|
||||||
|
|
||||||
Object iBlockData = getBlockData.invoke(nmsBlock);
|
Object iBlockData = getBlockData.invoke(nmsBlock);
|
||||||
|
|
||||||
return (int) getBlockDataAsId.invoke(null, iBlockData);
|
return (int) getBlockDataAsId.invoke(null, iBlockData);
|
||||||
|
Loading…
Reference in New Issue
Block a user