MohistMC / Mohist

Minecraft Forge Hybrid server implementing the Spigot/Bukkit API, formerly known as Thermos/Cauldron/MCPC+
https://mohistmc.com
GNU General Public License v3.0
1.29k stars 210 forks source link

1.20.1 NPE InventoryMoveItemEvent #3181

Closed sanik closed 3 months ago

sanik commented 3 months ago

@Mgazul The problem is that Container itself is null and not CraftCustomInventory, so this does not fix the error...

if (container != null)

Inventory sourceInventory = InventoryOwner.getInventory(container);

If you look at CraftCustomInventory in it

public Location getLocation() { return inventory.getLocation(); } and inventory == null

Originally posted by @sanik in https://github.com/MohistMC/Mohist/issues/3152#issuecomment-2177769546

sanik commented 3 months ago

@Mgazul I don't know English well, so my explanation might be a bit unclear. In short, we need to check for null on the container itself because it is passed during the creation of CraftInventory. When getLocation is called, it turns out to be null and causes spam.

Mgazul commented 3 months ago

Please provide the error log you encountered

sanik commented 3 months ago

Please provide the error log you encountered

@Mgazul https://pastes.dev/jl4TOi1EOm