Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. package com.formas1.ruispantry.world;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Random;
  5.  
  6. import com.formas1.ruispantry.init.ModBlocks;
  7.  
  8. import net.minecraft.block.state.IBlockState;
  9. import net.minecraft.init.Biomes;
  10. import net.minecraft.util.math.BlockPos;
  11. import net.minecraft.world.World;
  12. import net.minecraft.world.biome.Biome;
  13. import net.minecraft.world.biome.BiomeForest;
  14. import net.minecraft.world.biome.BiomeJungle;
  15. import net.minecraft.world.biome.BiomePlains;
  16. import net.minecraft.world.chunk.IChunkProvider;
  17. import net.minecraft.world.gen.IChunkGenerator;
  18. import net.minecraft.world.gen.feature.WorldGenAbstractTree;
  19. import net.minecraft.world.gen.feature.WorldGenMinable;
  20. import net.minecraft.world.gen.feature.WorldGenTrees;
  21. import net.minecraft.world.gen.feature.WorldGenerator;
  22. import net.minecraftforge.event.LootTableLoadEvent;
  23. import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
  24. import net.minecraftforge.event.terraingen.TerrainGen;
  25. import net.minecraftforge.fml.common.IWorldGenerator;
  26. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  27. import scala.actors.threadpool.Arrays;
  28.  
  29. public class ModWorldGen implements IWorldGenerator
  30. {
  31. private WorldGenTreesFormas FORMAS = new WorldGenTreesFormas(false);
  32. private WorldGenTreesGam GAM = new WorldGenTreesGam(false);
  33. private WorldGenTreesMilkshake MILKSHAKE = new WorldGenTreesMilkshake(false);
  34. @Override
  35. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,IChunkProvider chunkProvider)
  36. {
  37. if(world.provider.getDimension() == 0)
  38. {
  39. generateOverworld(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
  40. if(world.getBiomeForCoordsBody(new BlockPos(chunkX * 16, 70, chunkZ * 16)) instanceof BiomePlains)
  41. {
  42. populate(FORMAS, world, random, chunkX, chunkZ, 2);
  43. populate(GAM, world, random, chunkX, chunkZ, 2);
  44. populate(MILKSHAKE, world, random, chunkX, chunkZ, 2);
  45. }
  46. }
  47.  
  48. else if(world.provider.getDimension() == -1)
  49. {
  50. generateNether(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
  51. }
  52.  
  53.  
  54. }
  55.  
  56. private void populate(WorldGenerator generator, World world, Random random, int chunkX, int chunkZ, int amountPerChunk) {
  57. for(int i = 0; i < amountPerChunk; i++) {
  58. int x = chunkX * 16 + random.nextInt(16);
  59. int z = chunkZ * 16 + random.nextInt(16);
  60. int y = world.getChunkFromChunkCoords(x >> 4, z >> 4).getHeight(new BlockPos(x & 15, 0, z & 15)) - 1;
  61. generator.generate(world, random, new BlockPos(x, y, z));
  62. }
  63. }
  64.  
  65. private void generateOverworld(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,IChunkProvider chunkProvider)
  66. {
  67. generateOre(ModBlocks.FORMAS_ORE.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 16, 64, random.nextInt(5) + 3, 15);
  68. generateOre(ModBlocks.MILKSHAKE_ORE.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 16, 64, random.nextInt(5) + 3, 15);
  69. generateOre(ModBlocks.GAM_ORE.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 16, 64, random.nextInt(5) + 3, 15);
  70. }
  71.  
  72. private void generateNether(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,IChunkProvider chunkProvider)
  73. {
  74. generateOre(ModBlocks.SPINEL_ORE.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 4, 200, random.nextInt(6) + 3, 100);
  75. }
  76.  
  77. private void generateOre(IBlockState ore, World world, Random random, int x, int z, int minY, int maxY, int size, int chances)
  78. {
  79. int deltaY = maxY - minY;
  80.  
  81. for(int i = 0; i < chances; i++)
  82. {
  83. BlockPos pos = new BlockPos(x + random.nextInt(16), minY + random.nextInt(deltaY), z + random.nextInt(16));
  84.  
  85. WorldGenMinable oregenerator = new WorldGenMinable(ore, size);
  86. oregenerator.generate(world, random, pos);
  87. }
  88. }
  89.  
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement