Вопрос

I am trying to have 2 ores in the overworld in my minecraft mod, but only one Ore is generating. Also I have added an Ore successfully in the overworld and in the nether but cant get 2 in the overworld. Here is my code: edit: I fixed it on my own

package com.halo.halomod.world.gen;

import java.util.Random;

import com.halo.halomod.halo;
import com.halo.halomod.world.gen.feature.NetherGenMinable;

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 haloGenerationClass implements IWorldGenerator {

@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
        IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
    // TODO Auto-generated method stub

    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:
        generationInEnd(world, random, chunkX*16, chunkZ*16);
        break;
}
}

private void generationInEnd(World world, Random random, int x, int z) {
}

private void generateInOverworld(World world, Random random, int x, int z) {
    for(int i = 0; i < 20; i++) { //20 = Rarity
        int chunkX = x + random.nextInt(16);
        int chunkY = random.nextInt(30); //= how high generates
        int chunkz = z + random.nextInt(16);

        (new WorldGenMinable(halo.Titanium_Ore, 8)).generate(world, random, chunkX,   chunkY, chunkz); //8 = number per vein
    }
}

private void generateInNether(World world, Random random, int x, int z) {
    for(int i = 0; i < 20; i++) { //20 = Rarity
        int chunkX = x + random.nextInt(16);
        int chunkY = random.nextInt(250); //= how high generates
        int chunkz = z + random.nextInt(16);

        (new NetherGenMinable(halo.Nether_Titanium_Ore, 8)).generate(world, random,  chunkX, chunkY, chunkz); //8 = number per vein
    }
}
//code not working from here 
private void generateInOverworld1(World world, Random random, int x, int z) {
    for(int i = 0; i < 1000; i++) { //20 = Rarity
        int chunkX = x + random.nextInt(16);
        int chunkY = random.nextInt(250); //= how high generates
        int chunkz = z + random.nextInt(16);

        (new WorldGenMinable(halo.Copper_Ore, 100)).generate(world, random, chunkX, chunkY, chunkz); //8 = number per vein
        }
} // <----- to here
}
Это было полезно?

Решение 2

I figured it out on my own. I took out the WorldGeneratieOverworld1 and just added the generation below the other WorldGeneratieOverworld. here is the new code:

private void generateInOverworld(World world, Random random, int x, int z) {
    for(int i = 0; i < 17; i++) { //20 = Rarity
        int chunkX = x + random.nextInt(16);
        int chunkY = random.nextInt(28); //= how high generates
        int chunkz = z + random.nextInt(16);

        (new WorldGenMinable(halo.Titanium_Ore, 6)).generate(world, random, chunkX,  chunkY, chunkz); //8 = number per vein
    }
    for(int i = 0; i < 24; i++) { //20 = Rarity
        int chunkX = x + random.nextInt(16);
        int chunkY = random.nextInt(45); //= how high generates
        int chunkz = z + random.nextInt(16);

        (new WorldGenMinable(halo.Copper_Ore, 7)).generate(world, random, chunkX, chunkY, chunkz); //8 = number per vein
   }
}

Другие советы

The problem seems to be a case of you forgetting to actually call the final generation method, meaning that it never executes and the ore never spawns.

Simply adding a call to it from within the switch statement in the generate method should work.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top