ItemStack can't be null/air (Beehive/Barrel, etc...)
Tirco opened this issue ยท 1 comments
- Using latest paper build (1.15.2 #165)
- Using NBT API 2.3.0
[09:23:54 ERROR]: Could not pass event PlayerInteractEvent to VoidRPG v1.3
java.lang.NullPointerException: ItemStack can't be null/Air!
Full stacktrace:
I have this bit of code:
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
public void onItemUse(PlayerInteractEvent event) {
if(!allowedAction(event.getAction())){
return; //Make sure there are only right click actions.
}
Player player = event.getPlayer();
if(event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if(getBlockedMaterials().contains(event.getClickedBlock().getType())) {
return; //Make sure you don't right click an interactable block.
}
}
if(player.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
return;
}
if(player.getInventory().getItemInMainHand() == null){
return;
}
ItemStack usedItem = player.getInventory().getItemInMainHand();
NBTItem nbti = new NBTItem(usedItem);
`
And ever since i updated to 2.3.0, (From 2.1.1) i get the error in console with certain items... I've found the beehive and barrel to be two of the items that trigger this, but I also have an event that triggers when armor is unequipped and equipped, and it seems to throw the same error on that one.
I have now downgraded to 2.2.0 and the errors are gone. :)