net.minecraft.block.BlockLeaves Java Examples

The following examples show how to use net.minecraft.block.BlockLeaves. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldGenBamboo.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public boolean generate(World worldIn, Random rand, BlockPos position) {
    int i = 9 + rand.nextInt(9);

    for (int i2 = 0; i2 < i; ++i2) {
        BlockPos blockpos = position.up(i2);
        if ((BlockLoader.BAMBOOSHOOT.canBlockStay(worldIn, blockpos)||
        		worldIn.getBlockState(blockpos.down()).getBlock() instanceof BlockPlantBamboo) && 
        (worldIn.isAirBlock(blockpos) || 
        		worldIn.getBlockState(blockpos).getMaterial() == Material.PLANTS
        		&& !(worldIn.getBlockState(blockpos).getBlock() instanceof BlockLeaves))) {
            worldIn.setBlockState(blockpos, BlockLoader.BAMBOO.getDefaultState(), 2);
        }
    }
    return true;
}
 
Example #2
Source File: EntityVortex.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onUpdate(){
    oldMotionX = motionX;
    oldMotionY = motionY;
    oldMotionZ = motionZ;
    super.onUpdate();
    //blowOtherEntities();
    motionX *= 0.95D;// equal to the potion effect friction. 0.95F
    motionY *= 0.95D;
    motionZ *= 0.95D;
    if(motionX * motionX + motionY * motionY + motionZ * motionZ < 0.1D) {
        setDead();
    }
    if(!worldObj.isRemote) {
        int blockX = (int)Math.floor(posX);
        int blockY = (int)Math.floor(posY);
        int blockZ = (int)Math.floor(posZ);
        for(int i = 0; i < 7; i++) { // to 7 so the middle block will also trigger (with UNKNOWN direction)
            Block block = worldObj.getBlock(blockX + ForgeDirection.getOrientation(i).offsetX, blockY + ForgeDirection.getOrientation(i).offsetY, blockZ + ForgeDirection.getOrientation(i).offsetZ);
            if(block instanceof IPlantable || block instanceof BlockLeaves) {
                worldObj.func_147480_a(blockX + ForgeDirection.getOrientation(i).offsetX, blockY + ForgeDirection.getOrientation(i).offsetY, blockZ + ForgeDirection.getOrientation(i).offsetZ, true);
            }
        }
    }

}
 
Example #3
Source File: BlockMapleSaplingGreen.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
	WorldGenerator treeGenerator = rand.nextInt(8) == 0
			? new WorldGenMapleTreeGreen(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
					BlockLoader.MAPLE_LEAVE_GREEN.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false)
							.withProperty(BlockLeaves.DECAYABLE, true),
					BlockLoader.FALLEN_LEAVES_MAPLE_GREEN.getDefaultState(), true)
			: new WorldGenMapleTreeGreen(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
					BlockLoader.MAPLE_LEAVE_GREEN.getDefaultState()
							.withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
					BlockLoader.FALLEN_LEAVES_MAPLE_GREEN.getDefaultState(), false);

	world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);

	if (!treeGenerator.generate(world, rand, pos)) {

		world.setBlockState(pos, state, 4);

	}
}
 
Example #4
Source File: TreeChopTask.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static int isLogBlock(IBlockState blockState) {
    if(blockState.getMaterial() == Material.AIR) {
        return 0;
    }
    if(blockState.getBlock() instanceof BlockLog) {
        return 1;
    } else if(blockState.getBlock() instanceof BlockLeaves) {
        return 2;
    }
    Item itemBlock = Item.getItemFromBlock(blockState.getBlock());
    ItemStack blockStack = new ItemStack(itemBlock, 1, blockState.getBlock().damageDropped(blockState));
    Set<String> blocks = OreDictUnifier.getOreDictionaryNames(blockStack);
    if(blocks.contains("logWood")) {
        return 1;
    } else if(blocks.contains("treeLeaves")) {
        return 2;
    } else return 0;
}
 
