use of forestry.core.items.ICraftingPlan in project ForestryMC by ForestryMC.
the class TileFabricator method craftResult.
private void craftResult() {
RecipePair<IFabricatorRecipe> myRecipePair = getRecipe();
ItemStack craftResult = getResult(myRecipePair);
IFabricatorRecipe myRecipe = myRecipePair.getRecipe();
if (myRecipe != null && !craftResult.isEmpty() && getStackInSlot(InventoryFabricator.SLOT_RESULT).isEmpty()) {
FluidStack liquid = myRecipe.getLiquid();
// Remove resources
NonNullList<ItemStack> crafting = InventoryUtil.getStacks(craftingInventory, InventoryGhostCrafting.SLOT_CRAFTING_1, InventoryGhostCrafting.SLOT_CRAFTING_COUNT);
if (removeFromInventory(crafting, myRecipePair, false)) {
FluidStack drained = moltenTank.drainInternal(liquid, false);
if (drained != null && drained.isFluidStackIdentical(liquid)) {
removeFromInventory(crafting, myRecipePair, true);
moltenTank.drain(liquid.amount, true);
// Damage plan
if (!getStackInSlot(InventoryFabricator.SLOT_PLAN).isEmpty()) {
Item planItem = getStackInSlot(InventoryFabricator.SLOT_PLAN).getItem();
if (planItem instanceof ICraftingPlan) {
ItemStack planUsed = ((ICraftingPlan) planItem).planUsed(getStackInSlot(InventoryFabricator.SLOT_PLAN), craftResult);
setInventorySlotContents(InventoryFabricator.SLOT_PLAN, planUsed);
}
}
setInventorySlotContents(InventoryFabricator.SLOT_RESULT, craftResult);
}
}
}
}
Aggregations