NPE in the fill bucket event
Eufranio opened this issue ยท 1 comments
Sometimes I get this NPE on my server, happened twice today:
Caused by: java.lang.NullPointerException
at com.minecolonies.coremod.permissions.ColonyPermissionEventHandler.on(ColonyPermissionEventHandler.java:410) ~[ColonyPermissionEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_450_ColonyPermissionEventHandler_on_FillBucketEvent.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:651) ~[EventBus.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:589) ~[EventBus.class:?]
at net.minecraftforge.event.ForgeEventFactory.onBucketUse(ForgeEventFactory.java:434) ~[ForgeEventFactory.class:?]
at net.minecraft.item.ItemBucket.func_77659_a(ItemBucket.java:43) ~[ahi.class:?]
at net.minecraft.item.ItemStack.func_77957_a(ItemStack.java:217) ~[aip.class:?]
at net.minecraft.server.management.PlayerInteractionManager.func_187250_a(PlayerInteractionManager.java:358) ~[or.class:?]
at net.minecraft.network.NetHandlerPlayServer.func_147346_a(NetHandlerPlayServer.java:763) ~[pa.class:?]
at net.minecraft.network.play.client.CPacketPlayerTryUseItem.func_148833_a(SourceFile:32) ~[mb.class:?]
at net.minecraft.network.play.client.CPacketPlayerTryUseItem.func_148833_a(SourceFile:9) ~[mb.class:?]
at org.spongepowered.common.network.PacketUtil.onProcessPacket(PacketUtil.java:149) ~[PacketUtil.class:1.12.2-2586-7.1.0-BETA-2884]
at net.minecraft.network.PacketThreadUtil$1.redirect$onProcessPacket$zkp000(SourceFile:539) ~[hv$1.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) ~[hv$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_151]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_151]
at net.minecraft.util.Util.func_181617_a(SourceFile:46) ~[h.class:?]
... 7 more
Well, the NPE is durring an attempt to fill a bucket.
checkEventCancelation(Action.FILL_BUCKET, event.getEntityPlayer(), event.getEntityPlayer().getEntityWorld(), event, event.getTarget().getBlockPos());
It's ambiguous whether the error was due to a missing player for that event or due to a missing target for that event. Probably it just needs a check to make sure that the target and player isn't null before attempting to cancel the event (filling a bucket is restricted inside of a colony)
Checking the event setup reveals that player cannot be null, but target can. Creating a fix.
public static ActionResult<ItemStack> onBucketUse(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull ItemStack stack, @Nullable RayTraceResult target)