Schleim_time Posted May 16, 2019 Posted May 16, 2019 @Override public void onContainerClosed(EntityPlayer playerIn) { for(int x = 0; x < 9; x++) { if(tyleentity.getStackInSlot(x)!=null||tyleentity.getStackInSlot(x)!= new ItemStack(Items.AIR).EMPTY) { itemlist.add(tyleentity.getStackInSlot(x)); } } if(!itemlist.isEmpty()) { for(ItemStack item : itemlist) { playerIn.inventory.addItemStackToInventory(item); } } tyleentity.clear(); itemlist.clear(); } i want to let the player get the items back on closing the table but for some reson its crashes because of an null pointer on the line i marked, idk why because i already asked if it is null bevore Quote
loordgek Posted May 16, 2019 Posted May 16, 2019 (edited) tyleentity.getStackInSlot(x)!=null||tyleentity.getStackInSlot(x)!= new ItemStack(Items.AIR).EMPTY what is this, use stack.isEmpty and plz format your code it is really hard to read did you ever set itemlist ? Edited May 16, 2019 by loordgek Quote
Schleim_time Posted May 16, 2019 Author Posted May 16, 2019 oh im sorry i solved it for myself i did up in my class something very stupid XD private List blala; Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.