JohnnyMccurm Posted February 23, 2015 Posted February 23, 2015 Having an issue with my first generated world structure, I wanted to generate a cave for the block I've been working on over the past few days to sit inside, the problem is the structure isn't spawning in plains biomes, like I want it too, and since I've not seen one yet I'm pretty certain I have an error, somewhere. I can't really see errors in my code, but here's my worldgen class. public class WorldGen implements IWorldGenerator { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.dimensionId) { case 0: //surface world generateSurface(world, random, chunkX*16, chunkZ*16); case 1: //end world generateEnd(world, random, chunkX * 16, chunkZ * 16); case -1: //nether world generateNether(world, random, chunkX * 16, chunkZ * 16); } } private void generateSurface(World world, Random random, int x, int z) { this.addSpawn(ModBlocks.johnnyFaceBlockRubble, world, random, x, z,16,16,4 + random.nextInt(6), 25, 38, 100); BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z); if ((biome == BiomeGenBase.plains)) { for(int a = 0; a < 1; a++) { int i = x + random.nextInt(16); int j = z + random.nextInt(16); int k = world.getHeightValue(i, j); new StructureJohnnyFaceCave().generate(world, random, i, k, j); } } } private void generateEnd(World world, Random random, int x, int z) { } private void generateNether(World world, Random random, int x, int z) { } private void addSpawn(Block block, World world, Random random, int blockXPos , int blockZPos, int maxX, int maxZ, int maxVeinSize, int chanceToSpawn, int minY, int maxY) { for(int i = 0; i <chanceToSpawn; i++) { int posX = blockXPos + random.nextInt(maxX); int posY = minY + random.nextInt(maxY - minY); int posZ = blockZPos + random.nextInt(maxZ); (new WorldGenMinable(block, maxVeinSize)).generate(world, random, posX, posY, posZ); } } } I'll link the Structure file if it's actually requested, since that is a large file (Most structures are just the java required to place the blocks, so it's 3000 lines long) pretty confident that if an error does exist it's in my WorldGen class and not the structure class, but I could be wrong, I have been before, and only been doing this stuff for a week If anyone could help out I'd be grateful Quote Think Java is tough? try BrainFuck!
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 Anyone? Quote Think Java is tough? try BrainFuck!
Failender Posted February 24, 2015 Posted February 24, 2015 Are you registering the world generator? Quote
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 What do you mean by registering? Quote Think Java is tough? try BrainFuck!
Failender Posted February 24, 2015 Posted February 24, 2015 Well. You cant just create a world generator and expect it to work. You need to tell Forge that you create one and that it should use it. I guess MinecraftForge.TERRAIN_GEN_BUS should be what you are looking for. But I need to say that I'm not sure. I never worked with Terrain generating. So I might be wrong. Just triing to give u some hints what to look for Quote
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 I've never heard of MinecraftForge.TERRAIN_GEN_BUS I don't think that's required. Still stumped. Quote Think Java is tough? try BrainFuck!
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 Quote Use World.getBiomeGenForCoords to get the Biome. It takes block coordinates, not chunk coordinates. Can you be more specific? So I need to change my entire generateSurface method? If I change: "BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);" to "BiomeGenBase biome = world.getBiomeGenForCoords().getBiomeGenAt(x, z);" all I get is an error. I was following this guys tutorial on it, and he used the same code as I have currently, and HIS worked: Quote Think Java is tough? try BrainFuck!
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 So, this? BiomeGenBase biome = world.getBiomeGenForCoords(x, z);? and I can keep my other code? Quote Think Java is tough? try BrainFuck!
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 What do you MEAN block Co-ords? Quote Think Java is tough? try BrainFuck!
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 On 2/24/2015 at 5:13 PM, diesieben07 said: Consider the Block at 3, 4, 3. It has coordinates x=3, y=4, z=3. It is in chunk that starts at 0, 0, so the chunk coordinates are x=0, z=0. To get from one to the other do an integer divide by 16 (to get from block coords to chunk coords) or multiply by 16 for the other way around. BiomeGenBase biome = world.getBiomeGenForCoords(x / 16 , z / 16);? BiomeGenBase biome = world.getBiomeGenForCoords(x * 16 , z * 16);? If not, I'm completely lost. Quote Think Java is tough? try BrainFuck!
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 I tried both and neither generated. Quote Think Java is tough? try BrainFuck!
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 http://pastebin.com/n9QX2PDL Think I'm going to try another method of generating or follow a less "Jumpy" tutorial if I don't get it working this way, I thought I was close, but apparently not. I appreciate the help though Quote Think Java is tough? try BrainFuck!
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 What do you MEAN? What should I be doing? You said to get blocks from chunks I need to multiply right? I just don't understand what you mean, I mean, why am I even getting individual blocks to generate a structure? Quote Think Java is tough? try BrainFuck!
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 Quote Yes, that is what I said. But you did it twice. Twice? I don't multiply both X and Z then? I don't multiply in this line? generateSurface(world, random, chunkX*16, chunkZ*16);? I'm so lost, just going to restart from scratch, at least that'll be better than talking in riddles and replacing my code with code I've never heard of before, to find individual blocks, which I have no idea why I'm even doing to spawn a structure. This obviously makes some sense to you but it makes absolutely none to me. Quote Think Java is tough? try BrainFuck!
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 Well, thing is, now that my code doesn't generate correctly I don't really have a guide to consult -- there's hardly any code guides for this on YT since everyone uses mods to do it for them, and I don't want to do that. I'm sure it was a simple problem to begin with. Hopefully someone will actually explain the process, eventually. Going to work on other parts of my mod while I wait, not spending another night trying to work this one out when I don't understand it. Quote Think Java is tough? try BrainFuck!
JohnnyMccurm Posted February 24, 2015 Author Posted February 24, 2015 Anyone else got any ideas why my error might be happening? Quote Think Java is tough? try BrainFuck!
JohnnyMccurm Posted February 25, 2015 Author Posted February 25, 2015 Anyone? Quote Think Java is tough? try BrainFuck!
Lewis_McReu Posted March 20, 2015 Posted March 20, 2015 What Diesieben was trying to tell you is that you multiply the original chunk coordinates with 16 in the generate method, after which you pass them to the generateSurface method, in which you do it again. Once is enough. Remove that error, and try again then. Quote
Recommended Posts
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.