2014-01-24 17:35:58 +01:00
|
|
|
package appeng.container.implementations;
|
|
|
|
|
2014-05-22 04:09:29 +02:00
|
|
|
import java.util.Iterator;
|
|
|
|
|
2014-01-24 17:35:58 +01:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
import net.minecraft.inventory.IInventory;
|
2014-05-22 04:09:29 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import appeng.api.AEApi;
|
2014-01-24 17:35:58 +01:00
|
|
|
import appeng.api.config.AccessRestriction;
|
|
|
|
import appeng.api.config.FuzzyMode;
|
2014-01-27 05:00:36 +01:00
|
|
|
import appeng.api.config.SecurityPermissions;
|
2014-01-24 17:35:58 +01:00
|
|
|
import appeng.api.config.Settings;
|
2014-01-26 07:44:50 +01:00
|
|
|
import appeng.api.config.Upgrades;
|
2014-05-22 04:09:29 +02:00
|
|
|
import appeng.api.storage.IMEInventory;
|
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
|
|
|
import appeng.api.storage.data.IItemList;
|
2014-05-07 07:22:42 +02:00
|
|
|
import appeng.container.guisync.GuiSync;
|
2014-01-26 07:44:50 +01:00
|
|
|
import appeng.container.slot.OptionalSlotFakeTypeOnly;
|
|
|
|
import appeng.container.slot.SlotFakeTypeOnly;
|
2014-01-24 17:35:58 +01:00
|
|
|
import appeng.container.slot.SlotRestrictedInput;
|
|
|
|
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
|
|
|
import appeng.parts.misc.PartStorageBus;
|
|
|
|
import appeng.util.Platform;
|
2014-05-22 04:09:29 +02:00
|
|
|
import appeng.util.iterators.NullIterator;
|
2014-01-24 17:35:58 +01:00
|
|
|
|
|
|
|
public class ContainerStorageBus extends ContainerUpgradeable
|
|
|
|
{
|
|
|
|
|
|
|
|
PartStorageBus storageBus;
|
2014-05-07 07:22:42 +02:00
|
|
|
|
|
|
|
@GuiSync(3)
|
2014-01-24 17:35:58 +01:00
|
|
|
public AccessRestriction rwMode = AccessRestriction.READ_WRITE;
|
|
|
|
|
|
|
|
public ContainerStorageBus(InventoryPlayer ip, PartStorageBus te) {
|
|
|
|
super( ip, te );
|
|
|
|
storageBus = te;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected int getHeight()
|
|
|
|
{
|
2014-01-26 07:44:50 +01:00
|
|
|
return 251;
|
2014-01-24 17:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int availableUpgrades()
|
|
|
|
{
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean supportCapacity()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-01-26 07:44:50 +01:00
|
|
|
@Override
|
|
|
|
public boolean isSlotEnabled(int idx)
|
|
|
|
{
|
|
|
|
int upgrades = myte.getInstalledUpgrades( Upgrades.CAPACITY );
|
|
|
|
|
|
|
|
return upgrades > idx;
|
|
|
|
}
|
|
|
|
|
2014-01-24 17:35:58 +01:00
|
|
|
@Override
|
|
|
|
protected void setupConfig()
|
|
|
|
{
|
2014-01-26 07:44:50 +01:00
|
|
|
int xo = 8;
|
|
|
|
int yo = 23 + 6;
|
|
|
|
|
|
|
|
IInventory config = myte.getInventoryByName( "config" );
|
|
|
|
for (int y = 0; y < 7; y++)
|
|
|
|
{
|
|
|
|
for (int x = 0; x < 9; x++)
|
|
|
|
{
|
|
|
|
if ( y < 2 )
|
|
|
|
addSlotToContainer( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) );
|
|
|
|
else
|
|
|
|
addSlotToContainer( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-24 17:35:58 +01:00
|
|
|
IInventory upgrades = myte.getInventoryByName( "upgrades" );
|
2014-07-13 03:03:17 +02:00
|
|
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0, invPlayer )).setNotDraggable() );
|
|
|
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1, invPlayer )).setNotDraggable() );
|
|
|
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, invPlayer )).setNotDraggable() );
|
|
|
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, invPlayer )).setNotDraggable() );
|
|
|
|
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, invPlayer )).setNotDraggable() );
|
2014-01-24 17:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void detectAndSendChanges()
|
|
|
|
{
|
2014-01-27 05:00:36 +01:00
|
|
|
verifyPermissions( SecurityPermissions.BUILD, false );
|
|
|
|
|
2014-01-24 17:35:58 +01:00
|
|
|
if ( Platform.isServer() )
|
|
|
|
{
|
|
|
|
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
|
|
|
this.rwMode = (AccessRestriction) this.myte.getConfigManager().getSetting( Settings.ACCESS );
|
|
|
|
}
|
|
|
|
|
|
|
|
standardDetectAndSendChanges();
|
|
|
|
}
|
|
|
|
|
2014-05-22 04:09:29 +02:00
|
|
|
public void clear()
|
|
|
|
{
|
|
|
|
IInventory inv = myte.getInventoryByName( "config" );
|
|
|
|
for (int x = 0; x < inv.getSizeInventory(); x++)
|
|
|
|
inv.setInventorySlotContents( x, null );
|
|
|
|
detectAndSendChanges();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void partition()
|
|
|
|
{
|
|
|
|
IInventory inv = myte.getInventoryByName( "config" );
|
|
|
|
|
|
|
|
IMEInventory<IAEItemStack> cellInv = storageBus.getInternalHandler();
|
|
|
|
|
|
|
|
Iterator<IAEItemStack> i = new NullIterator<IAEItemStack>();
|
|
|
|
if ( cellInv != null )
|
|
|
|
{
|
|
|
|
IItemList<IAEItemStack> list = cellInv.getAvailableItems( AEApi.instance().storage().createItemList() );
|
|
|
|
i = list.iterator();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int x = 0; x < inv.getSizeInventory(); x++)
|
|
|
|
{
|
|
|
|
if ( i.hasNext() && isSlotEnabled( (x / 9) - 2 ) )
|
|
|
|
{
|
|
|
|
ItemStack g = i.next().getItemStack();
|
|
|
|
g.stackSize = 1;
|
|
|
|
inv.setInventorySlotContents( x, g );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
inv.setInventorySlotContents( x, null );
|
|
|
|
}
|
|
|
|
|
|
|
|
detectAndSendChanges();
|
|
|
|
}
|
|
|
|
|
2014-01-24 17:35:58 +01:00
|
|
|
}
|