Package logisticspipes.proxy.recipeproviders

Source Code of logisticspipes.proxy.recipeproviders.AutoWorkbench

package logisticspipes.proxy.recipeproviders;

import logisticspipes.proxy.interfaces.ICraftingRecipeProvider;
import logisticspipes.utils.item.ItemIdentifierInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import buildcraft.factory.TileAutoWorkbench;

public class AutoWorkbench implements ICraftingRecipeProvider {
  @Override
  public boolean canOpenGui(TileEntity tile) {
    return (tile instanceof TileAutoWorkbench);
  }

  @Override
  public boolean importRecipe(TileEntity tile, ItemIdentifierInventory inventory) {
    if (!(tile instanceof TileAutoWorkbench))
      return false;

    TileAutoWorkbench bench = (TileAutoWorkbench) tile;
    ItemStack result = bench.findRecipeOutput();
    //ItemStack result = bench.getStackInSlot(TileAutoWorkbench.SLOT_RESULT);
   
    if (result == null)
      return false;

    inventory.setInventorySlotContents(9, result);

    // Import
    for (int i = 0; i < bench.craftMatrix.getSizeInventory(); i++) {
      if (i >= inventory.getSizeInventory() - 2) {
        break;
      }
      final ItemStack newStack = bench.craftMatrix.getStackInSlot(i) == null ? null : bench.craftMatrix.getStackInSlot(i).copy();
      if(newStack!=null && newStack.stackSize>1) // just incase size == 0 somehow.
      newStack.stackSize=1;
      inventory.setInventorySlotContents(i, newStack);
    }

    inventory.compact_first(9);
   
    return true;
  }
}
TOP

Related Classes of logisticspipes.proxy.recipeproviders.AutoWorkbench

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.