/** Called when the block is attempted to be harvested */
  public void onBlockHarvested(World world, int x, int y, int z, int i, EntityPlayer f) {
    if (func_149887_c(i)) {
      if (world.getBlock(x, y - 1, z) == this) {
        if (!f.capabilities.isCreativeMode) {
          int i1 = world.getBlockMetadata(x, y - 1, z);
          int j1 = func_149890_d(i1);

          if (j1 != 3 && j1 != 2) {
            world.func_147480_a(x, y - 1, z, true);
          } else {
            if (!world.isRemote
                && f.getCurrentEquippedItem() != null
                && f.getCurrentEquippedItem().getItem() == Items.shears) {
              this.func_149886_b(world, x, y, z, i1, f);
            }

            world.setBlockToAir(x, y - 1, z);
          }
        } else {
          world.setBlockToAir(x, y - 1, z);
        }
      }
    } else if (f.capabilities.isCreativeMode && world.getBlock(x, y + 1, z) == this) {
      world.setBlock(x, y + 1, z, Blocks.air, 0, 2);
    }

    super.onBlockHarvested(world, x, y, z, i, f);
  }
 /**
  * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the
  * coordinates of the block and l is the block's subtype/damage.
  */
 public void harvestBlock(World world, EntityPlayer entity, int x, int y, int z, int i) {
   if (world.isRemote
       || entity.getCurrentEquippedItem() == null
       || entity.getCurrentEquippedItem().getItem() != Items.shears
       || func_149887_c(i)
       || !this.func_149886_b(world, x, y, z, i, entity)) {
     super.harvestBlock(world, entity, x, y, z, i);
   }
 }
Esempio n. 3
0
 @Override
 public void grow(World world, BlockPos pos, IBlockState id) {
   BlockPos coord;
   for (int attempt = 0; attempt < growthAttempt; attempt++) {
     coord = Utils.findRandomNeighbour(pos, growthRadius);
     if (id.getBlock().canPlaceBlockAt(world, coord)
         && !world.getBlockState(coord).getBlock().getMaterial().isLiquid()) {
       if (id.getBlock() instanceof BlockDoublePlant) {
         if (world.getBlockState(pos.down()).equals(id)) {
           pos = pos.down();
         }
         ((BlockDoublePlant) id)
             .placeAt(world, coord, ((BlockDoublePlant) id).getVariant(world, pos), 3);
         return;
       }
       world.setBlockState(coord, id);
       return;
     }
   }
 }