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

generateTree() with Consumer or Predicate is broken

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version 3627-Spigot-d90018e-c810c3e (MC: 1.19.3) (Implementing API version 1.19.3-R0.1-SNAPSHOT)
    • Yes

      I am working on a plugin where I want to cancel the placement of certain block while generating a tree. For this I would like to use the generateTree() method with a Predicate as argument, but this method appears to be broken, as well as the version that received a Consumer as argument.

      It works as expected on spigot 1.18.2, but seems to be broken in 1.19.2 and 1.19.3.

      I am using the following  code in my plugin code (simplified):

          @EventHandler
          public void onBlockInteract(PlayerInteractEvent e) {
              var RANDOM = new Random();
              var b = e.getClickedBlock();
              if (b == null) return;
              b.getWorld().generateTree(b.getLocation().add(0, 1, 0), RANDOM, TreeType.BIRCH, (s) -> {
                  return true;
              });
          } 

      When generating a PlayerInteractEvent by clicking a block, the server throws an error:

      [20:52:10] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to Testplugin v0.1
      org.bukkit.event.EventException: null
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-api-1.19.3-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-api-1.19.3-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) ~[spigot-api-1.19.3-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576) ~[spigot-api-1.19.3-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.craftbukkit.v1_19_R2.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:511) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.server.level.PlayerInteractManager.a(PlayerInteractManager.java:495) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1645) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.network.protocol.game.PacketPlayInUseItem.a(PacketPlayInUseItem.java:37) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.network.protocol.game.PacketPlayInUseItem.a(PacketPlayInUseItem.java:1) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:31) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:156) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1154) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:1) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.util.thread.IAsyncTaskHandler.x(SourceFile:130) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.server.MinecraftServer.bh(MinecraftServer.java:1133) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1126) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.util.thread.IAsyncTaskHandler.c(SourceFile:139) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.server.MinecraftServer.i_(MinecraftServer.java:1110) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1021) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:301) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at java.lang.Thread.run(Thread.java:833) ~[?:?]
      Caused by: java.lang.UnsupportedOperationException: Not supported yet.
              at org.bukkit.craftbukkit.v1_19_R2.util.DummyGeneratorAccess.s(DummyGeneratorAccess.java:184) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at org.bukkit.craftbukkit.v1_19_R2.CraftRegionAccessor.generateTree(CraftRegionAccessor.java:405) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at org.bukkit.craftbukkit.v1_19_R2.CraftRegionAccessor.generateTree(CraftRegionAccessor.java:321) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at org.bukkit.craftbukkit.v1_19_R2.CraftRegionAccessor.generateTree(CraftRegionAccessor.java:311) ~[spigot-1.19.3-R0.1-SNAPSHOT.jar:3627-Spigot-d90018e-c810c3e]
              at me.lennart99.TestPlugin.onBlockInteract(TestPlugin.java:24) ~[?:?]
              at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
              at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
              at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
              at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.19.3-R0.1-SNAPSHOT.jar:?]
              ... 22 more 

      The same happens when using a Consumer instead of a Predicate (removing the return statement in the lambda).

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

              Created:
              Updated:
              Resolved: