Camellias_

Untitled

May 22nd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.55 KB | None | 0 0
  1. package com.camellias.voidaicarcania.world.gen;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Random;
  5.  
  6. import com.camellias.voidaicarcania.world.biomes.BiomeVoid;
  7. import com.camellias.voidaicarcania.world.gen.generators.WorldGenStructure;
  8.  
  9. import net.minecraft.block.Block;
  10. import net.minecraft.init.Biomes;
  11. import net.minecraft.init.Blocks;
  12. import net.minecraft.util.math.BlockPos;
  13. import net.minecraft.world.World;
  14. import net.minecraft.world.WorldType;
  15. import net.minecraft.world.biome.Biome;
  16. import net.minecraft.world.biome.BiomeEnd;
  17. import net.minecraft.world.chunk.IChunkProvider;
  18. import net.minecraft.world.gen.IChunkGenerator;
  19. import net.minecraft.world.gen.feature.WorldGenerator;
  20. import net.minecraftforge.fml.common.IWorldGenerator;
  21. import java.util.Arrays;
  22.  
  23. public class WorldGenCustomStructures implements IWorldGenerator
  24. {
  25.     @Override
  26.     public void generate(Random rand, int chunkX, int chunkZ, World world, IChunkGenerator generator,
  27.             IChunkProvider provider)
  28.     {
  29.         switch(world.provider.getDimension())
  30.         {
  31.             case 1:
  32.                
  33.                 break;
  34.                
  35.             case 0:
  36.                
  37.                 //generateStructure2(new WorldGenStructure(""), world, rand, chunkX, chunkZ, 1000, Blocks.STONE, Biome.class);
  38.                
  39.                 break;
  40.                
  41.             case -1:
  42.                
  43.                 break;
  44.                
  45.             case -64:
  46.                
  47.                 generateStructure(new WorldGenStructure("voidtemple"), world, rand, chunkX, chunkZ, 3000, Blocks.AIR, BiomeVoid.class);
  48.                
  49.                 generateStructure(new WorldGenStructure("islandruin_1"), world, rand, chunkX, chunkZ, 1000, Blocks.AIR, BiomeVoid.class);
  50.                
  51.                 generateStructure(new WorldGenStructure("ruin_garden"), world, rand, chunkX, chunkZ, 1000, Blocks.AIR, BiomeVoid.class);
  52.                
  53.                 generateStructure(new WorldGenStructure("islandovergrown"), world, rand, chunkX, chunkZ, 750, Blocks.AIR, BiomeVoid.class);
  54.                
  55.                 generateStructure(new WorldGenStructure("islandobelisk"), world, rand, chunkX, chunkZ, 400, Blocks.AIR, BiomeVoid.class);
  56.                
  57.                 generateStructure(new WorldGenStructure("islandtall"), world, rand, chunkX, chunkZ, 30, Blocks.AIR, BiomeVoid.class);
  58.                
  59.                 generateStructure(new WorldGenStructure("islandcluster_1"), world, rand, chunkX, chunkZ, 20, Blocks.AIR, BiomeVoid.class);
  60.         }
  61.     }
  62.    
  63.     private void generateStructure(WorldGenerator generator, World world, Random rand,
  64.             int chunkX, int chunkZ, int chance, Block topBlock, Class<?>... classes)
  65.     {
  66.         ArrayList<Class<?>> classesList = new ArrayList<Class<?>>(Arrays.asList(classes));
  67.        
  68.         int x = (chunkX * 16) + rand.nextInt(15);
  69.         int z = (chunkZ * 16) + rand.nextInt(15);
  70.         int y = rand.nextInt(256);
  71.         BlockPos pos = new BlockPos(x, y, z);
  72.        
  73.         Class<?> biome = world.provider.getBiomeForCoords(pos).getClass();
  74.        
  75.         if(world.getWorldType() != WorldType.FLAT)
  76.         {
  77.             if(classesList.contains(biome))
  78.             {
  79.                 if(rand.nextInt(chance) == 0)
  80.                 {
  81.                     generator.generate(world, rand, pos);
  82.                 }
  83.             }
  84.         }
  85.     }
  86.    
  87.     private void generateStructure2(WorldGenerator generator, World world, Random rand,
  88.             int chunkX, int chunkZ, int chance, Block topBlock, Class<?>... classes)
  89.     {
  90.         ArrayList<Class<?>> classesList = new ArrayList<Class<?>>(Arrays.asList(classes));
  91.        
  92.         int x = (chunkX * 16) + rand.nextInt(15);
  93.         int z = (chunkZ * 16) + rand.nextInt(15);
  94.         int y = rand.nextInt(256);
  95.         BlockPos pos = new BlockPos(x, y, z);
  96.        
  97.         Class<?> biome = world.provider.getBiomeForCoords(pos).getClass();
  98.        
  99.         if(world.getWorldType() != WorldType.FLAT)
  100.         {
  101.             if(classesList.contains(biome))
  102.             {
  103.                 if(rand.nextInt(chance) == 0)
  104.                 {
  105.                     generator.generate(world, rand, pos);
  106.                 }
  107.             }
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment