Fixed Interface Crash.

This commit is contained in:
AlgorithmX2 2014-07-12 16:28:55 -05:00
parent 48bc15fd82
commit 6fd32c3b12
3 changed files with 111 additions and 90 deletions

View file

@ -79,7 +79,7 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
public boolean isItemValid(ItemStack itemstack)
{
return itemstack != null && itemstack.getItem() instanceof ItemEncodedPattern;
}
@ -98,8 +98,7 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
InventoryAdaptor playerHand = new AdaptorPlayerHand( player );
WrapperInvSlot slotInv = new PatternInvSlot( inv.server );
slotInv.setSlot( slot );
InventoryAdaptor interfaceSlot = new AdaptorIInventory( slotInv );
InventoryAdaptor interfaceSlot = new AdaptorIInventory( slotInv.getWrapper( slot ) );
switch (action)
{
@ -111,7 +110,8 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
}
else
{
slotInv.setInventorySlotContents( 0, playerHand.addItems( slotInv.getStackInSlot( 0 ) ) );
IInventory mySlot = slotInv.getWrapper( slot );
mySlot.setInventorySlotContents( 0, playerHand.addItems( mySlot.getStackInSlot( 0 ) ) );
}
break;

View file

@ -298,7 +298,11 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
AppEngInternalInventory patterns = new AppEngInternalInventory( this, 9 );
WrapperInvSlot slotInv = new WrapperInvSlot( storage );
InventoryAdaptor adaptor = new AdaptorIInventory( slotInv );
private InventoryAdaptor getAdaptor(int slot)
{
return new AdaptorIInventory( slotInv.getWrapper( slot ) );
}
IMEInventory<IAEItemStack> destination;
private boolean isWorking = false;
@ -395,7 +399,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
private boolean usePlan(int x, IAEItemStack itemStack)
{
boolean changed = false;
slotInv.setSlot( x );
InventoryAdaptor adaptor = getAdaptor( x );
interfaceRequest = isWorking = true;
try
@ -918,18 +922,18 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
public IAEItemStack injectCratedItems(ICraftingLink link, IAEItemStack aquired, Actionable mode)
{
int x = craftingTracker.getSlot( link );
int slot = craftingTracker.getSlot( link );
if ( aquired != null && x >= 0 && x <= requireWork.length )
if ( aquired != null && slot >= 0 && slot <= requireWork.length )
{
slotInv.setSlot( x );
InventoryAdaptor adaptor = getAdaptor( slot );
if ( mode == Actionable.SIMULATE )
return AEItemStack.create( adaptor.simulateAdd( aquired.getItemStack() ) );
else
{
IAEItemStack is = AEItemStack.create( adaptor.addItems( aquired.getItemStack() ) );
updatePlan( x );
updatePlan( slot );
return is;
}
}

View file

@ -4,18 +4,17 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class WrapperInvSlot implements IInventory
public class WrapperInvSlot
{
private final IInventory inv;
private int slot = 0;
public WrapperInvSlot(IInventory inv) {
this.inv = inv;
}
public void setSlot(int slot)
class InternalInterfaceWrapper implements IInventory
{
private final IInventory inv;
private final int slot;
public InternalInterfaceWrapper(IInventory target, int slot) {
this.inv = target;
this.slot = slot;
}
@ -94,7 +93,25 @@ public class WrapperInvSlot implements IInventory
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
return inv.isItemValidForSlot( slot, itemstack );
return isItemValid( itemstack ) && inv.isItemValidForSlot( slot, itemstack );
}
};
private IInventory inv;
public WrapperInvSlot(IInventory inv) {
this.inv = inv;
}
public IInventory getWrapper(int slot)
{
InternalInterfaceWrapper wrapper = new InternalInterfaceWrapper( inv, slot );
return wrapper;
}
protected boolean isItemValid(ItemStack itemstack)
{
return true;
}
}