Example #5
Source File: EntityVortex.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onImpact(MovingObjectPosition objectPosition){
    if(objectPosition.entityHit != null) {
        Entity entity = objectPosition.entityHit;
        entity.motionX += motionX;
        entity.motionY += motionY;
        entity.motionZ += motionZ;
        if(!entity.worldObj.isRemote && entity instanceof IShearable) {
            IShearable shearable = (IShearable)entity;
            int x = (int)Math.floor(posX);
            int y = (int)Math.floor(posY);
            int z = (int)Math.floor(posZ);
            if(shearable.isShearable(null, worldObj, x, y, z)) {
                List<ItemStack> drops = shearable.onSheared(null, worldObj, x, y, z, 0);
                for(ItemStack stack : drops) {
                    PneumaticCraftUtils.dropItemOnGround(stack, worldObj, entity.posX, entity.posY, entity.posZ);
                }
            }
        }

    } else {
        Block block = worldObj.getBlock(objectPosition.blockX, objectPosition.blockY, objectPosition.blockZ);
        if(block instanceof IPlantable || block instanceof BlockLeaves) {
            motionX = oldMotionX;
            motionY = oldMotionY;
            motionZ = oldMotionZ;
        } else {
            setDead();
        }
    }
    hitCounter++;
    if(hitCounter > 20) setDead();
}
 
Example #6
Source File: WorldGenBigMaple.java    From Sakura_mod with MIT License 5 votes vote down vote up
/**
 * Generates the leaves surrounding an individual entry in the leafNodes list.
 */
void generateLeafNode(BlockPos pos)
{
    for (int i = 0; i < this.leafDistanceLimit; ++i)
    {
        this.crosSection(pos.up(i), this.leafSize(i), metaLeaves.withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false)));
    }
}
 
Example #7
Source File: ItemBuildersWand.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void placeHelperBlock(EntityPlayer player)
{
    BlockPos pos = PositionUtils.getPositionInfrontOfEntity(player);
    //player.worldObj.setBlockState(pos, Blocks.RED_MUSHROOM_BLOCK.getDefaultState(), 3);
    player.getEntityWorld().setBlockState(pos, Blocks.LEAVES.getDefaultState()
            .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.SPRUCE)
            .withProperty(BlockLeaves.CHECK_DECAY, false)
            .withProperty(BlockLeaves.DECAYABLE, true), 3);
}
 
Example #8
Source File: WorldGenBigSakura.java    From Sakura_mod with MIT License 5 votes vote down vote up
/**
 * Generates the leaves surrounding an individual entry in the leafNodes list.
 */
void generateLeafNode(BlockPos pos)
{
    for (int i = 0; i < this.leafDistanceLimit; ++i)
    {
        this.crosSection(pos.up(i), this.leafSize(i), BlockLoader.SAKURA_LEAVES.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, true).withProperty(BlockLeaves.DECAYABLE, true));
    }
}
 
Example #9
Source File: BlockTraverseLeaves.java    From Traverse-Legacy-1-12-2 with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
    if (!Minecraft.getMinecraft().gameSettings.fancyGraphics) {
        if (!(blockAccess.getBlockState(pos.offset(side)).getBlock() instanceof BlockLeaves)) {
            return true;
        }
        return false;
    }
    return true;
}
 
Example #10
Source File: BlockTraverseLeaves.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
    if (!Minecraft.getMinecraft().gameSettings.fancyGraphics) {
        if (!(blockAccess.getBlockState(pos.offset(side)).getBlock() instanceof BlockLeaves)) {
            return true;
        }
        return false;
    }
    return true;
}
 
Example #11
Source File: BlockMapleSaplingRed.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
	WorldGenerator treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
			BlockLoader.MAPLE_LEAVE_RED.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true), BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(),
			false);
	switch (rand.nextInt(16)) {
	case 0:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_RED.getDefaultState(), BlockLoader.MAPLE_LEAVE_RED.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(), true);
		break;
	case 1:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_RED.getDefaultState(), BlockLoader.MAPLE_LEAVE_RED.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(), false);
		break;
	case 2:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_RED.getDefaultState(), BlockLoader.MAPLE_LEAVE_RED.getDefaultState(),
				BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(), false);
		break;
	case 3:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_RED.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(), true);
		break;
	case 4:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_RED.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(), true);
		break;
	case 5:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_RED.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_RED.getDefaultState(), true);
		break;
	default:
		break;
	}
	world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);
	if (!treeGenerator.generate(world, rand, pos)) {
		world.setBlockState(pos, state, 4);
	}
}
 
Example #12
Source File: Leaves.java    From minecraft-roguelike with GNU General Public License v3.0 4 votes vote down vote up
public static MetaBlock get(Wood type, boolean decay){
	
	Block base = getBlockId(type);
	
	MetaBlock leaf = new MetaBlock(base);
	
	// Original minecraft leaves use a different variant property than
	// newer leaves like acacia and dark oak.
	if(base == Blocks.LEAVES){
		leaf.withProperty(BlockOldLeaf.VARIANT, getType(type));	
	} else {
		leaf.withProperty(BlockNewLeaf.VARIANT, getType(type));
	}
	
	leaf.withProperty(BlockLeaves.DECAYABLE, decay);
	
	return leaf;
	
}
 
