Lots of Gui And Slot related Changes.

This commit is contained in:
AlgorithmX2 2013-12-29 23:52:00 -06:00
parent 14207bb8e7
commit c4b43eb0cf
7 changed files with 58 additions and 25 deletions

View file

@ -18,7 +18,7 @@ import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.InternalSlotME;
import appeng.client.me.SlotME;
import appeng.container.slot.ISlotPlayerSide;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotDisabled;
import appeng.container.slot.SlotFake;
@ -48,6 +48,15 @@ public abstract class AEBaseContainer extends Container
return tileEntity;
}
@Override
protected Slot addSlotToContainer(Slot newSlot)
{
if ( newSlot instanceof AppEngSlot )
return super.addSlotToContainer( newSlot );
else
throw new RuntimeException( "Invalid Slot for AE Container." );
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
@ -78,7 +87,7 @@ public abstract class AEBaseContainer extends Container
}
ItemStack tis = null;
Slot clickSlot = (Slot) this.inventorySlots.get( idx );
AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get( idx ); // require AE SLots!
if ( clickSlot instanceof SlotDisabled || clickSlot instanceof SlotInaccessable )
return null;
@ -94,16 +103,16 @@ public abstract class AEBaseContainer extends Container
/**
* Gather a list of valid destinations.
*/
if ( clickSlot instanceof ISlotPlayerSide )
if ( clickSlot.isPlayerSide() )
{
tis = shiftStoreItem( tis );
// target slots in the container...
for (int x = 0; x < this.inventorySlots.size(); x++)
{
Slot cs = (Slot) this.inventorySlots.get( x );
AppEngSlot cs = (AppEngSlot) this.inventorySlots.get( x );
if ( !(cs instanceof ISlotPlayerSide) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix) )
if ( !(cs.isPlayerSide()) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix) )
{
if ( cs.isItemValid( tis ) )
selectedSlots.add( cs );
@ -115,9 +124,9 @@ public abstract class AEBaseContainer extends Container
// target slots in the container...
for (int x = 0; x < this.inventorySlots.size(); x++)
{
Slot cs = (Slot) this.inventorySlots.get( x );
AppEngSlot cs = (AppEngSlot) this.inventorySlots.get( x );
if ( (cs instanceof ISlotPlayerSide) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix) )
if ( (cs.isPlayerSide()) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix) )
{
if ( cs.isItemValid( tis ) )
selectedSlots.add( cs );
@ -128,17 +137,17 @@ public abstract class AEBaseContainer extends Container
/**
* Handle Fake Slot Shift clicking.
*/
if ( selectedSlots.isEmpty() && clickSlot instanceof ISlotPlayerSide )
if ( selectedSlots.isEmpty() && clickSlot.isPlayerSide() )
{
if ( tis != null )
{
// target slots in the container...
for (int x = 0; x < this.inventorySlots.size(); x++)
{
Slot cs = (Slot) this.inventorySlots.get( x );
AppEngSlot cs = (AppEngSlot) this.inventorySlots.get( x );
ItemStack dest = cs.getStack();
if ( !(cs instanceof ISlotPlayerSide) && cs instanceof SlotFake )
if ( !(cs.isPlayerSide()) && cs instanceof SlotFake )
{
if ( Platform.isSameItem( dest, tis ) )
return null;

View file

@ -12,6 +12,14 @@ public class AppEngSlot extends Slot
NotAvailable, Valid, Invalid
};
public boolean isPlayerSide = false;
public Slot setPlayerSide()
{
isPlayerSide = true;
return this;
}
public int icon = -1;
public hasCalculatedValidness isValid;
public int defX, defY;
@ -68,4 +76,9 @@ public class AppEngSlot extends Slot
return icon;
}
public boolean isPlayerSide()
{
return isPlayerSide;
}
}

View file

@ -1,8 +0,0 @@
package appeng.container.slot;
// anything that implements this interface is treated as being part of the players interface, rather then the chests...
public interface ISlotPlayerSide
{
}

View file

@ -15,6 +15,11 @@ public class SlotFake extends AppEngSlot
invSlot = idx;
}
public boolean isEnabled()
{
return true;
}
public void addToInv(ItemStack is)
{
if ( is != null )
@ -27,7 +32,8 @@ public class SlotFake extends AppEngSlot
if ( current.stackSize > inventory.getInventoryStackLimit() )
current.stackSize = inventory.getInventoryStackLimit();
} else
}
else
{
current = is.copy();
@ -36,7 +42,8 @@ public class SlotFake extends AppEngSlot
this.inventory.setInventorySlotContents( invSlot, current );
}
} else
}
else
{
this.inventory.setInventorySlotContents( invSlot, null );
}
@ -82,4 +89,5 @@ public class SlotFake extends AppEngSlot
{
return true;
}
}

View file

@ -2,10 +2,11 @@ package appeng.container.slot;
import net.minecraft.inventory.IInventory;
public class SlotPlayerHotBar extends AppEngSlot implements ISlotPlayerSide
public class SlotPlayerHotBar extends AppEngSlot
{
public SlotPlayerHotBar(IInventory par1iInventory, int par2, int par3, int par4) {
super( par1iInventory, par2, par3, par4 );
isPlayerSide = true;
}
}

View file

@ -4,10 +4,12 @@ import net.minecraft.inventory.IInventory;
// there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot.
public class SlotPlayerInv extends AppEngSlot implements ISlotPlayerSide
public class SlotPlayerInv extends AppEngSlot
{
public SlotPlayerInv(IInventory par1iInventory, int par2, int par3, int par4) {
super( par1iInventory, par2, par3, par4 );
;
isPlayerSide = true;
}
}

View file

@ -11,6 +11,7 @@ import appeng.api.crafting.ICraftingPatternMAC;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.implementations.ISpatialStorageCell;
import appeng.api.implementations.IStorageComponent;
import appeng.api.implementations.IUpgradeModule;
import appeng.util.Platform;
public class SlotRestrictedInput extends AppEngSlot
@ -18,9 +19,9 @@ public class SlotRestrictedInput extends AppEngSlot
public enum PlaceableItemType
{
STORAGE_CELLS(15), ORE(1 * 16 + 15), STORAGE_COMPONENT(3 * 16 + 15), WIRELESS_TERMINAL(4 * 16 + 15), TRASH(5 * 16 + 15), VALID_ENCODED_PATTERN_W_OUPUT(7 * 16 + 15), ENCODED_PATTERN_W_OUTPUT(
7 * 16 + 15), ENCODED_PATTERN(7 * 16 + 15), BLANK_PATTERN(8 * 16 + 15), POWERED_TOOL(9 * 16 + 15), RANGE_BOOSTER(6 * 16 + 15), QE_SINGULARTIY(10 * 16 + 15), SPATIAL_STORAGE_CELLS(
11 * 16 + 15), FUEL(12 * 16 + 15);
STORAGE_CELLS(15), ORE(1 * 16 + 15), STORAGE_COMPONENT(3 * 16 + 15), WIRELESS_TERMINAL(4 * 16 + 15), TRASH(5 * 16 + 15), VALID_ENCODED_PATTERN_W_OUPUT(
7 * 16 + 15), ENCODED_PATTERN_W_OUTPUT(7 * 16 + 15), ENCODED_PATTERN(7 * 16 + 15), BLANK_PATTERN(8 * 16 + 15), POWERED_TOOL(9 * 16 + 15), RANGE_BOOSTER(
6 * 16 + 15), QE_SINGULARTIY(10 * 16 + 15), SPATIAL_STORAGE_CELLS(11 * 16 + 15), FUEL(12 * 16 + 15), UPGRADES(13 * 16 + 15);
public final int icon;
@ -90,6 +91,9 @@ public class SlotRestrictedInput extends AppEngSlot
if ( i.getItem() == null )
return false;
if ( !inventory.isItemValidForSlot( this.getSlotIndex(), i ) )
return false;
IAppEngApi api = AEApi.instance();
switch (which)
{
@ -133,6 +137,10 @@ public class SlotRestrictedInput extends AppEngSlot
return true;
case WIRELESS_TERMINAL:
return AEApi.instance().registries().wireless().isWirelessTerminal( i );
case UPGRADES:
return i.getItem() instanceof IUpgradeModule && ((IUpgradeModule) i.getItem()).getType( i ) != null;
default:
break;
}
return false;