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

NPE when placing a sign with NBT data due to ItemSign#openSign not being reset in some situations

XMLWordPrintable

    • This server is running CraftBukkit version dev-Spigot-dc75aca-11c9299 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT)
    • Yes

       

      [Server thread/FATAL]: Error executing task on Server
      java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.block.entity.TileEntitySign.a(java.util.UUID)" because "tileentitysign" is null
              at net.minecraft.server.level.EntityPlayer.openSign(EntityPlayer.java:1315) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.world.item.ItemStack.placeItem(ItemStack.java:388) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.server.level.PlayerInteractManager.a(PlayerInteractManager.java:538) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1527) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.network.protocol.game.PacketPlayInUseItem.a(PacketPlayInUseItem.java:33) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.network.protocol.game.PacketPlayInUseItem.a(PacketPlayInUseItem.java:1) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:30) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.util.thread.IAsyncTaskHandler.executeTask(SourceFile:151) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.util.thread.IAsyncTaskHandler.executeNext(SourceFile:125) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.server.MinecraftServer.bf(MinecraftServer.java:1148) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.server.MinecraftServer.executeNext(MinecraftServer.java:1141) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.util.thread.IAsyncTaskHandler.awaitTasks(SourceFile:134) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.server.MinecraftServer.sleepForTick(MinecraftServer.java:1125) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1054) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[spigot-1.17.1-SNAPSHOT.jar:dev-Spigot-dc75aca-11c9299]
              at java.lang.Thread.run(Thread.java:831) [?:?]

      Reproduction steps:

      • Be in creative mode.
      • Pickup a sign block with NBT data (ctrl+middle-mouse)
      • Switch to survival mode.
      • Have a plugin on the server that cancels the BlockPlaceEvent for the player in survival mode.
      • Attempt to place the sign with NBT data. This action is cancelled by the plugin.
      • Switch back to creative mode.
      • Place the sign with NBT data at some different location. The BlockPlaceEvent for this is not cancelled by the above mentioned plugin.
      • Observe the above error in the server log.

      The issue is that for the sign placement attempt of the survival player, ItemStack#placeItem will eventually invoke ItemSign#a, which remembers the block placement location in ItemSign#openSign. But this location is never cleared during the subsequent further handling of the block placement, because the handling is prematurely aborted due to the BlockPlaceEvent being cancelled.
      For the subsequent sign placement attempt of the creative player, the ItemSign#openSign would usually not be set (because the creative mode player is able to place the sign with NBT data, which causes the sign opening to be skipped). But since ItemSign#openSign is still set to the previous location of the cancelled sign placement attempt of the survival player, and the BlockPlaceEvent for the creative player is not cancelled, the sign opening logic is triggered anyways. But since ItemSign#openSign points to a location at which no sign was actually placed, the TileEntity is not found and we get the above error.

       

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

              Created:
              Updated:
              Resolved: