簡體   English   中英

如何在Minecraft Mod中擁有多個礦石?

[英]How to have multiple ores in a minecraft mod?

我想在我的《我的世界》模組中在地球上擁有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語句內添加對它的調用即可。

我自己解決了。 我取出了WorldGeneratieOverworld1,然后將這一代添加到另一個WorldGeneratieOverworld之下。 這是新代碼:

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
   }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM