2014-02-05 03:44:54 +01:00
|
|
|
package appeng.container.implementations;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2014-02-05 08:25:44 +01:00
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.inventory.InventoryCrafting;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.item.crafting.CraftingManager;
|
2014-02-17 01:50:25 +01:00
|
|
|
import appeng.api.storage.ITerminalHost;
|
2014-02-05 08:25:44 +01:00
|
|
|
import appeng.container.ContainerNull;
|
|
|
|
import appeng.container.slot.SlotCraftingMatrix;
|
|
|
|
import appeng.container.slot.SlotCraftingTerm;
|
2014-02-05 03:44:54 +01:00
|
|
|
import appeng.parts.reporting.PartCraftingTerminal;
|
2014-02-05 08:25:44 +01:00
|
|
|
import appeng.tile.inventory.AppEngInternalInventory;
|
|
|
|
import appeng.tile.inventory.IAEAppEngInventory;
|
|
|
|
import appeng.tile.inventory.InvOperation;
|
2014-02-05 03:44:54 +01:00
|
|
|
|
2014-02-05 08:25:44 +01:00
|
|
|
public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAEAppEngInventory
|
2014-02-05 03:44:54 +01:00
|
|
|
{
|
|
|
|
|
2014-02-05 08:25:44 +01:00
|
|
|
AppEngInternalInventory output = new AppEngInternalInventory( this, 1 );
|
|
|
|
|
|
|
|
SlotCraftingMatrix craftingSlots[] = new SlotCraftingMatrix[9];
|
|
|
|
SlotCraftingTerm outputSlot;
|
|
|
|
|
2014-05-01 06:01:22 +02:00
|
|
|
public PartCraftingTerminal ct;
|
2014-02-05 03:44:54 +01:00
|
|
|
|
2014-02-05 08:25:44 +01:00
|
|
|
/**
|
|
|
|
* Callback for when the crafting matrix is changed.
|
|
|
|
*/
|
|
|
|
public void onCraftMatrixChanged(IInventory par1IInventory)
|
|
|
|
{
|
|
|
|
ContainerNull cn = new ContainerNull();
|
|
|
|
InventoryCrafting ic = new InventoryCrafting( cn, 3, 3 );
|
|
|
|
|
|
|
|
for (int x = 0; x < 9; x++)
|
|
|
|
ic.setInventorySlotContents( x, craftingSlots[x].getStack() );
|
|
|
|
|
|
|
|
outputSlot.putStack( CraftingManager.getInstance().findMatchingRecipe( ic, getPlayerInv().player.worldObj ) );
|
|
|
|
}
|
2014-02-05 03:44:54 +01:00
|
|
|
|
2014-02-17 01:50:25 +01:00
|
|
|
public ContainerCraftingTerm(InventoryPlayer ip, ITerminalHost montiorable) {
|
2014-02-05 03:44:54 +01:00
|
|
|
super( ip, montiorable, false );
|
|
|
|
ct = (PartCraftingTerminal) montiorable;
|
|
|
|
|
2014-02-05 08:25:44 +01:00
|
|
|
IInventory crafting = ct.getInventoryByName( "crafting" );
|
|
|
|
|
|
|
|
for (int y = 0; y < 3; y++)
|
|
|
|
for (int x = 0; x < 3; x++)
|
|
|
|
addSlotToContainer( craftingSlots[x + y * 3] = new SlotCraftingMatrix( this, crafting, x + y * 3, 37 + x * 18, -72 + y * 18 ) );
|
|
|
|
|
2014-04-17 06:38:43 +02:00
|
|
|
addSlotToContainer( outputSlot = new SlotCraftingTerm( getPlayerInv().player, mySrc, powerSrc, montiorable, crafting, crafting, output, 131, -72 + 18 ) );
|
2014-02-05 08:25:44 +01:00
|
|
|
|
2014-02-05 03:44:54 +01:00
|
|
|
bindPlayerInventory( ip, 0, 0 );
|
2014-02-05 08:25:44 +01:00
|
|
|
|
|
|
|
onCraftMatrixChanged( crafting );
|
2014-02-05 03:44:54 +01:00
|
|
|
}
|
|
|
|
|
2014-02-05 08:25:44 +01:00
|
|
|
@Override
|
|
|
|
public void saveChanges()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2014-02-05 03:44:54 +01:00
|
|
|
}
|