示例#1
0
  @Override
  public void handleDataPacket(NBTTagCompound nbt) {
    if (!worldObj.isRemote) {
      if (nbt.hasKey("fluidID")) {
        if (nbt.getByte("fluidID") == -1) fluid = null;
      } else if (nbt.hasKey("mode")) {
        mode = nbt.getByte("mode");
      } else if (nbt.hasKey("seal")) {
        sealed = nbt.getBoolean("seal");
        if (!sealed) {
          unsealtime = (int) TFC_Time.getTotalHours();
          sealtime = 0;
        } else {
          sealtime = (int) TFC_Time.getTotalHours();
          unsealtime = 0;
        }
      }

      if (nbt.hasKey("tab")) {
        int tab = nbt.getByte("tab");
        if (tab == 0)
          worldObj
              .getPlayerEntityByName(nbt.getString("player"))
              .openGui(TerraFirmaCraft.instance, 35, worldObj, xCoord, yCoord, zCoord);
        else if (tab == 1)
          worldObj
              .getPlayerEntityByName(nbt.getString("player"))
              .openGui(TerraFirmaCraft.instance, 36, worldObj, xCoord, yCoord, zCoord);
      }
    }
  }
  public EntityChickenTFC(World par1World) {
    super(par1World);
    this.setSize(0.3F, 0.7F);
    this.timeUntilNextEgg = 9999; // Here we set the vanilla egg timer to 9999
    this.nextEgg = TFC_Time.getTotalTicks() + EggTime;
    hunger = 168000;
    mateSizeMod = 1f;
    sex = rand.nextInt(2);

    this.tasks.taskEntries.clear();
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIPanic(this, 1.4D));
    this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D));
    this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
    this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
    this.tasks.addTask(7, new EntityAILookIdle(this));
    this.tasks.addTask(6, this.aiEatGrass);
    addAI();

    size_mod =
        (((rand.nextInt((degreeOfDiversion + 1) * 10) * (rand.nextBoolean() ? 1 : -1)) / 100f) + 1F)
            * (1.0F - 0.1F * sex);

    //	We hijack the growingAge to hold the day of birth rather
    //	than number of ticks to next growth event. We want spawned
    //	animals to be adults, so we set their birthdays far enough back
    //	in time such that they reach adulthood now.
    //
    this.setAge((int) TFC_Time.getTotalDays() - getNumberOfDaysToAdult());
    // For Testing Only(makes spawned animals into babies)
    // this.setGrowingAge((int) TFC_Time.getTotalDays());
  }
 public ItemStack getEggs() {
   if (TFC_Time.getTotalTicks() >= this.nextEgg) {
     this.nextEgg = TFC_Time.getTotalTicks() + EggTime;
     return new ItemStack(TFCItems.Egg, 1);
   }
   return null;
 }
示例#4
0
  public void ProcessItems() {
    if (this.getInvCount() == 0) {
      if (getFluidStack() != null) {
        recipe =
            BarrelManager.getInstance()
                .findMatchingRecipe(getInputStack(), getFluidStack(), this.sealed);
        if (recipe != null && !worldObj.isRemote) {
          int time = 0;
          if (sealtime > 0) time = (int) TFC_Time.getTotalHours() - sealtime;
          else if (unsealtime > 0) time = (int) TFC_Time.getTotalHours() - unsealtime;

          // Make sure that the recipe meets the time requirements
          if (recipe.isSealedRecipe() && time < recipe.sealTime) return;

          ItemStack origIS = getInputStack().copy();
          FluidStack origFS = getFluidStack().copy();
          if (fluid.isFluidEqual(recipe.getResultFluid(origIS, origFS, time))) {
            fluid.amount -= recipe.getResultFluid(origIS, origFS, time).amount;
          } else {
            this.fluid = recipe.getResultFluid(origIS, origFS, time);
            this.fluid.amount = origFS.amount;
          }
          this.setInventorySlotContents(0, recipe.getResult(origIS, origFS, time));
        }
      }
    }
  }
