From a7e9c3586e9ace76b6e6f785e7df363289cc4a80 Mon Sep 17 00:00:00 2001 From: Andy Kish Date: Thu, 15 Jan 2026 14:41:05 -0500 Subject: [PATCH] Fix multiple export cables not working. --- gradle.properties | 2 +- .../storagenetwork/block/main/TileMain.java | 25 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 7b8b74e0..84cc9a18 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ org.gradle.daemon=false mod_id=storagenetwork curse_id=268495 -mod_version=1.12.1 +mod_version=1.13.0 mc_version=1.20.1 diff --git a/src/main/java/com/lothrazar/storagenetwork/block/main/TileMain.java b/src/main/java/com/lothrazar/storagenetwork/block/main/TileMain.java index 31ee5ecc..0b6deb05 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/main/TileMain.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/main/TileMain.java @@ -1,5 +1,6 @@ package com.lothrazar.storagenetwork.block.main; +import java.util.List; import com.lothrazar.storagenetwork.StorageNetworkMod; import com.lothrazar.storagenetwork.api.DimPos; import com.lothrazar.storagenetwork.api.EnumStorageDirection; @@ -9,11 +10,13 @@ import com.lothrazar.storagenetwork.capability.handler.ItemStackMatcher; import com.lothrazar.storagenetwork.registry.SsnRegistry; import com.lothrazar.storagenetwork.registry.StorageNetworkCapabilities; +import com.lothrazar.storagenetwork.util.Request; import com.lothrazar.storagenetwork.util.RequestBatch; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Connection; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; @@ -119,7 +122,8 @@ private void tick() { return; } refresh(); - RequestBatch requestBatch = null; + RequestBatch requestBatch = new RequestBatch(); + int exportCableCount = 0; for (IConnectable connectable : nw.getConnectables()) { if (connectable == null || connectable.getPos() == null) { continue; @@ -142,10 +146,27 @@ private void tick() { ioCap.runImport(this); } if (ioCap.ioDirection() == EnumStorageDirection.OUT) { - requestBatch = ioCap.runExport(this); + exportCableCount++; + RequestBatch cableBatch = ioCap.runExport(this); + StorageNetworkMod.log("Export cable #" + exportCableCount + " at " + connectable.getPos().getBlockPos() + " created batch with " + (cableBatch == null ? "0" : cableBatch.size()) + " item types"); + if (cableBatch != null) { + // Merge this cable's requests into the accumulated batch + for (Item item : cableBatch.keySet()) { + List requests = cableBatch.get(item); + if (requests != null) { + for (Request request : requests) { + requestBatch.put(item, request); + } + } + } + } } } } + // Execute all accumulated export requests at once, properly sorted by priority + if (!requestBatch.isEmpty()) { + StorageNetworkMod.log("Executing accumulated batch with " + requestBatch.size() + " item types from " + exportCableCount + " cables"); + } executeRequestBatch(requestBatch); }