MinecraftReflection.getMinecraftItemStack() returns null for CraftItemStacks with Material.AIR
Alvin-LB opened this issue ยท 2 comments
Make sure you've done the following:
- You're using the latest build for your server version (PL 4.3.0)
- This isn't an issue caused by another plugin
- You've checked for duplicate issues
- You didn't use
/reload
Description and relevant errors:
The MinecraftReflection.getMinecraftItemStack(ItemStack)
method returns null for CraftItemStacks with Material.AIR
. Note that it only happens if the ItemStack is a CraftItemStack (IE it has come from an inventory or somewhere else in the minecraft internals), regular ItemStacks are not affected.
This is because the BukkitUnwrapper#unwrapItem()
call on line 1946 fetches the handle
field in the CraftItemStack, but this field is set to null if the material is Material.AIR
.
This is the shortest way I could find to reproduce the problem:
// This will print null, even though it shouldn't!
System.out.println(MinecraftReflection.getMinecraftItemStack(CraftItemStack.asCraftCopy(new ItemStack(Material.AIR))));
Since you identified the cause of this issue already, would you be able to PR a fix? Should be as a easy as a simple null check.