-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major
-
None
-
Affects Version/s: None
-
None
-
This server is running CraftBukkit version 4468-Spigot-aa90801-9b5a525 (MC: 1.21.5) (Implementing API version 1.21.5-R0.1-SNAPSHOT)
-
Yes
Trying to add bees to beehives during BlockPopulator.populate with limitedRegion (with the below code) leads to an IllegalStateException as Beehive.addEntity tries to call EntityRemoveEvent
@Override public void populate(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, LimitedRegion lr) { int targetX = chunkX*16 - 8; int targetZ = chunkZ*16 - 8; assert lr.isInRegion(targetX, 51, targetZ); lr.setType(targetX,51,targetZ,Material.BEE_NEST); Beehive bukkitBeehive = (Beehive) lr.getBlockState(targetX, 51, targetZ); Bee bee = (Bee) lr.createEntity(new Location(bukkitBeehive.getWorld(),targetX, 55, targetZ), Bee.class); bukkitBeehive.addEntity(bee); }
Exception:
java.lang.IllegalStateException: EntityRemoveEvent cannot be triggered asynchronously from another thread. at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:584) at org.bukkit.craftbukkit.v1_21_R4.event.CraftEventFactory.callEntityRemoveEvent(CraftEventFactory.java:2001) at net.minecraft.world.entity.Entity.setRemoved(Entity.java:4336) at net.minecraft.world.entity.Entity.remove(Entity.java:518) at net.minecraft.world.entity.EntityLiving.remove(EntityLiving.java:768) at net.minecraft.world.entity.Entity.discard(Entity.java:484) at net.minecraft.world.level.block.entity.TileEntityBeehive.a(TileEntityBeehive.java:176) at org.bukkit.craftbukkit.v1_21_R4.block.CraftBeehive.addEntity(CraftBeehive.java:86) at org.bukkit.craftbukkit.v1_21_R4.block.CraftBeehive.addEntity(CraftBeehive.java:17) at org.worldgentutorial.main.WorldGenTutorialBlockPopulator.populate(WorldGenTutorialBlockPopulator.java:27) at net.minecraft.world.level.chunk.ChunkGenerator.applyBiomeDecoration(ChunkGenerator.java:431) at org.bukkit.craftbukkit.v1_21_R4.generator.CustomChunkGenerator.a(CustomChunkGenerator.java:291) at net.minecraft.world.level.chunk.status.ChunkStatusTasks.i(ChunkStatusTasks.java:113) at net.minecraft.world.level.chunk.status.ChunkStep.a(SourceFile:33) at net.minecraft.server.level.PlayerChunkMap.a(PlayerChunkMap.java:715) at net.minecraft.server.level.GenerationChunkHolder.a(SourceFile:101) at net.minecraft.server.level.ChunkGenerationTask.a(SourceFile:148) at net.minecraft.server.level.ChunkGenerationTask.a(SourceFile:125) at net.minecraft.server.level.ChunkGenerationTask.d(SourceFile:76) at net.minecraft.server.level.ChunkGenerationTask.a(SourceFile:61) at net.minecraft.server.level.PlayerChunkMap.lambda$runGenerationTask$22(PlayerChunkMap.java:751) at net.minecraft.server.level.ChunkTaskDispatcher.a(SourceFile:88) at net.minecraft.util.thread.TaskScheduler.a(SourceFile:21) at net.minecraft.SystemUtils.a(SourceFile:297) at net.minecraft.util.thread.AbstractConsecutiveExecutor.f(SourceFile:50) at net.minecraft.util.thread.AbstractConsecutiveExecutor.run(SourceFile:62) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Attached is the worldgen plugin (source and built jar) which triggers this with that block populator code. If all is well, it should spawn beehives with bees in them.
The follow bukkit.yml entry should enable the block populator
worlds: world: generator: WorldGenTutorial