Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7894

NRE when sending tile entity update (world is null)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version dev-Spigot-5a6439b-8ee6fd1 (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
    • Yes

      Plugin code to send a block update for a Sign block state retrieved from the world:

      player.sendBlockUpdate(sign.getLocation(), sign);

      Error (probably due to the world being null in the TileEntity created for the update packet):

      [23:44:22] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to InSigns v2.9.2
      org.bukkit.event.EventException: null
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:601) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:588) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.craftbukkit.v1_21_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:578) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.server.level.PlayerInteractManager.a(PlayerInteractManager.java:504) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1585) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.protocol.game.PacketPlayInUseItem.a(PacketPlayInUseItem.java:44) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.protocol.game.PacketPlayInUseItem.a(PacketPlayInUseItem.java:11) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$ensureRunningOnSameThread$0(PlayerConnectionUtils.java:35) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:162) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1270) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:203) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.util.thread.IAsyncTaskHandler.B(SourceFile:136) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.server.MinecraftServer.bv(MinecraftServer.java:1249) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.server.MinecraftServer.B(MinecraftServer.java:1242) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.util.thread.IAsyncTaskHandler.b(SourceFile:145) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1207) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.server.MinecraftServer.v_(MinecraftServer.java:1214) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1078) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
            at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]

      Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.World.H_()" because the return value of "net.minecraft.world.level.block.entity.TileEntity.i()" is null
              at net.minecraft.network.protocol.game.PacketPlayOutTileEntityData.a(SourceFile:30) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.protocol.game.PacketPlayOutTileEntityData.a(SourceFile:35) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at org.bukkit.craftbukkit.v1_21_R1.block.CraftBlockEntityState.getUpdatePacket(CraftBlockEntityState.java:160) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer.sendBlockUpdate(CraftPlayer.java:827) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at de.blablubbabc.insigns.Utils.sendSignUpdate(Utils.java:51) ~[?:?]
              at de.blablubbabc.insigns.PlayerListener.onPlayerInteract(PlayerListener.java:42) ~[?:?]
              at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
              at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
              ... 23 more

      Ideally, (not the issue here) the update packet should probably also work for non-placed block state, since the block state simply represents the data to send. So maye a solution could be to manually pass the registry access to "PacketPlayOutTileEntityData.create" (in CraftBlockEntityState.getUpdatePacket), instead of this method trying to retrieve it from the TileEntity's world.

            Unassigned Unassigned
            blablubbabc blablubbabc
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: