breakinblocks / Plonk

A Minecraft mod that lets you place items down anywhere https://www.curseforge.com/minecraft/mc-mods/plonk https://modrinth.com/mod/plonk
MIT License
3 stars 4 forks source link

Enderman crashes server when teleporting to plonk items #8

Closed Khazoda closed 3 years ago

Khazoda commented 3 years ago

crash-2021-01-03_00.50.56-server.txt crash-2021-01-03_00.59.49-server.txt crash-2021-01-03_00.40.43-server.txt

This isn't thoroughly tested, but I had some plonk items on my wall at the exact coordinates that the crash reports mention the enderman throwing the nullpointer was at. I think he may have collided/tried to pick up the plonk block or something? Regardless, the only fix was killing all enderman from the console and then logging in, otherwise upon chunkload the server would crash again.

BlueAgent commented 3 years ago

Hmm, this is definitely a confusing one. The enderman is calling getShape on the block:

java.lang.NullPointerException: Ticking entity
    at java.util.Objects.requireNonNull(Objects.java:203) ~[?:1.8.0_201] {}
    at com.breakinblocks.plonk.common.block.BlockPlacedItems.getPickedSlot(BlockPlacedItems.java:179) ~[plonk:?] {re:classloading}
    at com.breakinblocks.plonk.common.block.BlockPlacedItems.getShape(BlockPlacedItems.java:103) ~[plonk:?] {re:classloading}
    at net.minecraft.block.AbstractBlock$AbstractBlockState.getShape(AbstractBlock.java:535) ~[?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:losttrinkets.mixins.json:AbstractBlockStateMixin,pl:mixin:APP:immersiveengineering.mixins.json:coremods.AbstractBlockStateMixin,pl:mixin:A,pl:runtimedistcleaner:A}
    at net.minecraft.util.math.RayTraceContext$BlockMode.get(RayTraceContext.java:57) ~[?:?] {re:classloading}
    at net.minecraft.util.math.RayTraceContext.getBlockShape(RayTraceContext.java:38) ~[?:?] {re:classloading}
    at net.minecraft.world.IBlockReader.lambda$rayTraceBlocks$0(IBlockReader.java:50) ~[?:?] {re:mixin,re:classloading}
    at net.minecraft.world.IBlockReader.doRayTrace(IBlockReader.java:142) ~[?:?] {re:mixin,re:classloading}
    at net.minecraft.world.IBlockReader.rayTraceBlocks(IBlockReader.java:45) ~[?:?] {re:mixin,re:classloading}
    at net.minecraft.entity.monster.EndermanEntity$TakeBlockGoal.tick(EndermanEntity.java:523) ~[?:?] {re:mixin,re:classloading,pl:mixin:APP:assets/botania/botania.mixins.json:MixinEndermanPickupBlock,pl:mixin:A}
    at net.minecraft.entity.ai.goal.PrioritizedGoal.tick(SourceFile:55) ~[?:?] {re:classloading}
    ...

There's a null check there to confirm that the tile entity is not null at that position, which is what is causing the crash. getShape, which uses getPickedSlot, also confirms that the tile entity is null before it calls getPickedSlot. So the tile must have been removed from the world between getShape being called and getPickedSlot This might take a bit... I'm thinking I could also pass the tile entity reference to getPickedSlot directly so that it can't be turned null. Also probably making sure that the entity is a player too. Will post back once I get to take a closer look.

BlueAgent commented 3 years ago

Okay, just released a fix with Plonk v9.0.6. Let me know if works out and reopen if it's still broken. :)

Khazoda commented 3 years ago

Will test the new build on my server and get back to you here in a few days 😇thanks for the hard work!