Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class WorldGenTwigsAndRocks extends WorldGenerator {
- private Block getBlock;
- private IBlockState state;
- public WorldGenTwigsAndRocks(Block setBlock) {
- this.getBlock = setBlock;
- this.state = setBlock.getDefaultState();
- }
- public boolean generate(World worldIn, Random rand, BlockPos position) {
- for (int i = 0; i < 32; i++) {
- BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
- IBlockState getBlockState = worldIn.getBlockState(blockpos.down());
- Material getMaterial = getBlockState.getMaterial();
- if (worldIn.isAirBlock(blockpos) && blockpos.getY() < 255 && blockpos.getY() > 0 && (getMaterial == Material.GRASS || getMaterial == Material.CLAY || getMaterial == Material.GROUND || getMaterial == Material.ROCK || getMaterial == Material.SAND) && !worldIn.isAirBlock(blockpos.down())) {
- worldIn.setBlockState(blockpos, state, 2);
- }
- }
- return true;
- }
- public int offset(int bound, Random rand) {
- return rand.nextInt(bound * 2) - bound;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement