Posted January 5, 201510 yr I'm attempting to work with world generation, currently I am simply doing nothing but generating a layer of bedrock at y=1 and a layer of dirt at y=63. Looking below, it takes almost a full minute to generate the spawn area - I must be doing something wrong for that to be the case when it's just 32 blocks per chunk, where as it only takes 10 seconds for the default world generator to do it. [21:10:40] [server thread/INFO]: Preparing start region for level 0 [21:10:42] [server thread/INFO]: Preparing spawn area: 13% [21:10:43] [server thread/INFO]: Preparing spawn area: 14% [21:10:44] [server thread/INFO]: Preparing spawn area: 16% [21:10:45] [server thread/INFO]: Preparing spawn area: 18% [21:10:46] [server thread/INFO]: Preparing spawn area: 19% [21:10:47] [server thread/INFO]: Preparing spawn area: 21% [21:10:48] [server thread/INFO]: Preparing spawn area: 23% [21:10:49] [server thread/INFO]: Preparing spawn area: 25% [21:10:50] [server thread/INFO]: Preparing spawn area: 26% [21:10:51] [server thread/INFO]: Preparing spawn area: 28% [21:10:53] [server thread/INFO]: Preparing spawn area: 29% [21:10:54] [server thread/INFO]: Preparing spawn area: 31% [21:10:55] [server thread/INFO]: Preparing spawn area: 33% [21:10:56] [server thread/INFO]: Preparing spawn area: 35% [21:10:57] [server thread/INFO]: Preparing spawn area: 37% [21:10:58] [server thread/INFO]: Preparing spawn area: 38% [21:10:59] [server thread/INFO]: Preparing spawn area: 40% [21:11:00] [server thread/INFO]: Preparing spawn area: 42% [21:11:01] [server thread/INFO]: Preparing spawn area: 43% [21:11:03] [server thread/INFO]: Preparing spawn area: 46% [21:11:04] [server thread/INFO]: Preparing spawn area: 48% [21:11:05] [server thread/INFO]: Preparing spawn area: 49% [21:11:06] [server thread/INFO]: Preparing spawn area: 50% [21:11:07] [server thread/INFO]: Preparing spawn area: 52% [21:11:08] [server thread/INFO]: Preparing spawn area: 53% [21:11:09] [server thread/INFO]: Preparing spawn area: 55% [21:11:10] [server thread/INFO]: Preparing spawn area: 56% [21:11:12] [server thread/INFO]: Preparing spawn area: 58% [21:11:13] [server thread/INFO]: Preparing spawn area: 59% [21:11:14] [server thread/INFO]: Preparing spawn area: 61% [21:11:15] [server thread/INFO]: Preparing spawn area: 62% [21:11:16] [server thread/INFO]: Preparing spawn area: 63% [21:11:17] [server thread/INFO]: Preparing spawn area: 65% [21:11:18] [server thread/INFO]: Preparing spawn area: 66% [21:11:19] [server thread/INFO]: Preparing spawn area: 68% [21:11:20] [server thread/INFO]: Preparing spawn area: 70% [21:11:21] [server thread/INFO]: Preparing spawn area: 71% [21:11:22] [server thread/INFO]: Preparing spawn area: 73% [21:11:23] [server thread/INFO]: Preparing spawn area: 74% [21:11:25] [server thread/INFO]: Preparing spawn area: 76% [21:11:26] [server thread/INFO]: Preparing spawn area: 78% [21:11:27] [server thread/INFO]: Preparing spawn area: 79% [21:11:28] [server thread/INFO]: Preparing spawn area: 81% [21:11:29] [server thread/INFO]: Preparing spawn area: 82% [21:11:30] [server thread/INFO]: Preparing spawn area: 83% [21:11:31] [server thread/INFO]: Preparing spawn area: 86% [21:11:32] [server thread/INFO]: Preparing spawn area: 87% [21:11:33] [server thread/INFO]: Preparing spawn area: 89% [21:11:34] [server thread/INFO]: Preparing spawn area: 90% [21:11:35] [server thread/INFO]: Preparing spawn area: 92% [21:11:36] [server thread/INFO]: Preparing spawn area: 94% [21:11:37] [server thread/INFO]: Preparing spawn area: 96% [21:11:38] [server thread/INFO]: Preparing spawn area: 98% [21:11:39] [server thread/INFO]: Changing view distance to 12, from 10 The default generation is shown below: [21:14:32] [server thread/INFO]: Preparing start region for level 0 [21:14:33] [server thread/INFO]: Preparing spawn area: 6% [21:14:34] [server thread/INFO]: Preparing spawn area: 16% [21:14:35] [server thread/INFO]: Preparing spawn area: 27% [21:14:36] [server thread/INFO]: Preparing spawn area: 40% [21:14:37] [server thread/INFO]: Preparing spawn area: 52% [21:14:38] [server thread/INFO]: Preparing spawn area: 64% [21:14:39] [server thread/INFO]: Preparing spawn area: 77% [21:14:40] [server thread/INFO]: Preparing spawn area: 89% [21:14:41] [server thread/INFO]: Preparing spawn area: 98% [21:14:42] [server thread/INFO]: Changing view distance to 12, from 10 My code is as follows: The world type: public class TestWorldType extends WorldType implements ICustomWorldGenerator { public TestWorldType() { super("Fantasy"); } @Override public WorldChunkManager getChunkManager(World world) { return new TestWorldChunkManager(world); } @Override public IChunkProvider getChunkGenerator(World world, String generatorOptions) { //creates the terrain return new TestWorldChunkProvider(world); } @Override public int getMinimumSpawnHeight(World world) { return 64; } @Override public double getHorizon(World world) { return 63; } @Override public double voidFadeMagnitude() { return 0D; } } The chunk manager: public class TestWorldChunkManager extends WorldChunkManager implements ICustomChunkManager { protected World world; protected List biomesToSpawnIn; public TestWorldChunkManager(World world) { biomesToSpawnIn = new ArrayList(); biomesToSpawnIn.add(BiomeGenBase.plains); } @Override public List getBiomesToSpawnIn() { return biomesToSpawnIn; } public BiomeGenBase[] getBiomeGenAt(BiomeGenBase[] listToReuse, int xPos, int zPos, int chunkWidth, int chunkLength, boolean cacheFlag) { //Looks for all the biomes inside a chunk. BiomeGenBase[] biomes = new BiomeGenBase[chunkWidth * chunkLength]; for (int i = 0; i < biomes.length; i++) { biomes[i] = BiomeGenBase.beach; } return biomes; } public float[] getRainfall(float[] listToReuse, int x, int z, int width, int length) { float[] rainfall = new float[width * length]; for (int i = 0; i < rainfall.length; i++) { rainfall[i] = 0; } return rainfall; } public boolean areBiomesViable(int x, int z, int radius, List allowed) { return true; } public BlockPos findBiomePosition(int x, int z, int range, List biomes, Random random) { return new BlockPos(7, 0, 7); } } The chunk provider: public class TestWorldChunkProvider implements IChunkProvider { private Random random; private World world; public TestWorldChunkProvider(World world) { random = new Random(); this.world = world; } @Override public boolean chunkExists(int x, int z) { return true; } @Override public Chunk provideChunk(int x, int z) { random.setSeed((long)x * 341873128712L + (long)z * 132897987541L); Chunk chunk = new Chunk(world, x, z); // Generate 16x16 square of grass blocks at y value of 63. for (int curX=0; curX<16; curX++) { for (int curZ=0; curZ<16; curZ++) { for (int curY = 1; curY < 2; curY++) { chunk.setBlockState(new BlockPos(curX, curY, curZ), Blocks.bedrock.getDefaultState()); } chunk.setBlockState(new BlockPos(curX, 63, curZ), Blocks.dirt.getDefaultState()); } } return chunk; } @Override public Chunk provideChunk(BlockPos blockPosIn) { return provideChunk(blockPosIn.getX() >> 4, blockPosIn.getZ() >> 4); } @Override public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) { //add ores in here } @Override public boolean func_177460_a(IChunkProvider p_177460_1_, Chunk p_177460_2_, int p_177460_3_, int p_177460_4_) { return false; } @Override public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_) { return true; } @Override public boolean unloadQueuedChunks() { return false; } @Override public boolean canSave() { return false; } @Override public String makeString() { return null; } @Override public List func_177458_a(EnumCreatureType p_177458_1_, BlockPos p_177458_2_) { return null; } @Override public BlockPos getStrongholdGen(World worldIn, String p_180513_2_, BlockPos p_180513_3_) { return null; } @Override public int getLoadedChunkCount() { return 0; } @Override public void recreateStructures(Chunk p_180514_1_, int p_180514_2_, int p_180514_3_) { } @Override public void saveExtraData() { } } Any insight as to what is so slow about this would be helpful - I would think it shouldn't take that long for it to generate with the 16x16 loop (even with that stupid loop that originally generated multiple layers of bedrock...)...
January 5, 201510 yr Using setBlockState() with flag 2 will most likely fix your issue. The default flag, 3, schedules a block update for each block it sets. GitHub|Recipe API Proposal
January 5, 201510 yr Author Using setBlockState() with flag 2 will most likely fix your issue. The default flag, 3, schedules a block update for each block it sets. Where does this flag get set? I can't seem to find an option for a flag inside the chunk.setBlockState() method EDIT: If it matters this is working with forge for 1.8
January 5, 201510 yr I didn't realize you were using chunks; I was referring to world.setBlockState() . Sorry for the confusion. GitHub|Recipe API Proposal
January 5, 201510 yr Author Got it working mostly. The solution: ChunkPrimer. The chunk primer is a container that can generate a chunk and ignore all the events and updates that need to be fired. Alternately: my perlin noise generator is slower than the previous one I worked with, just a secondary issue on top of it.
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.