Block Drops (JEI Addon)

Block Drops (JEI Addon)

12M Downloads

NPE due to missing chunk in fake world when calling block.getDrops

bdew opened this issue ยท 3 comments

commented

https://github.com/MrRiegel/BlockDrops/blob/1.10/src/main/java/mrriegel/blockdrops/Plugin.java#L109

When your plugin calls block.getDrops it passes a fake world object. Blocks that have drops that depend on their tile entity will likely call world.getTileEntity which will ultimately throw an NPE since the chunk doesn't exist in the fake world.

You should probably either wrap that call in a try/catch (like you do with fireBlockHarvesting later) or emulate a chunk there in some way.

Example traceback:

[Client thread/WARN] [bdlib/blockdrops]: Error retrieving TE java.lang.NullPointerException
	at net.minecraft.world.World.func_72964_e(World.java:303) ~[aid.class:?]
	at net.minecraft.world.World.func_175726_f(World.java:298) ~[aid.class:?]
	at net.minecraft.world.World.func_175625_s(World.java:2402) ~[aid.class:?]
	at net.bdew.lib.block.HasTE$$anonfun$1.apply(HasTE.scala:59) ~[HasTE$$anonfun$1.class:?]
	at net.bdew.lib.block.HasTE$$anonfun$1.apply(HasTE.scala:59) ~[HasTE$$anonfun$1.class:?]
	at scala.util.Try$.apply(Try.scala:191) ~[Try$.class:?]
	at net.bdew.lib.block.HasTE$class.getTE(HasTE.scala:59) [HasTE$class.class:?]
	at net.bdew.gendustry.machines.apiary.BlockApiary$.getTE(BlockApiary.scala:24) [BlockApiary$.class:?]
	at net.bdew.lib.block.BlockKeepData$class.getSavedBlock(KeepData.scala:38) [BlockKeepData$class.class:?]
	at net.bdew.gendustry.machines.apiary.BlockApiary$.getSavedBlock(BlockApiary.scala:24) [BlockApiary$.class:?]
	at net.bdew.lib.block.BlockKeepData$class.getDrops(KeepData.scala:44) [BlockKeepData$class.class:?]
	at net.bdew.gendustry.machines.apiary.BlockApiary$.getDrops(BlockApiary.scala:24) [BlockApiary$.class:?]
	at net.bdew.gendustry.machines.apiary.BlockApiary$.getDrops(BlockApiary.scala:24) [BlockApiary$.class:?]
	at mrriegel.blockdrops.Plugin.getList(Plugin.java:109) [Plugin.class:?]
	at mrriegel.blockdrops.Plugin.getRecipes(Plugin.java:85) [Plugin.class:?]
	at mrriegel.blockdrops.BlockDrops.postInit(BlockDrops.java:128) [BlockDrops.class:?]
commented

Actually getList() is called in a try catch block.
https://github.com/MrRiegel/BlockDrops/blob/1.10/src/main/java/mrriegel/blockdrops/Plugin.java#L85
So it should leave the loop after first try.
I don't know why it spams that amount of logs

commented

I'm adding a workaround in my code - i'll check if the passed world object has a null chunkProvider i'll skip trying get the TE to modify the dropped itemstack. I guess this can be closed.

commented

Dang, you're right, the exception is logged and suppressed in my code, i've added that some time ago to deal with some vanilla bullshit (CME's when getTileEntity is called from rendering threads). So it never leaves the loop and keeps calling it generating a ton of log spam.