content: package net.minecraft.block;
  
  import net.minecraft.block.material.Material;
  import net.minecraft.block.properties.IProperty;
  import net.minecraft.block.properties.PropertyInteger;
  import net.minecraft.block.state.BlockState;
  import net.minecraft.block.state.IBlockState;
  import net.minecraft.creativetab.CreativeTabs;
  import net.minecraft.entity.Entity;
  import net.minecraft.init.Blocks;
  import net.minecraft.util.*;
  import net.minecraft.world.World;
  
  import java.util.Random;
  
  public class BlockCactus extends Block {
      public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15);
  
      protected BlockCactus() {
          super(Material.cactus);
          this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));
          this.setTickRandomly(true);
          this.setCreativeTab(CreativeTabs.tabDecorations);
      }
  
      public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
          BlockPos blockpos = pos.up();
  
          if (worldIn.isAirBlock(blockpos)) {
              int i;
  
              for (i = 1; worldIn.getBlockState(pos.down(i)).getBlock() == this; ++i) {
              }
  
              if (i < 3) {
                  int j = state.getValue(AGE).intValue();
  
                  if (j == 15) {
                      worldIn.setBlockState(blockpos, this.getDefaultState());
                      IBlockState iblockstate = state.withProperty(AGE, Integer.valueOf(0));
                      worldIn.setBlockState(pos, iblockstate, 4);
                      this.onNeighborBlockChange(worldIn, blockpos, iblockstate, this);
                  } else {
                      worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(j + 1)), 4);
                  }
              }
          }
      }
  
      public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) {
          float f = 0.0625F;
          return new AxisAlignedBB((float) pos.getX() + f, pos.getY(), (float) pos.getZ() + f, (float) (pos.getX() + 1) - f, (float) (pos.getY() + 1) - f, (float) (pos.getZ() + 1) - f);
      }
  
      public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos) {
          float f = 0.0625F;
          return new AxisAlignedBB((float) pos.getX() + f, pos.getY(), (float) pos.getZ() + f, (float) (pos.getX() + 1) - f, pos.getY() + 1, (float) (pos.getZ() + 1) - f);
      }
  
      public boolean isFullCube() {
          return false;
      }
  
      public boolean isOpaqueCube() {
          return false;
      }
  
      public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
          return super.canPlaceBlockAt(worldIn, pos) && this.canBlockStay(worldIn, pos);
      }
  
      public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) {
          if (!this.canBlockStay(worldIn, pos)) {
              worldIn.destroyBlock(pos, true);
          }
      }
  
      public boolean canBlockStay(World worldIn, BlockPos pos) {
          for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) {
              if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock().getMaterial().isSolid()) {
                  return false;
              }
          }
  
          Block block = worldIn.getBlockState(pos.down()).getBlock();
          return block == Blocks.cactus || block == Blocks.sand;
      }
  
      public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
          entityIn.attackEntityFrom(DamageSource.cactus, 1.0F);
      }
  
      public EnumWorldBlockLayer getBlockLayer() {
          return EnumWorldBlockLayer.CUTOUT;
      }
  
      public IBlockState getStateFromMeta(int meta) {
          return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
      }
  
      public int getMetaFromState(IBlockState state) {
          return state.getValue(AGE).intValue();
      }
  
      protected BlockState createBlockState() {
          return new BlockState(this, AGE);
      }
  }
  