mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-10-26 14:25:20 +00:00
Buff interface throughput (#350)
* Allow instant transfer from interface <-> interface We now try to inject all the items at once into a target interface's ME system. * Use a special adaptor for p2p items It will now use the destination p2p's inventory stack limit. This may or may not change any bottlenecking behavior
This commit is contained in:
1 parent
d6b15979f7
commit
8d1401e94b
7 files changed
+48
-13
No files matched your search
@@ -1150,6 +1150,10 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
return (te.zCoord << 24) ^ (te.xCoord << 8) ^ te.yCoord;
|
||||
}
|
||||
|
||||
public BaseActionSource getActionSource() {
|
||||
return interfaceRequestSource;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
this.updateCraftingList();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package appeng.util;
|
||||
|
||||
import appeng.parts.p2p.PartP2PItems;
|
||||
import appeng.util.inv.AdaptorIInventory;
|
||||
|
||||
public class AdaptorP2PItem extends AdaptorIInventory {
|
||||
|
||||
public AdaptorP2PItem(PartP2PItems p2p) {
|
||||
super(p2p, p2p.getInventoryStackLimit());
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import appeng.helpers.IInterfaceHost;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.IBetterStorage;
|
||||
import appeng.parts.p2p.PartP2PItems;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
@@ -62,6 +63,8 @@ public abstract class InventoryAdaptor implements Iterable<ItemSlot> {
|
||||
IPart part = ((TileCableBus) te).getPart(d);
|
||||
if (part instanceof IInterfaceHost host) {
|
||||
return new AdaptorDualityInterface(new WrapperMCISidedInventory(si, d), host);
|
||||
} else if (part instanceof PartP2PItems p2p) {
|
||||
return new AdaptorP2PItem(p2p);
|
||||
}
|
||||
}
|
||||
int stackLimit = 0;
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package appeng.util.inv;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.AdvancedBlockingMode;
|
||||
import appeng.api.config.InsertionMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class AdaptorDualityInterface extends AdaptorIInventory {
|
||||
|
||||
@@ -19,6 +24,28 @@ public class AdaptorDualityInterface extends AdaptorIInventory {
|
||||
this.interfaceHost = interfaceHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack addItems(ItemStack toBeAdded, InsertionMode insertionMode) {
|
||||
// Ignore insertion mode since injecting into a ME system doesn't have this concept
|
||||
IMEMonitor<IAEItemStack> monitor = interfaceHost.getInterfaceDuality().getItemInventory();
|
||||
IAEItemStack result = monitor.injectItems(
|
||||
AEItemStack.create(toBeAdded),
|
||||
Actionable.MODULATE,
|
||||
interfaceHost.getInterfaceDuality().getActionSource());
|
||||
return result == null ? null : result.getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateAdd(ItemStack toBeSimulated, InsertionMode insertionMode) {
|
||||
// Ignore insertion mode since injecting into a ME system doesn't have this concept
|
||||
IMEMonitor<IAEItemStack> monitor = interfaceHost.getInterfaceDuality().getItemInventory();
|
||||
IAEItemStack result = monitor.injectItems(
|
||||
AEItemStack.create(toBeSimulated),
|
||||
Actionable.SIMULATE,
|
||||
interfaceHost.getInterfaceDuality().getActionSource());
|
||||
return result == null ? null : result.getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsItems() {
|
||||
DualityInterface dual = interfaceHost.getInterfaceDuality();
|
||||
|
||||
@@ -235,12 +235,7 @@ public class AdaptorIInventory extends InventoryAdaptor {
|
||||
}
|
||||
|
||||
final ItemStack left = itemsToAdd.copy();
|
||||
|
||||
int internalLimit = 0;
|
||||
if (this.i instanceof WrapperInventoryRange) {
|
||||
internalLimit = ((WrapperInventoryRange) this.i).getInternalInventoryStackLimit();
|
||||
}
|
||||
int invLimit = internalLimit > 0 ? internalLimit : this.i.getInventoryStackLimit();
|
||||
int invLimit = this.i.getInventoryStackLimit();
|
||||
|
||||
final int perOperationLimit = this.skipStackSizeCheck ? invLimit
|
||||
: Math.min(invLimit, itemsToAdd.getMaxStackSize());
|
||||
|
||||
@@ -144,7 +144,7 @@ public class WrapperChainedInventory implements IInventory {
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
int smallest = 64;
|
||||
int smallest = Integer.MAX_VALUE;
|
||||
|
||||
for (final IInventory i : this.l) {
|
||||
smallest = Math.min(smallest, i.getInventoryStackLimit());
|
||||
|
||||
@@ -93,16 +93,11 @@ public class WrapperInventoryRange implements IInventory {
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return this.src.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
public int getInternalInventoryStackLimit() {
|
||||
if (this.src instanceof AEBaseInvTile) {
|
||||
IInventory internalInv = ((AEBaseInvTile) this.src).getInternalInventory();
|
||||
return internalInv.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
return 0;
|
||||
return this.src.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user