Example #13
Source File: BlockMapleSaplingOrange.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
	WorldGenerator treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
			BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
			BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), false);
	switch (rand.nextInt(16)) {
	case 0:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_ORANGE.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), true);
		break;
	case 1:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_ORANGE.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), false);
		break;
	case 2:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_ORANGE.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), false);
		break;
	case 3:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), true);
		break;
	case 4:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState(),
				BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), true);
		break;
	case 5:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_ORANGE.getDefaultState(),
				BlockLoader.FALLEN_LEAVES_MAPLE_ORANGE.getDefaultState(), true);
		break;
	default:
		break;
	}
	world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);
	if (!treeGenerator.generate(world, rand, pos)) {
		world.setBlockState(pos, state, 4);
	}
}
 
Example #14
Source File: BlockMapleSaplingYellow.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
	WorldGenerator treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
			BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
			BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), false);
	switch (rand.nextInt(16)) {
	case 0:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_YELLOW.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), true);
		break;
	case 1:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_YELLOW.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), false);
		break;
	case 2:
		treeGenerator = new WorldGenBigMaple(true, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_SAPLING_YELLOW.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), false);
		break;
	case 3:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), true);
		break;
	case 4:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), true);
		break;
	case 5:
		treeGenerator = new WorldGenMapleTree(true, 5, BlockLoader.MAPLE_LOG.getDefaultState(),
				BlockLoader.MAPLE_LEAVE_YELLOW.getDefaultState().withProperty(BlockLeaves.CHECK_DECAY, false).withProperty(BlockLeaves.DECAYABLE, true),
				BlockLoader.FALLEN_LEAVES_MAPLE_YELLOW.getDefaultState(), true);
		break;
	default:
		break;
	}
	world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);
	if (!treeGenerator.generate(world, rand, pos)) {
		world.setBlockState(pos, state, 4);
	}
}
 
Example #15
Source File: WorldGenBigMaple.java    From Sakura_mod with MIT License 4 votes vote down vote up
/**
 * Fill the given area with the selected blocks
 */
private void fallenLeaves(World worldIn,BlockPos pos, int xADD, int yADD, int zADD, IBlockState insideBlockState){
	int xx = pos.getX();
    int yy = pos.getY();
    int zz = pos.getZ();
    
    boolean setFlg = false;
    int YEND = 4;
    for (int xx1 = xx - xADD; xx1 <= xx + xADD; xx1++) {
      for (int zz1 = zz - zADD; zz1 <= zz + zADD; zz1++) {
        if (((xx1 != xx - xADD) || (zz1 != zz - zADD)) && ((xx1 != xx + xADD) || (zz1 != zz - zADD)) && ((xx1 != xx - xADD) || (zz1 != zz + zADD)) && ((xx1 != xx + xADD) || (zz1 != zz + zADD)) && (((xx1 >= xx - xADD + 1) && (xx1 <= xx + xADD - 1) && (zz1 >= zz - zADD + 1) && (zz1 <= zz + zADD - 1)) || (worldIn.rand.nextInt(2) != 0)))
        {
          setFlg = false;
          int yy1 = yy + yADD;
          Block cBl = worldIn.getBlockState(new BlockPos(xx1, yy + yADD, zz1)).getBlock();
          
          if ((cBl == Blocks.AIR) || (cBl instanceof BlockLeaves) || (cBl == BlockLoader.CHESTNUTBURR)) {
            for (yy1 = yy + yADD; yy1 >= yy - YEND; yy1--)
            {
              boolean cAir = worldIn.isAirBlock(new BlockPos(xx1, yy1, zz1));
              cBl = worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).getBlock();
              if ((cBl == Blocks.AIR) || ((cBl != Blocks.GRASS) && !(cBl instanceof BlockLeaves) && (!worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).isOpaqueCube())))
              {
                if (cBl != Blocks.AIR) {
                  break;
                }
              }
              else if (cAir)
              {
                setFlg = true;
                break;
              }
            }
          }
          if (setFlg) {
            setBlockAndNotifyAdequately(worldIn, new BlockPos(xx1, yy1, zz1), insideBlockState);
          }
        }
      }
    }
}
 
Example #16
Source File: WorldGenMapleTree.java    From Sakura_mod with MIT License 4 votes vote down vote up
/**
 * Fill the given area with the selected blocks
 */
private void fallenLeaves(World worldIn,BlockPos pos, int xADD, int yADD, int zADD, IBlockState insideBlockState){
	int xx = pos.getX();
    int yy = pos.getY();
    int zz = pos.getZ();
    
    boolean setFlg = false;
    int YEND = 4;
    for (int xx1 = xx - xADD; xx1 <= xx + xADD; xx1++) {
      for (int zz1 = zz - zADD; zz1 <= zz + zADD; zz1++) {
        if (((xx1 != xx - xADD) || (zz1 != zz - zADD)) && ((xx1 != xx + xADD) || (zz1 != zz - zADD)) && ((xx1 != xx - xADD) || (zz1 != zz + zADD)) && ((xx1 != xx + xADD) || (zz1 != zz + zADD)) && (((xx1 >= xx - xADD + 1) && (xx1 <= xx + xADD - 1) && (zz1 >= zz - zADD + 1) && (zz1 <= zz + zADD - 1)) || (worldIn.rand.nextInt(2) != 0)))
        {
          setFlg = false;
          int yy1 = yy + yADD;
          Block cBl = worldIn.getBlockState(new BlockPos(xx1, yy + yADD, zz1)).getBlock();
          
          if ((cBl == Blocks.AIR) || (cBl instanceof BlockLeaves) || (cBl == BlockLoader.CHESTNUTBURR)) {
            for (yy1 = yy + yADD; yy1 >= yy - YEND; yy1--)
            {
              boolean cAir = worldIn.isAirBlock(new BlockPos(xx1, yy1, zz1));
              cBl = worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).getBlock();
              if ((cBl == Blocks.AIR) || ((cBl != Blocks.GRASS) && !(cBl instanceof BlockLeaves) && (!worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).isOpaqueCube())))
              {
                if (cBl != Blocks.AIR) {
                  break;
                }
              }
              else if (cAir)
              {
                setFlg = true;
                break;
              }
            }
          }
          if (setFlg) {
            setBlockAndNotifyAdequately(worldIn, new BlockPos(xx1, yy1, zz1), insideBlockState);
          }
        }
      }
    }
}
 
Example #17
Source File: WorldGenMapleTreeGreen.java    From Sakura_mod with MIT License 4 votes vote down vote up
/**
 * Fill the given area with the selected blocks
 */
private void fallenLeaves(World worldIn,BlockPos pos, int xADD, int yADD, int zADD, IBlockState insideBlockState){
	int xx = pos.getX();
    int yy = pos.getY();
    int zz = pos.getZ();
    
    boolean setFlg = false;
    int YEND = 4;
    for (int xx1 = xx - xADD; xx1 <= xx + xADD; xx1++) {
      for (int zz1 = zz - zADD; zz1 <= zz + zADD; zz1++) {
        if (((xx1 != xx - xADD) || (zz1 != zz - zADD)) && ((xx1 != xx + xADD) || (zz1 != zz - zADD)) && ((xx1 != xx - xADD) || (zz1 != zz + zADD)) && ((xx1 != xx + xADD) || (zz1 != zz + zADD)) && (((xx1 >= xx - xADD + 1) && (xx1 <= xx + xADD - 1) && (zz1 >= zz - zADD + 1) && (zz1 <= zz + zADD - 1)) || (worldIn.rand.nextInt(2) != 0)))
        {
          setFlg = false;
          int yy1 = yy + yADD;
          Block cBl = worldIn.getBlockState(new BlockPos(xx1, yy + yADD, zz1)).getBlock();
          
          if ((cBl == Blocks.AIR) || (cBl instanceof BlockLeaves) || (cBl == BlockLoader.CHESTNUTBURR)) {
            for (yy1 = yy + yADD; yy1 >= yy - YEND; yy1--)
            {
              boolean cAir = worldIn.isAirBlock(new BlockPos(xx1, yy1, zz1));
              cBl = worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).getBlock();
              if ((cBl == Blocks.AIR) || ((cBl != Blocks.GRASS) && !(cBl instanceof BlockLeaves) && (!worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).isOpaqueCube())))
              {
                if (cBl != Blocks.AIR) {
                  break;
                }
              }
              else if (cAir)
              {
                setFlg = true;
                break;
              }
            }
          }
          if (setFlg) {
            setBlockAndNotifyAdequately(worldIn, new BlockPos(xx1, yy1, zz1), insideBlockState);
          }
        }
      }
    }
}