Advertisement
Guest User

Untitled

a guest
Feb 1st, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. package com.mightydanp.rodrcore.common.world.gen.feature;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.mightydanp.rodrcore.common.block.ModBlocks;
  6.  
  7. import net.minecraft.init.Blocks;
  8. import net.minecraft.util.math.BlockPos;
  9. import net.minecraft.world.World;
  10. import net.minecraft.world.chunk.IChunkGenerator;
  11. import net.minecraft.world.chunk.IChunkProvider;
  12. import net.minecraftforge.fml.common.IWorldGenerator;
  13.  
  14. public class WorldGenRocks implements IWorldGenerator {
  15.  
  16. @Override
  17. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
  18. if (!world.provider.isSurfaceWorld()) {
  19. return;
  20. }
  21.  
  22. if (random.nextInt(10) == 0) {
  23. int posX = (chunkX * 16) + 8;
  24. int posZ = (chunkZ * 16) + 8;
  25. int posY = (world.getTopSolidOrLiquidBlock(new BlockPos(posX + offset(8, random), 0, posZ + offset(8, random))).getY());
  26.  
  27. for (int i = 0; i < (random.nextInt(8)) + 8; i++) {
  28. BlockPos pos = new BlockPos(posX + offset(8, random), posY, posZ + offset(8, random));
  29. if (world.isAirBlock(new BlockPos(posX + offset(8, random), posY, posZ + offset(8, random))) && (!world.provider.getHasNoSky() || pos.getY() < 255)) {
  30. if (world.getBlockState(pos.down()).getBlock() == Blocks.GRASS || world.getBlockState(pos.down()).getBlock() == Blocks.DIRT || world.getBlockState(pos.down()).getBlock() == Blocks.SAND || world.getBlockState(pos.down()).getBlock() == Blocks.STONE) {
  31. if (!(world.getBlockState(pos).getBlock() == Blocks.WATER) || !(world.getBlockState(pos).getBlock() == Blocks.LAVA)) {
  32. if (!(world.getBlockState(pos.down()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.up()).getBlock() == Blocks.AIR)) {
  33. if ((world.getBlockState(pos.east()).getBlock() == Blocks.AIR) || !(world.getBlockState(pos.north()).getBlock() == Blocks.AIR) || !(world.getBlockState(pos.south()).getBlock() == Blocks.AIR)|| !(world.getBlockState(pos.west()).getBlock() == Blocks.AIR)){
  34. world.setBlockState(pos, ModBlocks.rocks.getDefaultState());
  35. }
  36. }
  37. }
  38. }
  39. }
  40. }
  41. }
  42. }
  43.  
  44. public int offset(int bound, Random rand) {
  45. return rand.nextInt(bound * 2) - bound;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement