Advertisement
Zarbi4734

GenOre

Dec 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. package com.mod.zarbium.world;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.mod.zarbium.init.BlockMod;
  6.  
  7. import net.minecraft.block.state.IBlockState;
  8. import net.minecraft.block.state.pattern.BlockMatcher;
  9. import net.minecraft.init.Blocks;
  10. import net.minecraft.util.math.BlockPos;
  11. import net.minecraft.world.World;
  12. import net.minecraft.world.chunk.IChunkGenerator;
  13. import net.minecraft.world.chunk.IChunkProvider;
  14. import net.minecraft.world.gen.feature.WorldGenMinable;
  15. import net.minecraftforge.fml.common.IWorldGenerator;
  16.  
  17. public class GenOre implements IWorldGenerator
  18. {
  19. @Override
  20. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
  21. {
  22. switch ( world.provider.getDimensionType() )
  23. {
  24. case NETHER:
  25. generateNether(world, random, chunkX * 16, chunkZ * 16);
  26. break;
  27. case OVERWORLD:
  28. generateSurface(world, random, chunkX * 16, chunkZ * 16);
  29. break;
  30. case THE_END:
  31. generateEnd(world, random, chunkX * 16, chunkZ * 16);
  32. break;
  33. }
  34. }
  35. private void generateEnd(World world, Random random, int x, int z)
  36. {
  37. }
  38. private void generateSurface(World world, Random random, int x, int z)
  39. {
  40. this.generateOre(BlockMod.zarbium_ore.getDefaultState(), Blocks.STONE.getDefaultState(), world, random, x, z, 0, 20, 1, 6, 50, 2);
  41. }
  42. private void generateNether(World world, Random random, int x, int z)
  43. {
  44. }
  45.  
  46. public void generateOre(IBlockState oreState, IBlockState targetState, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY)
  47. {
  48. assert maxY > minY : "La position Y maximum doit être supérieure à la position Y minimum.";
  49. assert maxX > 0 && maxX <= 16 : "X doit se trouver entre 0 et 16.";
  50. assert minY > 0 : "La position Y minimum doit être supérieure à 0.";
  51. assert maxY < 256 && maxY > 0 : "La position Y maximum doit se trouver entre 0 et 256.";
  52. assert maxZ > 0 && maxZ <= 16 : "Z doit se trouver entre 0 et 16.";
  53. for ( int i = 0; i < chancesToSpawn; i++ )
  54. {
  55. int posY = random.nextInt(128);
  56. if( (posY <= maxY) && (posY >= minY) )
  57. {
  58. new WorldGenMinable(oreState, maxVeinSize, BlockMatcher.forBlock(targetState.getBlock())).generate(world, random, new BlockPos(blockXPos + random.nextInt(16), posY, blockZPos + random.nextInt(16)));
  59. }
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement