Guest User

Untitled

a guest
Aug 30th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.89 KB | None | 0 0
  1. package com.halestormxv.worldALT.biomes.decorators;
  2.  
  3.  
  4. import com.halestormxv.blocks.CelestialCraft_blocks;
  5. import com.halestormxv.worldALT.biomes.BiomeLightForest;
  6. import com.halestormxv.worldALT.biomes.ModBiomes;
  7.  
  8.  
  9.  
  10. import net.minecraft.block.Block;
  11. import net.minecraft.init.Blocks;
  12. import net.minecraft.world.biome.BiomeGenBase;
  13. import net.minecraft.world.gen.feature.WorldGenMinable;
  14. import net.minecraft.world.gen.feature.WorldGenerator;
  15. import net.minecraftforge.common.MinecraftForge;
  16. import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
  17.  
  18. public class BiomeDecoratorHelper {
  19.  
  20.     private static WorldGenerator glowStone;
  21.  
  22.     public BiomeDecoratorHelper(){
  23.         //      glowStone = new WorldGenMinable(Blocks.glowstone, 30, CelestialCraft_blocks.lightStone);
  24.     }
  25.  
  26.     protected static void decorateBiome(BiomeGenBase biome) {
  27.         MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(BiomeDecoratorMod.currentWorld, BiomeDecoratorMod.randomGenerator, BiomeDecoratorMod.chunk_X, BiomeDecoratorMod.chunk_Z));
  28.         //perpere ores for generation
  29.         initOres();
  30.         //GenerateOres
  31.         generateOreInBiome(biome);
  32.  
  33.         if(biome == ModBiomes.forestLight){
  34.             BiomeDecoratorMod.howMenyTrees = BiomeLightForest.treesPerChunk;
  35.             int i = BiomeDecoratorMod.howMenyTrees;
  36.             /** Chunk Postions **/
  37.             int chunkX;
  38.             int chunkZ;
  39.             int y;
  40.             /** get blocks at the given locations **/
  41.             Block block;
  42.             Block blockA;
  43.             /** Generates Small tree **/
  44.             for(int a = 0; a < i; ++a){
  45.                 if(i == BiomeDecoratorMod.randomGenerator.nextInt(8)){
  46.                     chunkX = BiomeDecoratorMod.chunk_X + BiomeDecoratorMod.randomGenerator.nextInt(16) + 8;
  47.                     chunkZ = BiomeDecoratorMod.chunk_Z + BiomeDecoratorMod.randomGenerator.nextInt(16) + 8;
  48.                     y = BiomeDecoratorMod.currentWorld.getTopSolidOrLiquidBlock(chunkX, chunkZ);
  49.                     block = BiomeDecoratorMod.currentWorld.getBlock(chunkX, y, chunkZ);
  50.                     blockA = BiomeDecoratorMod.currentWorld.getBlock(chunkX, y - 1, chunkZ);
  51.                     if(block != Blocks.air || block != Blocks.water){
  52.                         if(blockA != Blocks.air || blockA != Blocks.water){
  53.                             BiomeDecoratorMod.smallTree.generate(BiomeDecoratorMod.currentWorld, BiomeDecoratorMod.randomGenerator, chunkX, y, chunkZ);
  54.                         }
  55.                     }
  56.                 }
  57.                 /** Generates Big tree **/
  58.                 if(i == BiomeDecoratorMod.randomGenerator.nextInt(15)){
  59.                     chunkX = BiomeDecoratorMod.chunk_X + BiomeDecoratorMod.randomGenerator.nextInt(16) + 8;
  60.                     chunkZ = BiomeDecoratorMod.chunk_Z + BiomeDecoratorMod.randomGenerator.nextInt(16) + 8;
  61.                     y = BiomeDecoratorMod.currentWorld.getTopSolidOrLiquidBlock(chunkX, chunkZ);
  62.                     block = BiomeDecoratorMod.currentWorld.getBlock(chunkX, y, chunkZ);
  63.                     blockA = BiomeDecoratorMod.currentWorld.getBlock(chunkX, y - 1, chunkZ);
  64.                     if(block != Blocks.air || block != Blocks.water){
  65.                         if(blockA != Blocks.air || blockA != Blocks.water){
  66.                             BiomeDecoratorMod.bigTree.generate(BiomeDecoratorMod.currentWorld, BiomeDecoratorMod.randomGenerator, chunkX, y, chunkZ);
  67.                         }
  68.                     }
  69.                 }
  70.                 /** Generates Celestial Trees **/
  71.                 if(i == BiomeDecoratorMod.randomGenerator.nextInt(6)){
  72.                     chunkX = BiomeDecoratorMod.chunk_X + BiomeDecoratorMod.randomGenerator.nextInt(16) + 8;
  73.                     chunkZ = BiomeDecoratorMod.chunk_Z + BiomeDecoratorMod.randomGenerator.nextInt(16) + 8;
  74.                     y = BiomeDecoratorMod.currentWorld.getTopSolidOrLiquidBlock(chunkX, chunkZ);
  75.                     block = BiomeDecoratorMod.currentWorld.getBlock(chunkX, y, chunkZ);
  76.                     blockA = BiomeDecoratorMod.currentWorld.getBlock(chunkX, y - 1, chunkZ);
  77.                     if(block != Blocks.air || block != Blocks.water){
  78.                         if(blockA != Blocks.air || blockA != Blocks.water){
  79.                             BiomeDecoratorMod.celestialTree.generate(BiomeDecoratorMod.currentWorld, BiomeDecoratorMod.randomGenerator, chunkX, y, chunkZ);
  80.                         }
  81.                     }
  82.                 }
  83.             }
  84.            
  85.             if(biome == ModBiomes.forestDark){
  86.                 //GENERARTE DARK FOREST STUFF HERE
  87.             }
  88.         }
  89.     }
  90.  
  91.     /**
  92.      * Prepare ores for generation
  93.      */
  94.     private static void initOres() {
  95.         //glowstone used fotr testing generation
  96.         glowStone = new WorldGenMinable(Blocks.glowstone, 30, Blocks.glowstone);
  97.     }
  98.  
  99.     /**
  100.      * Geberate Ores In a Biome
  101.      * @param biome
  102.      */
  103.     private static void generateOreInBiome(BiomeGenBase biome){
  104.         if(biome == ModBiomes.forestLight){
  105.             genStandardOre(20, glowStone, 0, 128);
  106.         }
  107.     }
  108.  
  109.     /**
  110.      * Generate ores in chunks.
  111.      * @param spawnWeight
  112.      * @param generatorToSpawn
  113.      * @param minSpawnHeight
  114.      * @param maxYSpawnHeight
  115.      */
  116.     private static void genStandardOre(int spawnWeight, WorldGenerator generatorToSpawn, int minSpawnHeight, int maxYSpawnHeight) {
  117.         for (int l = 0; l < spawnWeight; ++l) {
  118.             int i1 = BiomeDecoratorMod.chunk_X + BiomeDecoratorMod.randomGenerator.nextInt(16);
  119.             int j1 = BiomeDecoratorMod.randomGenerator.nextInt(maxYSpawnHeight - minSpawnHeight) + minSpawnHeight;
  120.             int k1 = BiomeDecoratorMod.chunk_Z + BiomeDecoratorMod.randomGenerator.nextInt(16);
  121.             generatorToSpawn.generate(BiomeDecoratorMod.currentWorld, BiomeDecoratorMod.randomGenerator, i1, j1, k1);
  122.         }
  123.     }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment