コード例 #1
0
ファイル: TEBarrel.java プロジェクト: rjdunlap/TFCraft
  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;
    }
  }
コード例 #2
0
ファイル: TEBarrel.java プロジェクト: rjdunlap/TFCraft
 public static void registerRecipes() {
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelAlcoholRecipe(
               ItemFoodTFC.createTag(new ItemStack(TFCItems.potato), 160),
               new FluidStack(TFCFluids.FRESHWATER, 10000),
               null,
               new FluidStack(TFCFluids.VODKA, 10000)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelAlcoholRecipe(
               ItemFoodTFC.createTag(new ItemStack(TFCItems.redApple), 160),
               new FluidStack(TFCFluids.FRESHWATER, 10000),
               null,
               new FluidStack(TFCFluids.CIDER, 10000)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelAlcoholRecipe(
               ItemFoodTFC.createTag(new ItemStack(TFCItems.greenApple), 160),
               new FluidStack(TFCFluids.FRESHWATER, 10000),
               null,
               new FluidStack(TFCFluids.CIDER, 10000)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelAlcoholRecipe(
               ItemFoodTFC.createTag(new ItemStack(TFCItems.wheatGround), 160),
               new FluidStack(TFCFluids.FRESHWATER, 10000),
               null,
               new FluidStack(TFCFluids.WHISKEY, 10000)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelAlcoholRecipe(
               ItemFoodTFC.createTag(new ItemStack(TFCItems.ryeGround), 160),
               new FluidStack(TFCFluids.FRESHWATER, 10000),
               null,
               new FluidStack(TFCFluids.RYEWHISKEY, 10000)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelAlcoholRecipe(
               ItemFoodTFC.createTag(new ItemStack(TFCItems.barleyGround), 160),
               new FluidStack(TFCFluids.FRESHWATER, 10000),
               null,
               new FluidStack(TFCFluids.BEER, 10000)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelAlcoholRecipe(
               ItemFoodTFC.createTag(new ItemStack(TFCItems.riceGround), 160),
               new FluidStack(TFCFluids.FRESHWATER, 10000),
               null,
               new FluidStack(TFCFluids.SAKE, 10000)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelAlcoholRecipe(
               ItemFoodTFC.createTag(new ItemStack(TFCItems.sugar), 160),
               new FluidStack(TFCFluids.FRESHWATER, 10000),
               null,
               new FluidStack(TFCFluids.RUM, 10000)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelAlcoholRecipe(
               ItemFoodTFC.createTag(new ItemStack(TFCItems.cornmealGround), 160),
               new FluidStack(TFCFluids.FRESHWATER, 10000),
               null,
               new FluidStack(TFCFluids.CORNWHISKEY, 10000)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelRecipe(
                   null,
                   new FluidStack(TFCFluids.MILKVINEGAR, 10000),
                   null,
                   new FluidStack(TFCFluids.MILKCURDLED, 10000))
               .setMinTechLevel(0)
               .setRemovesLiquid(false));
   // BarrelManager.getInstance().addRecipe(new BarrelRecipeNoItem(new
   // FluidStack(TFCFluid.MILKCURDLED, 10000), ItemFoodTFC.createTag(new
   // ItemStack(TFCItems.Cheese), 160), null).setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelRecipe(
                   new ItemStack(TFCItems.logs, 1, 0),
                   new FluidStack(TFCFluids.FRESHWATER, 1000),
                   null,
                   new FluidStack(TFCFluids.TANNIN, 1000))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelRecipe(
                   new ItemStack(TFCItems.logs, 1, 2),
                   new FluidStack(TFCFluids.FRESHWATER, 1000),
                   null,
                   new FluidStack(TFCFluids.TANNIN, 1000))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelRecipe(
                   new ItemStack(TFCItems.logs, 1, 3),
                   new FluidStack(TFCFluids.FRESHWATER, 1000),
                   null,
                   new FluidStack(TFCFluids.TANNIN, 1000))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelRecipe(
                   new ItemStack(TFCItems.logs, 1, 4),
                   new FluidStack(TFCFluids.FRESHWATER, 1000),
                   null,
                   new FluidStack(TFCFluids.TANNIN, 1000))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelRecipe(
                   new ItemStack(TFCItems.logs, 1, 5),
                   new FluidStack(TFCFluids.FRESHWATER, 1000),
                   null,
                   new FluidStack(TFCFluids.TANNIN, 1000))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelRecipe(
                   new ItemStack(TFCItems.logs, 1, 6),
                   new FluidStack(TFCFluids.FRESHWATER, 1000),
                   null,
                   new FluidStack(TFCFluids.TANNIN, 1000))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelRecipe(
                   new ItemStack(TFCItems.logs, 1, 9),
                   new FluidStack(TFCFluids.FRESHWATER, 1000),
                   null,
                   new FluidStack(TFCFluids.TANNIN, 1000))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelRecipe(
                   new ItemStack(TFCItems.powder, 1, 0),
                   new FluidStack(TFCFluids.FRESHWATER, 500),
                   null,
                   new FluidStack(TFCFluids.LIMEWATER, 500),
                   0)
               .setMinTechLevel(0)
               .setSealedRecipe(false)
               .setRemovesLiquid(false)
               .setAllowAnyStack(false));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelMultiItemRecipe(
                   new ItemStack(TFCItems.scrapedHide, 1, 0),
                   new FluidStack(TFCFluids.FRESHWATER, 300),
                   new ItemStack(TFCItems.prepHide, 1, 0),
                   new FluidStack(TFCFluids.FRESHWATER, 300))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelMultiItemRecipe(
                   new ItemStack(TFCItems.scrapedHide, 1, 1),
                   new FluidStack(TFCFluids.FRESHWATER, 400),
                   new ItemStack(TFCItems.prepHide, 1, 1),
                   new FluidStack(TFCFluids.FRESHWATER, 400))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelMultiItemRecipe(
                   new ItemStack(TFCItems.scrapedHide, 1, 2),
                   new FluidStack(TFCFluids.FRESHWATER, 500),
                   new ItemStack(TFCItems.prepHide, 1, 2),
                   new FluidStack(TFCFluids.FRESHWATER, 500))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelMultiItemRecipe(
                   new ItemStack(TFCItems.hide, 1, 0),
                   new FluidStack(TFCFluids.LIMEWATER, 300),
                   new ItemStack(TFCItems.soakedHide, 1, 0),
                   new FluidStack(TFCFluids.LIMEWATER, 300))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelMultiItemRecipe(
                   new ItemStack(TFCItems.hide, 1, 1),
                   new FluidStack(TFCFluids.LIMEWATER, 400),
                   new ItemStack(TFCItems.soakedHide, 1, 1),
                   new FluidStack(TFCFluids.LIMEWATER, 400))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelMultiItemRecipe(
                   new ItemStack(TFCItems.hide, 1, 2),
                   new FluidStack(TFCFluids.LIMEWATER, 500),
                   new ItemStack(TFCItems.soakedHide, 1, 2),
                   new FluidStack(TFCFluids.LIMEWATER, 500))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelMultiItemRecipe(
                   new ItemStack(TFCItems.prepHide, 1, 0),
                   new FluidStack(TFCFluids.TANNIN, 300),
                   new ItemStack(TFCItems.leather, 1),
                   new FluidStack(TFCFluids.TANNIN, 300))
               .setKeepStackSize(false)
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelMultiItemRecipe(
                   new ItemStack(TFCItems.prepHide, 1, 1),
                   new FluidStack(TFCFluids.TANNIN, 400),
                   new ItemStack(TFCItems.leather, 2),
                   new FluidStack(TFCFluids.TANNIN, 400))
               .setKeepStackSize(false)
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelMultiItemRecipe(
                   new ItemStack(TFCItems.prepHide, 1, 2),
                   new FluidStack(TFCFluids.TANNIN, 500),
                   new ItemStack(TFCItems.leather, 3),
                   new FluidStack(TFCFluids.TANNIN, 500))
               .setKeepStackSize(false)
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelRecipe(
                   new ItemStack(TFCBlocks.sand, 1, 32767),
                   new FluidStack(TFCFluids.LIMEWATER, 100),
                   new ItemStack(TFCItems.mortar, 16),
                   new FluidStack(TFCFluids.LIMEWATER, 100))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelRecipe(
                   new ItemStack(TFCBlocks.sand2, 1, 32767),
                   new FluidStack(TFCFluids.LIMEWATER, 100),
                   new ItemStack(TFCItems.mortar, 16),
                   new FluidStack(TFCFluids.LIMEWATER, 100))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelVinegarRecipe(
               new FluidStack(TFCFluids.VODKA, 100), new FluidStack(TFCFluids.VINEGAR, 100)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelVinegarRecipe(
               new FluidStack(TFCFluids.CIDER, 100), new FluidStack(TFCFluids.VINEGAR, 100)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelVinegarRecipe(
               new FluidStack(TFCFluids.WHISKEY, 100), new FluidStack(TFCFluids.VINEGAR, 100)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelVinegarRecipe(
               new FluidStack(TFCFluids.RYEWHISKEY, 100), new FluidStack(TFCFluids.VINEGAR, 100)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelVinegarRecipe(
               new FluidStack(TFCFluids.BEER, 100), new FluidStack(TFCFluids.VINEGAR, 100)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelVinegarRecipe(
               new FluidStack(TFCFluids.SAKE, 100), new FluidStack(TFCFluids.VINEGAR, 100)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelVinegarRecipe(
               new FluidStack(TFCFluids.RUM, 100), new FluidStack(TFCFluids.VINEGAR, 100)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelVinegarRecipe(
               new FluidStack(TFCFluids.CORNWHISKEY, 100),
               new FluidStack(TFCFluids.VINEGAR, 100)));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelLiquidToLiquidRecipe(
                   new FluidStack(TFCFluids.SALTWATER, 9000),
                   new FluidStack(TFCFluids.VINEGAR, 1000),
                   new FluidStack(TFCFluids.BRINE, 10000))
               .setSealedRecipe(false)
               .setMinTechLevel(0)
               .setRemovesLiquid(false));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelBriningRecipe(
                   new FluidStack(TFCFluids.BRINE, 60), new FluidStack(TFCFluids.BRINE, 60))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelMultiItemRecipe(
                   ItemFoodTFC.createTag(new ItemStack(TFCItems.sugarcane), 1),
                   new FluidStack(TFCFluids.FRESHWATER, 60),
                   ItemFoodTFC.createTag(new ItemStack(TFCItems.sugar), 0.1f),
                   new FluidStack(TFCFluids.FRESHWATER, 60))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelMultiItemRecipe(
                   new ItemStack(TFCItems.jute, 1, 0),
                   new FluidStack(TFCFluids.FRESHWATER, 200),
                   new ItemStack(TFCItems.juteFiber, 1, 0),
                   new FluidStack(TFCFluids.FRESHWATER, 200))
               .setMinTechLevel(0));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelLiquidToLiquidRecipe(
                   new FluidStack(TFCFluids.MILK, 9000),
                   new FluidStack(TFCFluids.VINEGAR, 1000),
                   new FluidStack(TFCFluids.MILKVINEGAR, 10000))
               .setSealedRecipe(false)
               .setMinTechLevel(0)
               .setRemovesLiquid(false));
   BarrelManager.getInstance()
       .addRecipe(
           new BarrelLiquidToLiquidRecipe(
                   new FluidStack(TFCFluids.MILKVINEGAR, 9000),
                   new FluidStack(TFCFluids.MILK, 1000),
                   new FluidStack(TFCFluids.MILKVINEGAR, 10000))
               .setSealedRecipe(false)
               .setMinTechLevel(0)
               .setRemovesLiquid(false));
   // 5000mb / 160oz = 31.25
   // 10000mb / 160oz = 62.5
   // FluidStack naturally only takes int so I rounded down
   BarrelPreservativeRecipe picklePreservative =
       new BarrelPreservativeRecipe(new FluidStack(TFCFluids.VINEGAR, 31), "gui.barrel.preserving")
           .setAllowGrains(false)
           .setRequiresPickled(true)
           .setEnvironmentalDecayFactor(0.25f)
           .setBaseDecayModifier(0.1f)
           .setRequiresSealed(true);
   BarrelPreservativeRecipe brineInBrinePreservative =
       new BarrelPreservativeRecipe(new FluidStack(TFCFluids.BRINE, 62), "gui.barrel.preserving")
           .setAllowGrains(false)
           .setRequiresBrined(true)
           .setEnvironmentalDecayFactor(0.75f)
           .setRequiresSealed(true);
   BarrelPreservativeRecipe brineInVinegarPreservative =
       new BarrelPreservativeRecipe(new FluidStack(TFCFluids.VINEGAR, 62), "gui.barrel.preserving")
           .setAllowGrains(false)
           .setRequiresBrined(true)
           .setEnvironmentalDecayFactor(0.75f)
           .setRequiresSealed(true);
   BarrelManager.getInstance().addPreservative(picklePreservative);
   BarrelManager.getInstance().addPreservative(brineInBrinePreservative);
   BarrelManager.getInstance().addPreservative(brineInVinegarPreservative);
 }
コード例 #3
0
ファイル: TEBarrel.java プロジェクト: rjdunlap/TFCraft
  @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()));
        }
      }
    }
  }