示例#5
0
  /**
   * We have to handle cheese by itself because the barrel recipe manager doesnt take kindly to null
   * input items.
   */
  private boolean handleCheese() {
    ItemStack inIS = this.getInputStack();
    if (this.getSealed()
        && this.fluid != null
        && this.fluid.getFluid() == TFCFluids.MILKCURDLED
        && (inIS == null
            || inIS.getItem() instanceof IFood
                && ((IFood) inIS.getItem()).getFoodGroup() != EnumFoodGroup.Dairy
                && ((IFood) inIS.getItem()).isEdible(inIS)
                && Food.getWeight(inIS) <= 20.0f)) {
      recipe =
          new BarrelRecipe(
                  null,
                  new FluidStack(TFCFluids.MILKCURDLED, 10000),
                  ItemFoodTFC.createTag(new ItemStack(TFCItems.cheese, 1), 160),
                  null)
              .setMinTechLevel(0);
      if (!worldObj.isRemote) {
        int time = 0;
        if (sealtime > 0) time = (int) TFC_Time.getTotalHours() - sealtime;
        else if (unsealtime > 0) time = (int) TFC_Time.getTotalHours() - unsealtime;

        // Make sure that the recipe meets the time requirements
        if (time < recipe.sealTime) return true;
        float w = this.fluid.amount / 62.5f;

        ItemStack is = ItemFoodTFC.createTag(new ItemStack(TFCItems.cheese), w);

        if (inIS != null && inIS.getItem() instanceof IFood) {
          int[] profile = Food.getFoodTasteProfile(inIS);
          float ratio =
              Math.min(
                  (Food.getWeight(getInputStack()) - Food.getDecay(inIS))
                      / (Global.FOOD_MAX_WEIGHT / 8),
                  1.0f);
          Food.setSweetMod(is, (int) Math.floor(profile[INPUT_SLOT] * ratio));
          Food.setSourMod(is, (int) Math.floor(profile[1] * ratio));
          Food.setSaltyMod(is, (int) Math.floor(profile[2] * ratio));
          Food.setBitterMod(is, (int) Math.floor(profile[3] * ratio));
          Food.setSavoryMod(is, (int) Math.floor(profile[4] * ratio));
          Food.setInfusion(is, inIS.getItem().getUnlocalizedName());
          this.storage[INPUT_SLOT] = null;
        }

        this.actionEmpty();
        this.setInventorySlotContents(0, is);
      }
      return true;
    }
    return false;
  }
 public void roosterCrow() {
   if ((TFC_Time.getTotalTicks() - 15) % TFC_Time.dayLength == 0
       && getGender() == GenderEnum.MALE
       && isAdult()) {
     this.playSound(TFC_Sounds.ROOSTERCROW, 10, rand.nextFloat() + 0.5F);
   }
 }
示例#7
0
 @Override
 public void setInventorySlotContents(int i, ItemStack is) {
   storage[i] = is;
   if (i == 0) {
     ProcessItems();
     if (!getSealed()) this.unsealtime = (int) TFC_Time.getTotalHours();
   }
 }
示例#8
0
  @Override
  public void handleDataPacket(NBTTagCompound nbt) {
    if (nbt.hasKey("fluidID")) {
      if (nbt.getByte("fluidID") == -1) fluid = null;
      worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
    }
    if (!worldObj.isRemote) {
      if (nbt.hasKey("mode")) {
        mode = nbt.getByte("mode");
      } else if (nbt.hasKey("seal")) {
        sealed = nbt.getBoolean("seal");
        if (!sealed) {
          unsealtime = (int) TFC_Time.getTotalHours();
          sealtime = 0;
        } else {
          sealtime = (int) TFC_Time.getTotalHours();
          unsealtime = 0;
        }

        // Broadcast the seal time to update the client
        NBTTagCompound timeTag = new NBTTagCompound();
        timeTag.setInteger("SealTime", sealtime);
        this.broadcastPacketInRange(this.createDataPacket(timeTag));

        worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
      }

      if (nbt.hasKey("tab")) {
        int tab = nbt.getByte("tab");
        switchTab(worldObj.getPlayerEntityByName(nbt.getString("player")), tab);
      }
    } else {
      // Get the seal time for the client display
      if (nbt.hasKey("SealTime")) sealtime = nbt.getInteger("SealTime");
    }
  }
