Example usage for net.minecraftforge.fluids FluidStack isFluidStackIdentical

List of usage examples for net.minecraftforge.fluids FluidStack isFluidStackIdentical

Introduction

In this page you can find the example usage for net.minecraftforge.fluids FluidStack isFluidStackIdentical.

Prototype

public boolean isFluidStackIdentical(FluidStack other) 

Source Link

Document

Determines if the FluidIDs, Amounts, and NBT Tags are all equal.

Usage

From source file:forestry.factory.gadgets.MachineFabricator.java

License:Open Source License

private void craftResult(EntityPlayer player) {
    Recipe myRecipe = getRecipe();//from   w  ww. jav  a 2  s .c  o m
    if (myRecipe == null) {
        return;
    }

    ItemStack result = getResult();
    if (result == null) {
        return;
    }

    IInventoryAdapter inventory = getInternalInventory();

    if (inventory.getStackInSlot(SLOT_RESULT) != null) {
        return;
    }

    FluidStack liquid = myRecipe.molten;

    // Remove resources
    ItemStack[] crafting = InvTools.getStacks(craftingInventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT);
    if (!removeFromInventory(crafting, player, false)) {
        return;
    }

    FluidStack canDrain = moltenTank.drain(liquid.amount, false);
    if (canDrain == null || !canDrain.isFluidStackIdentical(liquid)) {
        return;
    }

    removeFromInventory(crafting, player, true);
    moltenTank.drain(liquid.amount, true);

    // Damage plan
    if (inventory.getStackInSlot(SLOT_PLAN) != null) {
        Item planItem = inventory.getStackInSlot(SLOT_PLAN).getItem();
        if (planItem instanceof ICraftingPlan) {
            inventory.setInventorySlotContents(SLOT_PLAN,
                    ((ICraftingPlan) planItem).planUsed(inventory.getStackInSlot(SLOT_PLAN), result));
        }
    }

    inventory.setInventorySlotContents(SLOT_RESULT, result);
}