Guest User

Untitled

a guest
Aug 13th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. package com.mightydanp.eot.api.common.world.gen;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.mightydanp.eot.api.common.world.gen.feature.IWorldGenTwigs;
  6. import com.mightydanp.eot.common.block.BlockTwigs;
  7.  
  8. import net.minecraft.block.Block;
  9. import net.minecraft.block.state.IBlockState;
  10. import net.minecraft.util.math.BlockPos;
  11. import net.minecraft.world.World;
  12. import net.minecraft.world.WorldProviderEnd;
  13. import net.minecraft.world.WorldProviderHell;
  14. import net.minecraft.world.WorldProviderSurface;
  15. import net.minecraft.world.chunk.IChunkGenerator;
  16. import net.minecraft.world.chunk.IChunkProvider;
  17. import net.minecraft.world.gen.feature.WorldGenMinable;
  18. import net.minecraftforge.fml.common.IWorldGenerator;
  19.  
  20. public class IWorldGen implements IWorldGenerator {
  21.  
  22. @Override
  23. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
  24. if (world.provider instanceof WorldProviderHell) {
  25. generateNether(world, random, chunkX * 16, chunkZ * 16);
  26. }
  27. if (world.provider instanceof WorldProviderSurface) {
  28. generateSurface(world, random, chunkX * 16, chunkZ * 16);
  29. }
  30. if (world.provider instanceof WorldProviderEnd) {
  31. generateEnd(world, random, chunkX * 16, chunkZ * 16);
  32. }
  33. }
  34.  
  35. public void generateNether(World world, Random random, int chunkX, int chunkZ) { }
  36.  
  37. public void generateSurface(World world, Random random, int chunkX, int chunkZ) { }
  38.  
  39. public void generateEnd(World world, Random random, int chunkX, int chunkZ) { }
  40.  
  41. public void spawnOres(IBlockState block, World world, Random random, int chunkX, int chunkZ, int vainSize, int spawnChance, int YMin, int YMax) {
  42. for (int i = 0; i < spawnChance; i++) {
  43. int posX = chunkX + random.nextInt(16);
  44. int posY = YMin + random.nextInt(YMax - YMin);
  45. int posZ = chunkZ + random.nextInt(16);
  46. BlockPos blockPos = new BlockPos(posX, posY, posZ);
  47. (new WorldGenMinable(block, vainSize)).generate(world, random, blockPos);
  48. }
  49. }
  50.  
  51. public void spawnTwigs(Block block, World world, Random random, int chunkX, int chunkZ, int spawnChance) {
  52. for (int i = 0; i < spawnChance; i++) {
  53. int posX = chunkX + random.nextInt(16);
  54. int posY = (world.getActualHeight());
  55. int posZ = chunkZ + random.nextInt(16);
  56. BlockPos blockPos = new BlockPos(posX, posY, posZ);
  57. (new IWorldGenTwigs((BlockTwigs) block)).generate(world, random, blockPos);
  58. }
  59. }
  60.  
  61. }
Add Comment
Please, Sign In to add comment