@‘TheWolf’:
package fr.craftandfight.serveur.common;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenFlowers;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
public class WorldGeneration implements IWorldGenerator
{
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
switch (world.provider.dimensionId)
{
case -1:
generateNether(world, random, chunkX * 16, chunkZ * 16);
case 0:
generateSurface(world, random, chunkX * 16, chunkZ * 16);
case 1:
generateEnd(world, random, chunkX * 16, chunkZ * 16);}
}
private void generateEnd(World world, Random random, int x, int z) {
}
private void generateSurface(World world, Random random, int x, int z) {
this.addOreSpawn(ModCraftAndFight.rubyOre, world, random, x, z, 16, 16, 8, 1, 0, 16);
this.addOreSpawn(ModCraftAndFight.sapphireOre, world, random, x, z, 16, 16, 8, 1, 0, 16);
this.addOreSpawn(ModCraftAndFight.jadeOre, world, random, x, z, 16, 16, 4, 4, 0, 10);
this.addOreSpawn(ModCraftAndFight.rainbowOre, world, random, x, z, 16, 16, 3, 1, 0, 8);
this.addOreSpawn(ModCraftAndFight.nuclearOre, world, random, x, z, 16, 16, 2, 1, 0, 8);
this.addOreSpawn(ModCraftAndFight.agathOre, world, random, x, z, 16, 16, 5, 1, 0, 13);
}
public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY) {
assert maxY > minY : "La position Y maximum doit être supérieure à la position Y minimum.";
assert maxX > 0 && maxX <= 16 : "X doit se trouver entre 0 et 16.";
assert minY > 0 : "La position Y minimum doit être supérieure à 0.";
assert maxY < 256 && maxY > 0 : "La position Y maximum doit se trouver entre 0 et 256.";
assert maxZ > 0 && maxZ <= 16 : "Z doit se trouver entre 0 et 16.";
int diffBtwnMinMaxY = maxY - minY;
for (int x = 0; x < chancesToSpawn; x++) {
int posX = blockXPos + random.nextInt(maxX);
int posY = minY + random.nextInt(diffBtwnMinMaxY);
int posZ = blockZPos + random.nextInt(maxZ);
(new WorldGenMinable(block, maxVeinSize)).generate(world, random, posX, posY, posZ);
}
}
private void generateNether(World world, Random random, int x, int z) {
}
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
switch(world.provider.dimensionId)
{
case 0:
generateSurface(world, random, chunkX * 16, chunkZ * 16);
}
}
private void generateSurface(World world, Random rand, int x, int z)
{
for(int i = 0; i < 75; i ++)
{
int randPosX = x + rand.nextInt(16);
int randPosY = rand.nextInt(128);
int randPosZ = z + rand.nextInt(16);
(new WorldGenerationCoca()).generate(world, rand, randPosX, randPosY, randPosZ);
}
}
}
Tu as deux ois la méthode generate t’a classe doit être comme sa :
package fr.craftandfight.serveur.common;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenFlowers;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
public class WorldGeneration implements IWorldGenerator
{
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
switch (world.provider.dimensionId)
{
case -1:
generateNether(world, random, chunkX * 16, chunkZ * 16);
case 0:
generateSurface(world, random, chunkX * 16, chunkZ * 16);
case 1:
generateEnd(world, random, chunkX * 16, chunkZ * 16);}
}
private void generateEnd(World world, Random random, int x, int z) {
}
private void generateSurface(World world, Random random, int x, int z) {
for(int i = 0; i < 75; i ++)
{
int randPosX = x + rand.nextInt(16);
int randPosY = rand.nextInt(128);
int randPosZ = z + rand.nextInt(16);
(new WorldGenerationCoca()).generate(world, rand, randPosX, randPosY, randPosZ);
}
this.addOreSpawn(ModCraftAndFight.rubyOre, world, random, x, z, 16, 16, 8, 1, 0, 16);
this.addOreSpawn(ModCraftAndFight.sapphireOre, world, random, x, z, 16, 16, 8, 1, 0, 16);
this.addOreSpawn(ModCraftAndFight.jadeOre, world, random, x, z, 16, 16, 4, 4, 0, 10);
this.addOreSpawn(ModCraftAndFight.rainbowOre, world, random, x, z, 16, 16, 3, 1, 0, 8);
this.addOreSpawn(ModCraftAndFight.nuclearOre, world, random, x, z, 16, 16, 2, 1, 0, 8);
this.addOreSpawn(ModCraftAndFight.agathOre, world, random, x, z, 16, 16, 5, 1, 0, 13);
}
public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY) {
assert maxY > minY : "La position Y maximum doit être supérieure à la position Y minimum.";
assert maxX > 0 && maxX <= 16 : "X doit se trouver entre 0 et 16.";
assert minY > 0 : "La position Y minimum doit être supérieure à 0.";
assert maxY < 256 && maxY > 0 : "La position Y maximum doit se trouver entre 0 et 256.";
assert maxZ > 0 && maxZ <= 16 : "Z doit se trouver entre 0 et 16.";
int diffBtwnMinMaxY = maxY - minY;
for (int x = 0; x < chancesToSpawn; x++) {
int posX = blockXPos + random.nextInt(maxX);
int posY = minY + random.nextInt(diffBtwnMinMaxY);
int posZ = blockZPos + random.nextInt(maxZ);
(new WorldGenMinable(block, maxVeinSize)).generate(world, random, posX, posY, posZ);
}
}
private void generateNether(World world, Random random, int x, int z) {
}
}