我想在我的《我的世界》模组中在地球上拥有2个矿石,但只产生一个矿石。我也成功地在冥界和地狱中添加了一个矿石,但是在冥界中却无法获得2。这是我的代码:
编辑:我自己修复

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
}

最佳答案

问题似乎出在您忘记实际调用最终生成方法的情况下,这意味着该方法永远不会执行,矿石也不会产生。

只需在generate方法中的switch语句中添加对它的调用即可。

10-08 16:05