示例#9
0
 @Override
 public void onBlockPlacedBy(
     World world, int x, int y, int z, EntityLivingBase entity, ItemStack is) {
   TileEntity _t = world.getTileEntity(x, y, z);
   if (_t != null && _t instanceof TEOilLamp) {
     ((TEOilLamp) _t).create();
     FluidStack fs = FluidStack.loadFluidStackFromNBT(is.getTagCompound());
     if (fs != null) {
       ((TEOilLamp) _t).setFuelFromStack(fs);
     } else {
       // world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z)+8, 0x3);
     }
     ((TEOilLamp) _t).hourPlaced = (int) TFC_Time.getTotalHours();
   }
 }
示例#10
0
  public EntityChickenTFC(World world, IAnimal mother, ArrayList<Float> data) {
    this(world);
    float father_size = data.get(0);
    this.posX = ((EntityLivingBase) mother).posX;
    this.posY = ((EntityLivingBase) mother).posY;
    this.posZ = ((EntityLivingBase) mother).posZ;
    size_mod =
        (((rand.nextInt(degreeOfDiversion + 1) * 10 * (rand.nextBoolean() ? 1 : -1)) / 100f) + 1F)
            * (1.0F - 0.1F * sex)
            * (float) Math.sqrt((mother.getSize() + father_size) / 1.9F);
    size_mod = Math.min(Math.max(size_mod, 0.7F), 1.3f);

    //	We hijack the growingAge to hold the day of birth rather
    //	than number of ticks to next growth event.
    //
    this.setAge((int) TFC_Time.getTotalDays());
  }
示例#11
0
 private void smokeBlock(int x, int y, int z) {
   if (worldObj.blockExists(x, y, z) && worldObj.getBlock(x, y, z) == TFCBlocks.smokeRack) {
     TESmokeRack te = (TESmokeRack) worldObj.getTileEntity(x, y, z);
     te.lastSmokedTime = (int) TFC_Time.getTotalHours();
     if (te.getStackInSlot(0) != null) {
       ItemStack is = te.getStackInSlot(0);
       if (Food.getSmokeCounter(is) < Food.SMOKEHOURS)
         Food.setSmokeCounter(is, Food.getSmokeCounter(is) + 1);
       else Food.setFuelProfile(is, EnumFuelMaterial.getFuelProfile(fuelTasteProfile));
     }
     if (te.getStackInSlot(1) != null) {
       ItemStack is = te.getStackInSlot(1);
       if (Food.getSmokeCounter(is) < Food.SMOKEHOURS)
         Food.setSmokeCounter(is, Food.getSmokeCounter(is) + 1);
       else Food.setFuelProfile(is, EnumFuelMaterial.getFuelProfile(fuelTasteProfile));
     }
   }
 }
示例#12
0
  public EntityChickenTFC(
      World world, double posX, double posY, double posZ, NBTTagCompound genes) {
    this(world);
    this.posX = posX;
    this.posY = posY;
    this.posZ = posZ;
    float m_size = genes.getFloat("m_size");
    float f_size = genes.getFloat("f_size");
    size_mod =
        (((rand.nextInt(degreeOfDiversion + 1) * (rand.nextBoolean() ? 1 : -1)) / 10f) + 1F)
            * (1.0F - 0.1F * sex)
            * (float) Math.sqrt((m_size + f_size) / 1.9F);
    // size_mod = Math.min(Math.max(size_mod, 0.7F),1.3f);

    //	We hijack the growingAge to hold the day of birth rather
    //	than number of ticks to next growth event.
    //
    this.setAge((int) TFC_Time.getTotalDays());
  }
示例#13
0
 @Override
 public boolean isAdult() {
   return getBirthDay() + getNumberOfDaysToAdult() <= TFC_Time.getTotalDays();
 }
示例#14
0
  @Override
  public int foliageColorMultiplier(IBlockAccess par1IBlockAccess, int i, int j, int k) {
    // int var5 = 0;
    // int var6 = 0;
    // int var7 = 0;
    int[] rgb = {0, 0, 0};
    float temperature =
        TFC_Climate.getHeightAdjustedTempSpecificDay(
            getCurrentWorld(), TFC_Time.getDayOfYear(), i, j, k);
    // float rainfall = TFC_Climate.getRainfall(getCurrentWorld(),i,j,k);

    int meta = par1IBlockAccess.getBlockMetadata(i, j, k);
    if (par1IBlockAccess.getBlock(i, j, k) == TFCBlocks.fruitTreeLeaves)
    //			if(TFC_Time.currentMonth >= TFC_Time.September && TFC_Time.currentMonth <
    // TFC_Time.December)
    //			{
    //				int var10 = ColorizerFoliageTFC.getFoliageYellow();
    //				rgb = applyColor(var10, rgb);
    //
    //				int x = (rgb[0] / 9 & 255) << 16 | (rgb[1] / 9 & 255) << 8 | rgb[2] / 9 & 255;
    //				return x;
    //			}
    //			else
    {
      for (int var8 = -1; var8 <= 1; ++var8) {
        for (int var9 = -1; var9 <= 1; ++var9) {
          int var10 = TFC_Climate.getFoliageColor(getCurrentWorld(), i + var8, j, k + var9);
          rgb = applyColor(var10, rgb);
        }
      }
      int x = (rgb[0] / 9 & 255) << 16 | (rgb[1] / 9 & 255) << 8 | rgb[2] / 9 & 255;
      return x;
    } else if (par1IBlockAccess.getBlock(i, j, k) == TFCBlocks.Vine) {
      if (TFC_Time.getSeasonAdjustedMonth(k) >= 6
          && TFC_Time.getSeasonAdjustedMonth(k) < 9
          && !(TFC_Climate.getCacheManager(getCurrentWorld()).getEVTLayerAt(i, k).floatdata1 < 0.8)
          && TFC_Climate.getHeightAdjustedTemp(getCurrentWorld(), i, j, k) < 30) {
        int color = 0;
        for (int var8 = -1; var8 <= 1; ++var8) {
          for (int var9 = -1; var9 <= 1; ++var9) {
            color = (TFC_Climate.getFoliageColor(getCurrentWorld(), i + var8, j, k + var9));
            rgb = applyColor(color, rgb);
          }
        }
        int x = (rgb[0] / 9 & 255) << 16 | (rgb[1] / 9 & 255) << 8 | rgb[2] / 9 & 255;
        return x;
      } else if (TFC_Time.getSeasonAdjustedMonth(k) >= 11
          || TFC_Time.getSeasonAdjustedMonth(k) <= 0
              && !(TFC_Climate.getCacheManager(getCurrentWorld()).getEVTLayerAt(i, k).floatdata1
                  < 0.8)
              && TFC_Climate.getHeightAdjustedTemp(getCurrentWorld(), i, j, k) < 30) {
        for (int var8 = -1; var8 <= 1; ++var8) {
          for (int var9 = -1; var9 <= 1; ++var9) {
            int color = (TFC_Climate.getFoliageColor(getCurrentWorld(), i + var8, j, k + var9));
            rgb = applyColor(color, rgb);
          }
        }
        int x = (rgb[0] / 9 & 255) << 16 | (rgb[1] / 9 & 255) << 8 | rgb[2] / 9 & 255;
        return x;
      } else if (TFC_Time.getSeasonAdjustedMonth(k) >= 9
          && !(TFC_Climate.getCacheManager(getCurrentWorld()).getEVTLayerAt(i, k).floatdata1 < 0.8)
          && TFC_Climate.getHeightAdjustedTemp(getCurrentWorld(), i, j, k) < 30) {
        for (int var8 = -1; var8 <= 1; ++var8) {
          for (int var9 = -1; var9 <= 1; ++var9) {
            int color = ColorizerFoliageTFC.getFoliageDead();
            rgb = applyColor(color, rgb);
          }
        }
        int x = (rgb[0] / 9 & 255) << 16 | (rgb[1] / 9 & 255) << 8 | rgb[2] / 9 & 255;
        return x;
      } else {
        for (int var8 = -1; var8 <= 1; ++var8) {
          for (int var9 = -1; var9 <= 1; ++var9) {
            int color = (TFC_Climate.getFoliageColor(getCurrentWorld(), i + var8, j, k + var9));
            rgb = applyColor(color, rgb);
          }
        }
        int x = (rgb[0] / 9 & 255) << 16 | (rgb[1] / 9 & 255) << 8 | rgb[2] / 9 & 255;
        return x;
      }
    } else if (TFC_Time.getSeasonAdjustedMonth(k) >= 6 && EnumTree.values()[meta].isEvergreen) {
      for (int var8 = -1; var8 <= 1; ++var8) {
        for (int var9 = -1; var9 <= 1; ++var9) {
          int var10 =
              TFC_Climate.getFoliageColorEvergreen(getCurrentWorld(), i + var8, j, k + var9);
          rgb = applyColor(var10, rgb);
        }
      }
      int x = (rgb[0] / 9 & 255) << 16 | (rgb[1] / 9 & 255) << 8 | rgb[2] / 9 & 255;
      return x;
    } else if (temperature <= 10
        && TFC_Time.getSeasonAdjustedMonth(k) >= 6
        && TFC_Time.getSeasonAdjustedMonth(k) < 9
        && (meta == 4 || meta == 7 || meta == 5 || meta == 14)) {
      int color = 0;
      // Get the fade multiplie
      for (int var8 = -1; var8 <= 1; ++var8) {
        for (int var9 = -1; var9 <= 1; ++var9) {
          color = ColorizerFoliageTFC.getFoliageYellow();
          rgb = applyColor(color, rgb);
        }
      }
      int x = (rgb[0] / 9 & 255) << 16 | (rgb[1] / 9 & 255) << 8 | rgb[2] / 9 & 255;
      return x;
    } else if (temperature <= 10
        && TFC_Time.getSeasonAdjustedMonth(k) >= 6
        && TFC_Time.getSeasonAdjustedMonth(k) < 9
        && (meta == 6)) {
      for (int var8 = -1; var8 <= 1; ++var8) {
        for (int var9 = -1; var9 <= 1; ++var9) {
          int var10 = ColorizerFoliageTFC.getFoliageRed();
          rgb = applyColor(var10, rgb);
        }
      }
      int x = (rgb[0] / 9 & 255) << 16 | (rgb[1] / 9 & 255) << 8 | rgb[2] / 9 & 255;
      return x;
    } else if (temperature <= 10
        && TFC_Time.getSeasonAdjustedMonth(k) >= 6
        && TFC_Time.getSeasonAdjustedMonth(k) < 9
        && !(meta == 15)) {
      for (int var8 = -1; var8 <= 1; ++var8) {
        for (int var9 = -1; var9 <= 1; ++var9) {
          int var10 = ColorizerFoliageTFC.getFoliageOrange();
          rgb = applyColor(var10, rgb);
        }
      }
      int x = (rgb[0] / 9 & 255) << 16 | (rgb[1] / 9 & 255) << 8 | rgb[2] / 9 & 255;
      return x;
    } else if (temperature <= 8 && TFC_Time.getSeasonAdjustedMonth(k) >= 6 && !(meta == 15)) {
      for (int var8 = -1; var8 <= 1; ++var8) {
        for (int var9 = -1; var9 <= 1; ++var9) {
          int var10 = ColorizerFoliageTFC.getFoliageDead();
          rgb = applyColor(var10, rgb);
        }
      }
      int x = (rgb[0] / 9 & 255) << 16 | (rgb[1] / 9 & 255) << 8 | rgb[2] / 9 & 255;
      return x;
    } else {
      for (int var8 = -1; var8 <= 1; ++var8) {
        for (int var9 = -1; var9 <= 1; ++var9) {
          int var10 = TFC_Climate.getFoliageColor(getCurrentWorld(), i + var8, j, k + var9);
          rgb = applyColor(var10, rgb);
        }
      }
      int x = (rgb[0] / 9 & 255) << 16 | (rgb[1] / 9 & 255) << 8 | rgb[2] / 9 & 255;
      return x;
    }
  }
示例#15
0
  public void processItems() {
    if (this.getInvCount() == 0) {
      // Before we handle standard barrel processing we have to see if we are handling cheese and
      // run that code first
      // since it has to be handled specially.
      boolean isCheese = handleCheese();

      if (getFluidStack() != null && !isCheese) {
        recipe =
            BarrelManager.getInstance()
                .findMatchingRecipe(getInputStack(), getFluidStack(), this.sealed, getTechLevel());
        if (recipe != null && !worldObj.isRemote) {
          int time = 0;
          if (sealtime > 0) time = (int) TFC_Time.getTotalHours() - sealtime;
          else if (unsealtime > 0) time = (int) TFC_Time.getTotalHours() - unsealtime;

          // Make sure that the recipe meets the time requirements
          if (recipe.isSealedRecipe() && time < recipe.sealTime) return;

          ItemStack origIS = getInputStack() != null ? getInputStack().copy() : null;
          FluidStack origFS = getFluidStack() != null ? getFluidStack().copy() : null;
          if (fluid.isFluidEqual(recipe.getResultFluid(origIS, origFS, time))
              && recipe.removesLiquid) {
            if (fluid.getFluid() == TFCFluids.BRINE
                && origIS != null
                && origIS.getItem() instanceof IFood)
              fluid.amount -=
                  recipe.getResultFluid(origIS, origFS, time).amount * Food.getWeight(origIS);
            else fluid.amount -= recipe.getResultFluid(origIS, origFS, time).amount;
          } else {
            this.fluid = recipe.getResultFluid(origIS, origFS, time);
            if (fluid != null && !(recipe instanceof BarrelLiquidToLiquidRecipe) && origFS != null)
              this.fluid.amount = origFS.amount;
          }

          if (origFS != null
              && origFS.getFluid() != TFCFluids.MILKCURDLED
              && this.fluid.getFluid() == TFCFluids.MILKCURDLED)
            this.sealtime = (int) TFC_Time.getTotalHours();

          Stack<ItemStack> resultStacks = recipe.getResult(origIS, origFS, time);
          if (!resultStacks.isEmpty()) {
            ItemStack result = resultStacks.pop();
            if (fluid != null && fluid.getFluid() == TFCFluids.BRINE) {
              if (result == null && origIS != null) result = origIS.copy();
              if (result != null
                  && result.getItem() instanceof IFood
                  && (result.getItem() == TFCItems.cheese
                      || ((IFood) result.getItem()).getFoodGroup() != EnumFoodGroup.Grain)) {
                if (!Food.isBrined(result)) Food.setBrined(result, true);
              }
            }

            storage[INPUT_SLOT] = result;

            for (int i = 1; i < storage.length; i++) {
              if (storage[i] == null && !resultStacks.isEmpty())
                this.setInventorySlotContents(i, resultStacks.pop());
            }

            while (!resultStacks.isEmpty())
              worldObj.spawnEntityInWorld(
                  new EntityItem(worldObj, xCoord, yCoord, zCoord, resultStacks.pop()));

            this.setInventorySlotContents(0, result);
          }
        }
      } else if (getFluidStack() == null && !isCheese) recipe = null;
    }
  }
示例#16
0
  @Override
  public void updateEntity() {
    if (!worldObj.isRemote) {
      ItemStack itemstack = storage[INPUT_SLOT];
      BarrelPreservativeRecipe preservative =
          BarrelManager.getInstance()
              .findMatchingPreservativeRepice(this, itemstack, fluid, sealed);
      if (itemstack != null && fluid != null && fluid.getFluid() == TFCFluids.FRESHWATER) {
        if (TFC_ItemHeat.hasTemp(itemstack)) {
          float temp = TFC_ItemHeat.getTemp(itemstack);
          if (fluid.amount >= 1 && temp > 1) {
            temp -= 50;
            fluid.amount -= 1;
            TFC_ItemHeat.setTemp(itemstack, temp);
            TFC_ItemHeat.handleItemHeat(itemstack);
          }
        }
      }
      if (fluid != null && itemstack != null && itemstack.getItem() instanceof IFood) {
        float w = ((IFood) itemstack.getItem()).getFoodWeight(itemstack);
        if (fluid.getFluid() == TFCFluids.VINEGAR) {
          // If the food is brined then we attempt to pickle it
          if (Food.isBrined(itemstack)
              && !Food.isPickled(itemstack)
              && w / fluid.amount <= Global.FOOD_MAX_WEIGHT / this.getMaxLiquid()
              && this.getSealed()
              && sealtime != 0
              && TFC_Time.getTotalHours() - sealtime >= 4) {
            fluid.amount -= 1 * w;
            Food.setPickled(itemstack, true);
          }
        }
      }

      if (preservative == null) {
        // No preservative was matched - decay normally
        TFC_Core.handleItemTicking(this, this.worldObj, xCoord, yCoord, zCoord);
      } else {
        float env = preservative.getEnvironmentalDecayFactor();
        float base = preservative.getBaseDecayModifier();
        if (Float.isNaN(env) || env < 0.0) {
          TFC_Core.handleItemTicking(this, this.worldObj, xCoord, yCoord, zCoord);
        } else if (Float.isNaN(base) || base < 0.0) {
          TFC_Core.handleItemTicking(this, this.worldObj, xCoord, yCoord, zCoord, env);
        } else {
          TFC_Core.handleItemTicking(this, this.worldObj, xCoord, yCoord, zCoord, env, base);
        }
      }

      // If lightning can strike here then it means that the barrel can see the sky, so rain can hit
      // it. If true then we fill
      // the barrel when its raining.
      if (!this.getSealed() && worldObj.canLightningStrikeAt(xCoord, yCoord + 1, zCoord)) {
        int count = getInvCount();
        if (count == 0 || count == 1 && this.getInputStack() != null) {
          if (this.fluid == null) fluid = new FluidStack(TFCFluids.FRESHWATER, 1);
          else if (this.fluid != null && fluid.getFluid() == TFCFluids.FRESHWATER)
            fluid.amount = Math.min(fluid.amount + 1, getMaxLiquid());
        }
      }

      // We only want to bother ticking food once per 5 seconds to keep overhead low.
      processTimer++;
      if (processTimer > 100) {
        processItems();
        processTimer = 0;
      }

      // Here we handle item stacks that are too big for MC to handle such as when making mortar.
      // If the stack is > its own max stack size then we split it and add it to the invisible solid
      // storage area or
      // spawn the item in the world if there is no room left.
      if (this.getFluidLevel() > 0 && getInputStack() != null) {
        int count = 1;
        while (this.getInputStack().stackSize > getInputStack().getMaxStackSize()) {
          ItemStack is = getInputStack().splitStack(getInputStack().getMaxStackSize());
          if (count < this.storage.length && this.getStackInSlot(count) == null) {
            this.setInventorySlotContents(count, is);
          } else {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, xCoord, yCoord, zCoord, is));
          }
          count++;
        }
      }

      // Move any items in the solid storage slots to the main slot if they exist and the barrel has
      // liquid.
      else if (this.getFluidLevel() > 0 && getInputStack() == null && this.getInvCount() > 0) {
        for (int i = 0; i < storage.length; i++) {
          if (storage[i] != null) {
            storage[INPUT_SLOT] = storage[i].copy();
            storage[i] = null;
            break;
          }
        }
      }

      // Reset our fluid if all of the liquid is gone.
      if (fluid != null && fluid.amount == 0) fluid = null;

      // Handle adding fluids to the barrel if the barrel is currently in input mode.
      if (mode == MODE_IN) {
        ItemStack container = getInputStack();
        FluidStack inLiquid = FluidContainerRegistry.getFluidForFilledItem(container);

        if (container != null && container.getItem() instanceof IFluidContainerItem) {
          FluidStack isfs = ((IFluidContainerItem) container.getItem()).getFluid(container);
          if (isfs != null && addLiquid(isfs)) {
            ((IFluidContainerItem) container.getItem())
                .drain(
                    container,
                    ((IFluidContainerItem) container.getItem()).getCapacity(container),
                    true);
          }
        } else if (inLiquid != null && container != null && container.stackSize == 1) {
          if (addLiquid(inLiquid)) {
            this.setInventorySlotContents(0, FluidContainerRegistry.drainFluidContainer(container));
          }
        }
      }
      // Drain liquid from the barrel to a container if the barrel is in output mode.
      else if (mode == MODE_OUT) {
        ItemStack container = getInputStack();

        if (container != null
            && fluid != null
            && container.getItem() instanceof IFluidContainerItem) {
          FluidStack isfs = ((IFluidContainerItem) container.getItem()).getFluid(container);
          if (isfs == null || fluid.isFluidEqual(isfs)) {
            fluid.amount -=
                ((IFluidContainerItem) container.getItem()).fill(container, fluid, true);
            if (fluid.amount == 0) fluid = null;
          }
        } else if (FluidContainerRegistry.isEmptyContainer(container)) {
          this.setInventorySlotContents(0, this.removeLiquid(getInputStack()));
        }
      }
    }
  }