Exemplo n.º 1
0
  /**
   * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack,
   * world, entityPlayer
   */
  @Override
  public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer entity) {
    MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, entity, true);
    FoodStatsTFC fs = TFC_Core.getPlayerFoodStats(entity);

    if (mop == null) {
      if (is.getItemDamage() > 1 && fs.needDrink()) {
        entity.setItemInUse(is, this.getMaxItemUseDuration(is));
      }
    } else {
      if (mop.typeOfHit == EnumMovingObjectType.TILE) {
        int i = mop.blockX;
        int j = mop.blockY;
        int k = mop.blockZ;
        if (world.getBlockTileEntity(i, j, k) != null
            && world.getBlockTileEntity(i, j, k) instanceof TEBarrel) {
          TEBarrel TE = (TEBarrel) world.getBlockTileEntity(i, j, k);
          if (TE.checkValidAddition(13)) {
            return new ItemStack(TFCItems.WoodenBucketEmpty);
          }
        }
      }
    }
    return is;
  }
Exemplo n.º 2
0
  @Override
  public ItemStack onEaten(ItemStack is, World world, EntityPlayer player) {
    FoodStatsTFC foodstats = TFC_Core.getPlayerFoodStats(player);
    if (!world.isRemote && foodstats.needFood()) {

      world.playSoundAtEntity(player, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);

      foodstats.eatFood(is);
      foodstats.restoreWater(player, 8000);

      TFC_Core.setPlayerFoodStats(player, foodstats);

      is.itemID = TFCItems.WoodenBucketEmpty.itemID;
      is.stackTagCompound = null;
    }
    return is;
  }