Advertisement
NathanHam89

FireClayGen

Apr 19th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1. package com.penumbral.steelworks.world;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.minecraft.block.Block;
  6. import net.minecraft.block.material.Material;
  7. import net.minecraft.init.Blocks;
  8. import net.minecraft.util.BlockPos;
  9. import net.minecraft.world.World;
  10. import net.minecraft.world.gen.feature.WorldGenerator;
  11.  
  12. import com.penumbral.steelworks.init.SteelworksBlocks;
  13.  
  14. public class FireClayGen extends WorldGenerator{
  15.    
  16.     private final Block blockToGen;
  17.     private final int numberOfBlocks;
  18.    
  19.     public FireClayGen(Block block, int p_i2011_1_)
  20.     {
  21.         this.blockToGen = SteelworksBlocks.fire_clayblock;
  22.         this.numberOfBlocks = p_i2011_1_;
  23.     }
  24.  
  25.         public boolean generateClay(World world1, Random rand, BlockPos pos)
  26.         {
  27.             if (world1.getBlockState(pos).getBlock().getMaterial() != Material.water)
  28.             {
  29.                 return false;
  30.             }
  31.             else
  32.             {
  33.                 int i = rand.nextInt(this.numberOfBlocks - 2) + 2;
  34.                 byte b0 = 1;
  35.  
  36.                 for (int j = pos.getX() - i; j <= pos.getX() + i; ++j)
  37.                 {
  38.                     for (int k = pos.getZ() - i; k <= pos.getZ() + i; ++k)
  39.                     {
  40.                         int l = j - pos.getX();
  41.                         int i1 = k - pos.getZ();
  42.  
  43.                         if (l * l + i1 * i1 <= i * i)
  44.                         {
  45.                             for (int j1 = pos.getY() - b0; j1 <= pos.getY() + b0; ++j1)
  46.                             {
  47.                                 BlockPos blockpos1 = new BlockPos(j, j1, k);
  48.                                 Block block = world1.getBlockState(blockpos1).getBlock();
  49.  
  50.                                 if (block == Blocks.dirt || block == blockToGen)
  51.                                 {
  52.                                     world1.setBlockState(blockpos1, this.blockToGen.getDefaultState(), 2);
  53.                                 }
  54.                             }
  55.                         }
  56.                     }
  57.                 }
  58.  
  59.                 return false;
  60.             }
  61.       }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement