So a week or so ago I had a world generation class that worked perfectly fine, it would generate a block in a custom dimension, in this case a dimension with the id of 8. However this no longer works, and when I try to enter the custom dimension, the world gets stuck on "building terrain". I've tried generating in vanilla dimensions and the same problem occurs, so I'm guessing that the custom dimension I have is not causing the problem.
I haven't made any major changes inside or outside of my generation manager class in the time that this problem occurred.
I used a simple:
"System.out.println("Generating Block");" To see when the game tries to generate the block, and it seems that this is happening when the game gets stuck on "building terrain" (Obviously)
Code:
[spoiler=Generation Manager Class]
package com.custom.generation;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLog;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import cpw.mods.fml.common.IWorldGenerator;
public class CustomGeneration implements IWorldGenerator{
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
switch (world.provider.dimensionId) {
case -1:
break;
case 0:
break;
case 1:
break;
case 8:
generateCustom(world, random, chunkX * 16, chunkZ * 16);
break;
}
}
public void generateCustom(World world, Random random, int x, int z){
//I'm pretty sure this is where the problem is caused, because I put a println here to see when this specific code is running and it seems when it gets stuck on "Building Terrain" that this code is running over and over again, which Is probably the game attempting to generate the block.
for (int i = 0; i < 4; i++){
int X = x + random.nextInt(16);
int Y = random.nextInt(16);
int Z = z + random.nextInt(16);
new WorldGenCustomNameHere().generate(world, random, X, Y, Z);
}
}
}
}
[spoiler=WorldGen Class]
package com.custom.generation;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.world.World;
public class WorldGenCustomNameHere {
public WorldGenCustomNameHere(){}
public boolean generate(World world, Random rand, int i, int j, int k) {
world.setBlock(i + 0, j + 0, k + 0, ModClassHere.CustomBlockHere);
//this one block being generated is just a test for now
return true;
}
}
Main Mod Class, where the generator is registered:
[spoiler=Main Mod File]
CustomGenerator generator = new CustomGenerator();
GameRegistry.registerWorldGenerator(generator, 0);
//right now I have this in the Pre-Initialization method.
Like I said above, when I run this code, the game gets stuck on the "Building Terrain" Screen when I enter whichever dimension I'm generating in. I'm not looking for code, I would just like to know what I'm doing wrong or what the issue is.
Thanks in advance.