Guest User

code

a guest
Mar 24th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.24 KB | None | 0 0
  1. package com.steelfeathers.nethersurvival.worldgen;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.steelfeathers.nethersurvival.blocks.BlockCrystalCluster;
  6. import com.steelfeathers.nethersurvival.init.ModBlocks;
  7. import com.steelfeathers.nethersurvival.worldgen.predicates.NetherGenPredicate;
  8. import com.steelfeathers.nethersurvival.worldgen.predicates.OverworldGenPredicate;
  9.  
  10. import net.minecraft.init.Blocks;
  11. import net.minecraft.util.math.BlockPos;
  12. import net.minecraft.world.World;
  13. import net.minecraft.world.chunk.IChunkGenerator;
  14. import net.minecraft.world.chunk.IChunkProvider;
  15. import net.minecraft.world.gen.feature.WorldGenMinable;
  16. import net.minecraft.world.gen.feature.WorldGenerator;
  17. import net.minecraftforge.fml.common.IWorldGenerator;
  18.  
  19. public class CrystalGenerator implements IWorldGenerator {
  20.  
  21.     private WorldGenerator crystal_nether;
  22.     private WorldGenerator crystal_overworld;
  23.    
  24.     public CrystalGenerator() {
  25.         crystal_nether = new WorldGenCrystal(ModBlocks.crystalCluster.getDefaultState(), Blocks.NETHERRACK, 5, 3, BlockCrystalCluster.FACING);
  26.         crystal_overworld = new WorldGenCrystal(ModBlocks.crystalCluster.getDefaultState(), Blocks.STONE, 5, 3, BlockCrystalCluster.FACING);
  27.     }
  28.    
  29.     @Override
  30.     public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
  31.             IChunkProvider chunkProvider) {
  32.         switch (world.provider.getDimension()) {
  33.         case 0: //overworld
  34.             this.runGenerator(crystal_overworld, world, random, chunkX, chunkZ, 10, 0, 64);
  35.             break;
  36.         case -1:  //nether
  37.             this.runGenerator(crystal_nether, world, random, chunkX, chunkZ, 30, 0, 64);
  38.             break;
  39.         }
  40.        
  41.     }
  42.    
  43.    
  44.     private void runGenerator(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z,
  45.             int chancesToSpawn, int minHeight, int maxHeight) {
  46.         if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
  47.             throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
  48.  
  49.         int heightDiff = maxHeight - minHeight + 1;
  50.         for (int i = 0; i < chancesToSpawn; i++) {
  51.             int x = chunk_X * 16 + rand.nextInt(16);
  52.             int y = minHeight + rand.nextInt(heightDiff);
  53.             int z = chunk_Z * 16 + rand.nextInt(16);
  54.             generator.generate(world, rand, new BlockPos(x, y, z));
  55.         }
  56.     }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment