Compare commits

...

1 Commits

Author SHA1 Message Date
PrototypeTrousers 9fc96295a8 0 2022-01-14 15:02:30 -03:00
4 changed files with 22 additions and 7 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ aebuild=7
aegroup=appeng aegroup=appeng
aebasename=appliedenergistics2 aebasename=appliedenergistics2
trousers=trousers_edition trousers=trousers_edition
trousersversion=v49s trousersversion=v49t
######################################################### #########################################################
# Versions # # Versions #
######################################################### #########################################################
@@ -121,4 +121,8 @@ public interface IAEItemStack extends IAEStack<IAEItemStack>
*/ */
boolean equals(ItemStack is); boolean equals(ItemStack is);
ItemStack getCachedItemStack();
void setCachedItemStack(ItemStack is);
} }
@@ -62,8 +62,6 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
private StorageFilter mode; private StorageFilter mode;
private AccessRestriction access; private AccessRestriction access;
private ItemStack stackCache = null;
ItemHandlerAdapter( IItemHandler itemHandler, IGridProxyable proxy ) ItemHandlerAdapter( IItemHandler itemHandler, IGridProxyable proxy )
{ {
this.itemHandler = itemHandler; this.itemHandler = itemHandler;
@@ -82,8 +80,8 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
public IAEItemStack injectItems( IAEItemStack iox, Actionable type, IActionSource src ) public IAEItemStack injectItems( IAEItemStack iox, Actionable type, IActionSource src )
{ {
// Try to reuse the cached stack // Try to reuse the cached stack
@Nullable ItemStack currentCached = stackCache; @Nullable ItemStack currentCached = iox.getCachedItemStack();
stackCache = null; iox.setCachedItemStack(null);
ItemStack orgInput; ItemStack orgInput;
int slotCount = this.itemHandler.getSlots(); int slotCount = this.itemHandler.getSlots();
@@ -108,9 +106,9 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
} }
// Store the stack in the cache for next time. // Store the stack in the cache for next time.
if( !remaining.isEmpty() && remaining != orgInput ) if( !remaining.isEmpty() )
{ {
stackCache = remaining; iox.setCachedItemStack( remaining );
} }
// At this point, we still have some items left... // At this point, we still have some items left...
@@ -53,6 +53,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
private String displayName; private String displayName;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private List<String> tooltip; private List<String> tooltip;
private ItemStack cachedItemStack;
private AEItemStack(final AEItemStack is) { private AEItemStack(final AEItemStack is) {
this.setStackSize(is.getStackSize()); this.setStackSize(is.getStackSize());
@@ -250,6 +251,18 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
return this.isSameType(is); return this.isSameType(is);
} }
@Override
public ItemStack getCachedItemStack()
{
return this.cachedItemStack;
}
@Override
public void setCachedItemStack( ItemStack is )
{
this.cachedItemStack = is;
}
@Override @Override
public String toString() { public String toString() {
return this.getStackSize() + "x" + this.getDefinition().getItem().getRegistryName(); return this.getStackSize() + "x" + this.getDefinition().getItem().getRegistryName();