Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 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. import com.mightydanp.eot.common.lib.Reference;
  7. import com.mightydanp.eot.common.logger.EoTLogger;
  8.  
  9. import net.minecraft.util.math.BlockPos;
  10. import net.minecraft.world.World;
  11. import net.minecraft.world.chunk.IChunkGenerator;
  12. import net.minecraft.world.chunk.IChunkProvider;
  13. import net.minecraftforge.fml.common.IWorldGenerator;
  14.  
  15. public class WorldGenTwigs implements IWorldGenerator {
  16.  
  17. @Override
  18. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
  19. if (!world.provider.isSurfaceWorld()) {
  20. return;
  21. }
  22.  
  23. if (random.nextInt(7) == 0) {
  24. int posX = (chunkX *16)+8;
  25. int posY = (world.getActualHeight());
  26. int posZ = (chunkZ *16)+8;
  27.  
  28. for (int i = 0; i < (random.nextInt(8)) + 8; i++) {
  29. BlockPos pos = new BlockPos(posX + offset(8, random), posY, posZ + offset(8, random));
  30.  
  31. if (world.isAirBlock(new BlockPos(posX + offset(8, random), posY, posZ + offset(8, random))) && (!world.provider.getHasNoSky() || pos.getY() < 255) && ModBlocks.twigs.canPlaceBlockAt(world, new BlockPos(posX, posY, posZ))) {
  32. EoTLogger.logInfoMessage(Reference.MODID + ":" + "Generating Twigs:"+ " X:" + pos.getX() + " Y:" + pos.getY() + " Z:" + pos.getZ());
  33. world.setBlockState(pos, ModBlocks.twigs.getDefaultState());
  34. }
  35. }
  36. }
  37. }
  38.  
  39. public int offset(int bound, Random rand) {
  40.  
  41. return rand.nextInt(bound * 2) - bound;
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement