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

Structure Block setUsageMode encouters NullpointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • git-Spigot-05bb8bc-4b34472 (MC: 1.15.1) (Implementing API version 1.15.1-R0.1-SNAPSHOT)
    • Yes

      When trying to change the usage mode of a structure block, the server encounters the following NullpointerException:

      org.bukkit.event.EventException: null
      	at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:529) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:514) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at org.bukkit.craftbukkit.v1_15_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:441) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.PlayerInteractManager.a(PlayerInteractManager.java:441) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:1250) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:27) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:1) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18) [spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(SourceFile:144) [spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) [spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeNext(SourceFile:118) [spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.MinecraftServer.aZ(MinecraftServer.java:917) [spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.MinecraftServer.executeNext(MinecraftServer.java:910) [spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.awaitTasks(SourceFile:127) [spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.MinecraftServer.sleepForTick(MinecraftServer.java:894) [spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:827) [spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at java.lang.Thread.run(Thread.java:830) [?:?]
      Caused by: java.lang.NullPointerException
      	at net.minecraft.server.v1_15_R1.TileEntityStructure.setUsageMode(SourceFile:231) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at org.bukkit.craftbukkit.v1_15_R1.block.CraftStructureBlock.setUsageMode(CraftStructureBlock.java:108) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	at io.github.eiskasten.skyex.snbt.StructureKt.placeStructure(structure.kt:73) ~[?:?]
      	at io.github.eiskasten.skyex.NetherCreator.onMiddle(nether.kt:90) ~[?:?]
      	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
      	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
      	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
      	at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
      	at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[spigot-1.15.1.jar:git-Spigot-05bb8bc-4b34472]
      	... 19 more
      

      This is the (Kotlin) code, I used:

      location.block.type = Material.STRUCTURE_BLOCK //line 70
          val structureBlock = location.block.state as org.bukkit.block.Structure //line 71
          structureBlock.structureName = name //line 72
          structureBlock.usageMode = UsageMode.LOAD //line 73
          location.clone().add(0.toDouble(), (-1).toDouble(), 0.toDouble()).block.type = Material.REDSTONE_BLOCK //line 74
      

      Note, that setting the structure's name works flawlessly, only setting the usage mode makes troubles.

            Unassigned Unassigned
            Eiskasten Eiskasten
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: