Beispiel #1
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;
  }