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

When creating chunk data, setting a block to Material.CHEST results in the server crashing.

XMLWordPrintable

    • This server is running CraftBukkit version 3158-Spigot-f773da8-470050a (MC: 1.17) (Implementing API version 1.17-R0.1-SNAPSHOT)
    • Yes

      When one is taking advantage of the Spigot/Bukkit API to use a custom world generator, you need to create a ChunkGenerator with an @override method generateChunkData that returns an instance of ChunkData however you want it to be.

      If one tries to set a block inside the ChunkData instance to that of a block with an inventory associated with it such as a chest, ender chest, shulker box etc, by something along the lines of chunkData.setBlock(x, y, z, Material.CHEST) the following error is produced:

       

      java.lang.ClassCastException: class net.minecraft.world.level.block.state.IBlockData cannot be cast to class net.minecraft.world.level.block.ITileEntity (net.minecraft.world.level.block.state.IBlockData and net.minecraft.world.level.block.ITileEntity are in unnamed module of loader 'app')
      	at org.bukkit.craftbukkit.v1_17_R1.generator.CustomChunkGenerator.buildBase(CustomChunkGenerator.java:157)
      	at net.minecraft.world.level.chunk.ChunkStatus.lambda$6(ChunkStatus.java:77)
      	at net.minecraft.world.level.chunk.ChunkStatus$d.doWork(ChunkStatus.java:265)
      	at net.minecraft.world.level.chunk.ChunkStatus.a(ChunkStatus.java:212)
      	at net.minecraft.server.level.PlayerChunkMap.lambda$25(PlayerChunkMap.java:611)
      	at com.mojang.datafixers.util.Either$Left.map(Either.java:38)
      	at net.minecraft.server.level.PlayerChunkMap.lambda$24(PlayerChunkMap.java:609)
      	at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1146)
      	at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:478)
      	at net.minecraft.server.level.ChunkTaskQueueSorter.b(SourceFile:58)
      	at net.minecraft.util.thread.ThreadedMailbox.f(SourceFile:91)
      	at net.minecraft.util.thread.ThreadedMailbox.a(SourceFile:131)
      	at net.minecraft.util.thread.ThreadedMailbox.run(SourceFile:99)
      	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1434)
      	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:295)
      	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
      	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
      	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
      	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
      A detailed walkthrough of the error, its code path and all known details is as follows:
      ----------------------------------------------------------------------------------------- Head --
      Thread: Server thread
      Stacktrace:
      	at org.bukkit.craftbukkit.v1_17_R1.generator.CustomChunkGenerator.buildBase(CustomChunkGenerator.java:157)
      	at net.minecraft.world.level.chunk.ChunkStatus.lambda$6(ChunkStatus.java:77)
      	at net.minecraft.world.level.chunk.ChunkStatus$d.doWork(ChunkStatus.java:265)
      	at net.minecraft.world.level.chunk.ChunkStatus.a(ChunkStatus.java:212)-- Chunk to be generated --
      Details:
      	Location: 2,2
      	Position hash: 8589934594
      	Generator: org.bukkit.craftbukkit.v1_17_R1.generator.CustomChunkGenerator@4587463e
      Stacktrace:
      	at net.minecraft.server.level.PlayerChunkMap.lambda$25(PlayerChunkMap.java:611)
      	at com.mojang.datafixers.util.Either$Left.map(Either.java:38)
      	at net.minecraft.server.level.PlayerChunkMap.lambda$24(PlayerChunkMap.java:609)
      	at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1146)
      	at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:478)
      	at net.minecraft.server.level.ChunkTaskQueueSorter.b(SourceFile:58)
      	at net.minecraft.util.thread.ThreadedMailbox.f(SourceFile:91)
      	at net.minecraft.util.thread.ThreadedMailbox.a(SourceFile:131)
      	at net.minecraft.util.thread.ThreadedMailbox.run(SourceFile:99)
      

      This error does not occur on any other Minecraft versions that I have tested, nor does it occur for any other materials without inventories that I have tested. It seems to be an inventory-block related problem.

      Apologies if this isn't a bug, I did search through all the changes between 1.16.5 and 1.17 that could explain this but I could not find anything.

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

              Created:
              Updated:
              Resolved: