Posted September 27, 20195 yr I would like to have a nether-like dimension with dirt, which on top turns to grass. Obviously I can't use the vanilla `topBlock`, because the nether has multiple layers atop eachother. What method would I write this in? I have tried just looping through all the blocks in the chunk, and checking if the above block is air, but this is painfully inefficient and causes cascading world generation. Is there a better way to do this? It doesnt appear to work in `populate` either.
September 27, 20195 yr Author private void replaceTopBlocks(int chunkX, int chunkZ) { int x = (chunkX * 16) + 8; int z = (chunkZ * 16) + 8; for (int a = x; a < x + 16; a++) { for (int b = 0; b < world.getHeight(); b++) { for (int c = z; c < z + 16; c++) { replaceTopBlock(a, b, c); } } } } private void replaceTopBlock(int x, int y, int z) { BlockPos position = new BlockPos(x, y, z); if (topBlockReplacements.containsKey(world.getBlockState(position)) && world.getBlockState(position.up()).getBlock() == Blocks.AIR) { world.setBlockState(position, topBlockReplacements.get(world.getBlockState(position))); } } This is the code I am using, topBlockReplacments is a HashMap of two IBlockStates; the first being the original block, second being the block to replace it with.
September 27, 20195 yr Author You'd probably want to replace the air check with something else, because it means it wont replace the block under tallgrass and such.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.