Advertisement
Guest User

copy

a guest
Apr 19th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. public class ModWorldGen implements IWorldGenerator {
  2.  
  3. @Override
  4. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
  5. {
  6. //Get the dimension, in this case, 0 = Overworld
  7. if (world.provider.getDimension() == 0) {
  8. generateOverworld(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
  9. }
  10. }
  11.  
  12. private void generateOverworld(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
  13. {
  14. //I've commented out one of the ones below to use as example to explain this
  15. //generateOre(1|ModBlocks.RUBY_ORE.getDefaultState(), 2|world, 3|random, 4|chunkX * 16, 5|chunkZ * 16, 6|4, 7|56, 8|random.nextInt(4) + 1, 9|16);
  16.  
  17. // 1| The block-state we want to generate, i.e of the ore we're generating
  18. // 2| The world we want to generate in (via the World we've passed to this)
  19. // 3| Random func for generating, rather self-explanatory
  20. // 4| X position to generate at, 16 cause chunks are 16x16
  21. // 5| Z position to generate at, once again cause chunks are 16x16
  22. // 6| Minimum Y height we want for the ore
  23. // 7| Maximum Y height we want for the ore
  24. // 8| The size of the vein (continued below)
  25. // with the +1 being the absolute-minimum the ore can generate at
  26. // and the part before being how big their max-veins are
  27. // 9| The number of times attempt-per-chunk to generate (higher values = more likely to spawn)
  28.  
  29. //More notes
  30. //Attempt-per-chunk of 6 to 8 = probably about between rarity of diamond to emerald
  31. //Attempt-per-chunk of 10 to 12 = around lapis to gold, maybe slightly below gold ore rarity
  32. //Attempt-per-chunk of 14 to 16 = Around a little bit less than iron but still rarer than gold or so
  33. // with +16 approaching iron rarity
  34. //You may need to fiddle with this is you are generating your own ore
  35. //You can also repurpose this to generate single block non-ore things such as TNT traps, chests, etc, probably by setting random.nextInt to 0
  36.  
  37. generateOre(ModBlocks.RUBYORE.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 4, 56, random.nextInt(4) + 1, 16);
  38. generateOre(ModBlocks.SAPPHIREORE.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 4, 56, random.nextInt(4) + 1, 16);
  39. }
  40.  
  41. private void generateOre(IBlockState ore, World world, Random random, int x, int z, int minY, int maxY, int size, int chances)
  42. {
  43. int deltaY = maxY - minY;
  44.  
  45. for (int i = 0; i < chances; i++) {
  46. BlockPos pos = new BlockPos(x + random.nextInt(16), minY + random.nextInt(deltaY), z + random.nextInt(16));
  47.  
  48. WorldGenMinable generator = new WorldGenMinable(ore, size);
  49. generator.generate(world, random, pos);
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement