| package shaarfight.worldgen; |
| |
| 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.WorldGenMinable; |
| import shaarfight.common.ShaarMod; |
| import cpw.mods.fml.common.IWorldGenerator |
| |
| { |
| |
| public class IlluveWorldGeneration implements IWorldGenerator { |
| |
| public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){ |
| |
| swich (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 generateSurface(World world, Random random, int x, int z) { |
| |
| } |
| |
| private void generateNether(World world, Random random, int x, int z) { |
| |
| this.addOreSpawn(ShaarMod.oreIlluve, world, random, x, z, 16, 16, 1 + random.netInt(4), 50, 5, ); |
| |
| } |
| |
| 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 maX > 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(ShaarMod.oreIlluve, 1 + random.nextInt(4))).generate(world, random, posX, posY, posZ); |
| |
| } |
| } |
| } |
| |
Voilà mon code de ma classe IlluveWorldGeneration.