diff --git a/container/implementations/ContainerInterfaceTerminal.java b/container/implementations/ContainerInterfaceTerminal.java index 61416ac19..6ee1f803d 100644 --- a/container/implementations/ContainerInterfaceTerminal.java +++ b/container/implementations/ContainerInterfaceTerminal.java @@ -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; diff --git a/helpers/DualityInterface.java b/helpers/DualityInterface.java index 662f01338..f17142e4c 100644 --- a/helpers/DualityInterface.java +++ b/helpers/DualityInterface.java @@ -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 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; } } diff --git a/util/inv/WrapperInvSlot.java b/util/inv/WrapperInvSlot.java index 788f6e7ce..3b712e1d7 100644 --- a/util/inv/WrapperInvSlot.java +++ b/util/inv/WrapperInvSlot.java @@ -4,97 +4,114 @@ 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; + class InternalInterfaceWrapper implements IInventory + { + + private final IInventory inv; + private final int slot; + + public InternalInterfaceWrapper(IInventory target, int slot) { + this.inv = target; + this.slot = slot; + } + + @Override + public int getSizeInventory() + { + return 1; + } + + @Override + public ItemStack getStackInSlot(int i) + { + return inv.getStackInSlot( slot ); + } + + @Override + public ItemStack decrStackSize(int i, int num) + { + return inv.decrStackSize( slot, num ); + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) + { + return inv.getStackInSlotOnClosing( slot ); + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) + { + inv.setInventorySlotContents( slot, itemstack ); + } + + @Override + public String getInventoryName() + { + return inv.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() + { + return inv.hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() + { + return inv.getInventoryStackLimit(); + } + + @Override + public void markDirty() + { + inv.markDirty(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) + { + return inv.isUseableByPlayer( entityplayer ); + } + + @Override + public void openInventory() + { + inv.openInventory(); + } + + @Override + public void closeInventory() + { + inv.closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) + { + return isItemValid( itemstack ) && inv.isItemValidForSlot( slot, itemstack ); + } + }; + + private IInventory inv; public WrapperInvSlot(IInventory inv) { this.inv = inv; } - public void setSlot(int slot) + public IInventory getWrapper(int slot) { - this.slot = slot; + InternalInterfaceWrapper wrapper = new InternalInterfaceWrapper( inv, slot ); + return wrapper; } - @Override - public int getSizeInventory() + protected boolean isItemValid(ItemStack itemstack) { - return 1; - } - - @Override - public ItemStack getStackInSlot(int i) - { - return inv.getStackInSlot( slot ); - } - - @Override - public ItemStack decrStackSize(int i, int num) - { - return inv.decrStackSize( slot, num ); - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) - { - return inv.getStackInSlotOnClosing( slot ); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) - { - inv.setInventorySlotContents( slot, itemstack ); - } - - @Override - public String getInventoryName() - { - return inv.getInventoryName(); - } - - @Override - public boolean hasCustomInventoryName() - { - return inv.hasCustomInventoryName(); - } - - @Override - public int getInventoryStackLimit() - { - return inv.getInventoryStackLimit(); - } - - @Override - public void markDirty() - { - inv.markDirty(); - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - return inv.isUseableByPlayer( entityplayer ); - } - - @Override - public void openInventory() - { - inv.openInventory(); - } - - @Override - public void closeInventory() - { - inv.closeInventory(); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) - { - return inv.isItemValidForSlot( slot, itemstack ); + return true; } }