Solved BlockPopulator async ?

civious

New member
Jan 11, 2024
3
0
1
Hey I have another issue with my world generator, when using BlockPopulators. When I'm reading or modifying blocks from a BlockPopulator I have either an infinite loop (for reading) or AsyncException (for modifying). The workarround I found is using a BukkitRunnable inside the BlockPopulator to get ride of the problem but it slows down significantly the process :
Java:
@Override
public void populate(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, LimitedRegion limitedRegion) {
....
        new BukkitRunnable() {
@Override
            public void run() {
for(CacheObject object : objectsCaches) {
Location location = new Location(world, object.getCoordinates().getX(), object.getCoordinates().getY(), object.getCoordinates().getZ());
                    Chest chest = (Chest) location.getBlock().getState();
                    if(object.getObjectType() == CacheObjectType.DUNGEON_CHEST) populateDungeonChest(chest);
                    ...
                }
            }
}.runTask(Ouranos.getInstance());
    }
}

protected void populateDungeonChest(Chest chest) {
chest.getBlockInventory().addItem(new ItemStack(Material.CHEST));
}

Do you have any idea of where this could come from ?
Thanks

EDIT : I found the problem, just used Location instead of Limited region with the new API
 
Last edited: