Advertisement
Guest User

WorldGen

a guest
Jan 4th, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. package fr.yalouor.mod.world;
  2.  
  3. import java.util.Random;
  4.  
  5. import cpw.mods.fml.common.IWorldGenerator;
  6. import fr.yalouor.mod.client.BlocksYalouor;
  7. import net.minecraft.block.Block;
  8. import net.minecraft.init.Blocks;
  9. import net.minecraft.world.World;
  10. import net.minecraft.world.chunk.IChunkProvider;
  11. import net.minecraft.world.gen.feature.WorldGenMinable;
  12.  
  13. public class WorldGen implements IWorldGenerator
  14.  
  15. {
  16. @Override
  17. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
  18. {
  19. switch(world.provider.dimensionId)
  20. {
  21. case -1:
  22. GenerateNether(world, chunkX * 16, chunkZ * 16, random);
  23. break;
  24.  
  25. case 0:
  26. GenerateOverWorld(world, chunkX * 16, chunkZ * 16, random);
  27. break;
  28.  
  29. case 1:
  30. GenerateEnd(world, chunkX * 16, chunkZ * 16, random);
  31. break;
  32.  
  33. }
  34. }
  35.  
  36. private void addOre(Block block, Block blockSpawn, Random random, World world, int posX, int posZ, int minY, int maxY, int minV, int maxV, int spawnChance)
  37. {
  38. for(int i = 0; i < spawnChance; i++)
  39. {
  40. int chunkSize = 16;
  41. int Xpos = posX + random.nextInt(chunkSize);
  42. int Ypos = minY + random.nextInt(maxY - minY);
  43. int Zpos = posZ + random.nextInt(chunkSize);
  44.  
  45. new WorldGenMinable(block, maxY).generate(world, random, Xpos, Ypos, Zpos);
  46. }
  47. }
  48.  
  49. private void GenerateNether(World world, int i, int j, Random random)
  50. {
  51. addOre(BlocksYalouor.minerais_rinuim, Blocks.netherrack, random, world, i, j, 1, 16, 1, 3, 3);
  52. }
  53.  
  54. private void GenerateOverWorld(World world, int i, int j, Random random)
  55. {
  56. //addOre(minerais, Blocks.stone, random, world, i, j, couche mini, couche maxi, filon mini, filon maxi, chance);
  57. addOre(BlocksYalouor.minerais_sapphire, Blocks.stone, random, world, i, j, 1, 16, 1, 3, 4);
  58. addOre(BlocksYalouor.minerais_yalouor, Blocks.stone, random, world, i, j, 1, 16, 1, 3, 2);
  59. }
  60.  
  61. private void GenerateEnd(World world, int i, int j, Random random)
  62. {
  63.  
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement