Infinite loop when calling Block.SetType() in a BlockPopulator?

My populator can read the vanilla blocks, but attempting to change anything at all via Block.setType(Material) seems to be causing an infinite loop (see stack below), freezing my server. Is there a safe approach to set blocks from a BlockPopulator?

public class SnowPopulator extends BlockPopulator {
    
    public void populate(World world, Random random, Chunk chunk)
    {
        for (int x = 0; x < 16; x++)
        {
			for (int z = 0; z < 16; z++)
			{
				int y = world.getHighestBlockYAt(chunk.getX() * 16 + x, chunk.getZ() * 16 + z);
				Block block = world.getBlockAt(chunk.getX() * 16 + x, y - 1, chunk.getZ() * 16 + z);
				
				//this line breaks me..  with it commented, the server runs, but the populator has no effect
				world.getBlockAt(chunk.getX() * 16 + x, y + 1, chunk.getZ() * 16 + z).setType(Material.SNOW);
			}
        }
    }
}

[10:27:51] [Paper Watchdog Thread/ERROR]: — DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - git-Paper-192 (MC: 1.14.4) —
[10:27:51] [Paper Watchdog Thread/ERROR]: The server has not responded for 15 seconds! Creating thread dump
[10:27:51] [Paper Watchdog Thread/ERROR]: ------------------------------
[10:27:51] [Paper Watchdog Thread/ERROR]: Server thread dump (Look for plugins here before reporting to Paper!):
[10:27:51] [Paper Watchdog Thread/ERROR]: The server is waiting on these chunks: [[( -161,-498) in ‘sampleWorld’], [( -162,-498) in ‘sampleWorld’], [( -162,-499) in ‘sampleWorld’], [( -163,-499) in ‘sampleWorld’], [( -164,-499) in ‘sampleWorld’], [( -164,-500) in ‘sampleWorld’], [( -163,-500) in ‘sampleWorld’], [( -162,-500) in ‘sampleWorld’], [( -162,-501) in ‘sampleWorld’], [( -162,-502) in ‘sampleWorld’], [( -162,-503) in ‘sampleWorld’], [( -162,-504) in ‘sampleWorld’], [( -161,-504) in ‘sampleWorld’], [( -161,-505) in ‘sampleWorld’], [( -160,-505) in ‘sampleWorld’], [( -160,-506) in ‘sampleWorld’], [( -132,-514) in ‘sampleWorld’]]
[10:27:51] [Paper Watchdog Thread/ERROR]: ------------------------------
[10:27:51] [Paper Watchdog Thread/ERROR]: Current Thread: Server thread
[10:27:51] [Paper Watchdog Thread/ERROR]: PID: 24 | Suspended: false | Native: false | State: TIMED_WAITING
[10:27:51] [Paper Watchdog Thread/ERROR]: Stack:
[10:27:51] [Paper Watchdog Thread/ERROR]: sun.misc.Unsafe.park(Native Method)
[10:27:51] [Paper Watchdog Thread/ERROR]: java.util.concurrent.locks.LockSupport.parkNanos(Unknown Source)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.IAsyncTaskHandler.bi(IAsyncTaskHandler.java:131)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:120)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:285)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.ChunkProviderServer$a.executeNext(ChunkProviderServer.java:800)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.World.getChunkAt(World.java:373)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.IWorldReader.getChunkAt(IWorldReader.java:80)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:285)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.World.getChunkAt(World.java:334)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.World.getChunkAt(World.java:373)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.World.getType(World.java:726)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.IWorldReader.getChunkAt(IWorldReader.java:80)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.Block.a(Block.java:141)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.World.getChunkAt(World.java:334)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.IBlockData.a(IBlockData.java:190)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.World.getType(World.java:726)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.World.notifyAndUpdatePhysics(World.java:522)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.Block.a(Block.java:141)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.World.setTypeAndData(World.java:473)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.IBlockData.a(IBlockData.java:190)
[10:27:51] [Paper Watchdog Thread/ERROR]: org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock.setTypeAndData(CraftBlock.java:193)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.World.notifyAndUpdatePhysics(World.java:522)
[10:27:51] [Paper Watchdog Thread/ERROR]: org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock.setBlockData(CraftBlock.java:178)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.World.setTypeAndData(World.java:473)
[10:27:51] [Paper Watchdog Thread/ERROR]: org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock.setType(CraftBlock.java:167)
[10:27:51] [Paper Watchdog Thread/ERROR]: org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock.setTypeAndData(CraftBlock.java:193)
[10:27:51] [Paper Watchdog Thread/ERROR]: org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock.setType(CraftBlock.java:161)
[10:27:51] [Paper Watchdog Thread/ERROR]: org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock.setBlockData(CraftBlock.java:178)
[10:27:51] [Paper Watchdog Thread/ERROR]: me.ryanhamshire.BigScaryIslands.SnowPopulator.populate(SnowPopulator.java:29)
[10:27:51] [Paper Watchdog Thread/ERROR]: org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock.setType(CraftBlock.java:167)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.Chunk.loadCallback(Chunk.java:660)
[10:27:51] [Paper Watchdog Thread/ERROR]: org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock.setType(CraftBlock.java:161)
[10:27:51] [Paper Watchdog Thread/ERROR]: net.minecraft.server.v1_14_R1.PlayerChunk.lambda$null$7(PlayerChunk.java:415)
[10:27:51] [Paper Watchdog Thread/ERROR]: me.ryanhamshire.BigScaryIslands.SnowPopulator.populate(SnowPopulator.java:29)

Hi buddy, sadly you can’t do anything like that without manual loop.

Regards,
Seder Smith

setType(X.., false), otherwise physics updates will be ran across neighbouring blocks/chunks

1 Like