Guest User

Untitled

a guest
Sep 1st, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. package com.mightydanp.eot.common.world.gen.feature;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.mightydanp.eot.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 WorldGenTwigs 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(7) == 0) {
  23. int posX = (chunkX *16)+8;
  24. int posY = (world.getActualHeight());
  25. int posZ = (chunkZ *16)+8;
  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.  
  30. if (world.isAirBlock(new BlockPos(posX, posY, posZ)) && (!world.provider.getHasNoSky() || pos.getY() < 255) && Blocks.WATERLILY.canPlaceBlockAt(world, new BlockPos(posX, posY, posZ))) {
  31. world.setBlockState(pos, ModBlocks.twigs.getDefaultState());
  32. }
  33. }
  34. }
  35. }
  36.  
  37. public int offset(int bound, Random rand) {
  38.  
  39. return rand.nextInt(bound * 2) - bound;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment