Gui/Container over haul to get Bus Guis working.

This commit is contained in:
AlgorithmX2
2014-01-01 02:57:16 -06:00
parent 2a4e4c0369
commit 6b37ef8847
10 changed files with 241 additions and 99 deletions
+37 -27
View File
@@ -2,11 +2,13 @@ package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import appeng.api.config.Upgrades;
import appeng.api.implementations.IBusCommon;
import appeng.container.AEBaseContainer;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFake;
import appeng.container.slot.OptionalSlotFakeTypeOnly;
import appeng.container.slot.SlotFakeTypeOnly;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.inventory.AppEngInternalInventory;
@@ -22,10 +24,10 @@ public class ContainerBus extends AEBaseContainer implements IOptionalSlotHost
myte = te;
IInventory upgrades = myte.getInventoryByName( "upgrades" );
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0 ) );
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1 ) );
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2 ) );
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3 ) );
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() );
if ( hasToolbox() )
{
@@ -38,43 +40,51 @@ public class ContainerBus extends AEBaseContainer implements IOptionalSlotHost
int y = 40;
IInventory inv = myte.getInventoryByName( "config" );
addSlotToContainer( new SlotFake( inv, 0, x, y ) );
addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) );
addSlotToContainer( new OptionalSlotFake( inv, this, 1, x, y, -1, 0, 1 ) );
addSlotToContainer( new OptionalSlotFake( inv, this, 2, x, y, 1, 0, 1 ) );
addSlotToContainer( new OptionalSlotFake( inv, this, 3, x, y, 0, -1, 1 ) );
addSlotToContainer( new OptionalSlotFake( inv, this, 4, x, y, 0, 1, 1 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 1, x, y, -1, 0, 1 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 2, x, y, 1, 0, 1 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 3, x, y, 0, -1, 1 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 4, x, y, 0, 1, 1 ) );
addSlotToContainer( new OptionalSlotFake( inv, this, 5, x, y, -1, -1, 2 ) );
addSlotToContainer( new OptionalSlotFake( inv, this, 6, x, y, 1, -1, 2 ) );
addSlotToContainer( new OptionalSlotFake( inv, this, 7, x, y, -1, 1, 2 ) );
addSlotToContainer( new OptionalSlotFake( inv, this, 8, x, y, 1, 1, 2 ) );
/*
* addSlotToContainer( new OptionalSlotFake( inv, this, 9, x, y, -2, 0, 3 ) ); addSlotToContainer( new
* OptionalSlotFake( inv, this, 10, x, y, 2, 0, 3 ) ); addSlotToContainer( new OptionalSlotFake( inv, this, 11,
* x, y, 0, -2, 3 ) ); addSlotToContainer( new OptionalSlotFake( inv, this, 12, x, y, 0, 2, 3 ) );
*
* addSlotToContainer( new OptionalSlotFake( inv, this, 13, x, y, 2, 1, 4 ) ); addSlotToContainer( new
* OptionalSlotFake( inv, this, 14, x, y, 2, -1, 4 ) ); addSlotToContainer( new OptionalSlotFake( inv, this, 15,
* x, y, -2, -1, 4 ) ); addSlotToContainer( new OptionalSlotFake( inv, this, 16, x, y, -2, 1, 4 ) );
*/
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 5, x, y, -1, -1, 2 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 6, x, y, 1, -1, 2 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 7, x, y, -1, 1, 2 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 8, x, y, 1, 1, 2 ) );
bindPlayerInventory( ip, 0, 184 - /* height of playerinventory */82 );
}
@Override
public void detectAndSendChanges()
{
for (Object o : inventorySlots)
{
if ( o instanceof OptionalSlotFake )
{
OptionalSlotFake fs = (OptionalSlotFake) o;
if ( !fs.isEnabled() && fs.getDisplayStack() != null )
((OptionalSlotFake) fs).clearStack();
}
}
super.detectAndSendChanges();
}
public boolean hasToolbox()
{
// TODO Auto-generated method stub
return true;
return false;
}
@Override
public boolean isSlotEnabled(int idx, OptionalSlotFake osf)
{
if ( idx == 1 )
int upgrades = myte.getInstalledUpgrades( Upgrades.CAPACITY );
if ( idx == 1 && upgrades > 0 )
return true;
if ( idx == 2 )
if ( idx == 2 && upgrades > 1 )
return true;
return false;