2014-04-24 08:14:26 +02:00
|
|
|
package appeng.container.implementations;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
import net.minecraft.inventory.IInventory;
|
2014-04-25 03:55:29 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.world.World;
|
2014-04-24 08:14:26 +02:00
|
|
|
import appeng.api.config.RedstoneMode;
|
|
|
|
import appeng.api.config.SecurityPermissions;
|
|
|
|
import appeng.api.config.Settings;
|
2014-05-09 06:10:12 +02:00
|
|
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
2014-05-08 02:59:05 +02:00
|
|
|
import appeng.container.guisync.GuiSync;
|
2014-04-25 03:55:29 +02:00
|
|
|
import appeng.container.slot.SlotMACPattern;
|
|
|
|
import appeng.container.slot.SlotOutput;
|
2014-04-24 08:14:26 +02:00
|
|
|
import appeng.container.slot.SlotRestrictedInput;
|
|
|
|
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
2014-04-25 03:55:29 +02:00
|
|
|
import appeng.items.misc.ItemEncodedPattern;
|
2014-04-24 08:14:26 +02:00
|
|
|
import appeng.tile.crafting.TileMolecularAssembler;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
|
|
|
|
public class ContainerMAC extends ContainerUpgradeable
|
|
|
|
{
|
|
|
|
|
2014-05-08 02:59:05 +02:00
|
|
|
TileMolecularAssembler tma;
|
|
|
|
|
2014-04-24 08:14:26 +02:00
|
|
|
public ContainerMAC(InventoryPlayer ip, TileMolecularAssembler te) {
|
|
|
|
super( ip, te );
|
2014-05-08 02:59:05 +02:00
|
|
|
tma = te;
|
2014-04-24 08:14:26 +02:00
|
|
|
}
|
|
|
|
|
2014-05-07 04:21:12 +02:00
|
|
|
public int availableUpgrades()
|
|
|
|
{
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
2014-04-24 08:14:26 +02:00
|
|
|
@Override
|
|
|
|
protected int getHeight()
|
|
|
|
{
|
|
|
|
return 197;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean supportCapacity()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-08 02:59:05 +02:00
|
|
|
@GuiSync(4)
|
|
|
|
public int craftProgress = 0;
|
|
|
|
|
2014-04-25 03:55:29 +02:00
|
|
|
public boolean isValidItemForSlot(int slotIndex, ItemStack i)
|
|
|
|
{
|
|
|
|
IInventory mac = myte.getInventoryByName( "mac" );
|
|
|
|
|
|
|
|
ItemStack is = mac.getStackInSlot( 10 );
|
|
|
|
if ( is == null )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( is.getItem() instanceof ItemEncodedPattern )
|
|
|
|
{
|
|
|
|
World w = this.getTileEntity().getWorldObj();
|
|
|
|
ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
|
|
|
ICraftingPatternDetails ph = iep.getPatternForItem( is, w );
|
|
|
|
return ph.isValidItemForSlot( slotIndex, i, w );
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-04-24 08:14:26 +02:00
|
|
|
@Override
|
|
|
|
protected void setupConfig()
|
|
|
|
{
|
|
|
|
int offx = 29;
|
|
|
|
int offy = 30;
|
|
|
|
|
2014-04-25 03:55:29 +02:00
|
|
|
IInventory mac = myte.getInventoryByName( "mac" );
|
2014-04-24 08:14:26 +02:00
|
|
|
|
|
|
|
for (int y = 0; y < 3; y++)
|
|
|
|
for (int x = 0; x < 3; x++)
|
2014-04-25 03:55:29 +02:00
|
|
|
{
|
|
|
|
SlotMACPattern s = new SlotMACPattern( this, mac, x + y * 3, offx + x * 18, offy + y * 18 );
|
|
|
|
addSlotToContainer( s );
|
|
|
|
}
|
2014-04-24 08:14:26 +02:00
|
|
|
|
|
|
|
offx = 126;
|
|
|
|
offy = 16;
|
|
|
|
|
2014-04-25 03:55:29 +02:00
|
|
|
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.ENCODED_PATTERN, mac, 10, offx, offy ) );
|
|
|
|
addSlotToContainer( new SlotOutput( mac, 9, offx, offy + 32, -1 ) );
|
2014-04-24 08:14:26 +02:00
|
|
|
|
|
|
|
offx = 122;
|
|
|
|
offy = 17;
|
|
|
|
|
|
|
|
IInventory upgrades = myte.getInventoryByName( "upgrades" );
|
|
|
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0 )).setNotDraggable() );
|
|
|
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1 )).setNotDraggable() );
|
|
|
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2 )).setNotDraggable() );
|
|
|
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3 )).setNotDraggable() );
|
|
|
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4 )).setNotDraggable() );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void detectAndSendChanges()
|
|
|
|
{
|
|
|
|
verifyPermissions( SecurityPermissions.BUILD, false );
|
|
|
|
|
|
|
|
if ( Platform.isServer() )
|
|
|
|
{
|
|
|
|
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
|
|
|
}
|
|
|
|
|
2014-05-08 02:59:05 +02:00
|
|
|
craftProgress = this.tma.getCraftingProgress();
|
|
|
|
|
2014-04-24 08:14:26 +02:00
|
|
|
standardDetectAndSendChanges();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|