Jump to content

problem with ore generator


SimonSlime

Recommended Posts

there is an error in you world generation code...

it should be (...).generate(world, rand, randPosX, randPosY, randPosZ)

 

Excuse me if I'm wrong, but in the images currently posted, I don't see that error anywhere. And if it was there, the OP would be getting a runtime error and the minecraft client wouldn't even run.

 

the client runs normally but I searched the new ores in the world but they doesn't generate. where I mistake?

 

 

report.png

 

report1.png

 

 

You aren't using the x, y, and z values you generated in each for loop.

i.e. you should be calling this:

(new WorldGenMinable(...)).generate(world, random, x, y, z);

 

But instead you are calling this:

(new WorldGenMinable(...)).generate(world, random, chunkX, chunkY, chunkZ);

 

Even though these are technically valid coordinates in the world, they are not the coordinates you generated. The reason you can't find any ores is A) they are all spawning in the same area in each chunk, and B) chunkY is set to 0, therefore it is being spawned under bedrock, however, since ores can only be spawned in stone, it just isn't spawning anything. Does that make sense?

 

Link to comment
Share on other sites

SimonGenerator.java

 

package com.example.simonsores.generation;

 

import java.util.Random;

 

 

 

 

 

 

 

import com.example.simonsores.simonsoresMod;

 

import net.minecraft.block.Block;

import net.minecraft.world.World;

import net.minecraft.world.chunk.IChunkProvider;

import net.minecraft.world.gen.feature.WorldGenMinable;

import cpw.mods.fml.common.IWorldGenerator;

 

public class SimonGenerator implements IWorldGenerator

{

private static final int chunkY = 0;

 

public SimonGenerator() {

// TODO Auto-generated constructor stub

}

 

@Override

public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)

{

switch(world.provider.dimensionId)

{

case -1:

generateInNether(world, random, chunkX * 16, chunkZ * 16);

break;

case 0:

generateInOverworld(world, random, chunkX * 16, chunkZ * 16);

break;

case 1:

generateInEnd(world, random, chunkX * 16, chunkZ * 16);

break;

}

}

 

private void generateInNether(World world, Random random, int chunkX, int chunkZ) {

 

}

 

 

private void generateInOverworld(World world, Random random, int chunkX, int chunkZ)

{

for(int i = 0; i < 50; i++) {

int x = chunkX + random.nextInt(16);

int y = random.nextInt(300);

int z = random.nextInt(16);

(new WorldGenMinable(simonsoresMod.PlatinumOre, 50)).generate(world, random, x, y, z);

}

 

{

for(int i = 0; i < 20; i++) {

int x = chunkX + random.nextInt(16);

int y = random.nextInt(300);

int z = random.nextInt(16);

(new WorldGenMinable(simonsoresMod.CobaltOre, 20)).generate(world, random, x, y, z);}}

}

 

private void generateInEnd(World world, Random random, int chunkX, int chunkZ) {

 

}

}

Link to comment
Share on other sites

I tried in this way, did you mean this?

 

private void generateInOverworld(World world, Random random, int chunkX, int chunkZ)

{

for(int i = 0; i < 50; i++) {

int x = chunkX + random.nextInt(16);

int y = random.nextInt(300);

int z = random.nextInt(15);

(new WorldGenMinable(simonsoresMod.PlatinumOre, 50)).generate(world, random, x, y, z);

}

Link to comment
Share on other sites

SimonSlime, I believe what he means is, as you had to do with your X coordinate, you have to add the chunkZ to your Z variable. Does that make sense? I can give a further explanation if you do not understand why, it's important you understand why things work, not just that they do.

 

diesieben07, is that what you meant?

Link to comment
Share on other sites

ok then maybe did you mean this? sorry but it's my first generation  :-\

 

{

for(int i = 0; i < 50; i++) {

int x = chunkX + random.nextInt(16);

int y = random.nextInt(300);

int z = chunkZ + random.nextInt(16);

(new WorldGenMinable(simonsoresMod.PlatinumOre, 50)).generate(world, random, x, y, z);

}

Link to comment
Share on other sites

ok ok I fixed it! the error was in the main.java.

 

I had written

 

    GameRegistry.registerWorldGenerator(gen, 1);

 

and I have changed it with

 

    GameRegistry.registerWorldGenerator(new SimonGenerator(), 1);

 

I don't know why I did this stupid mistake but the important thing is that now it works! thank you all! :)

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.