Skip to content

Commit b50b8d0

Browse files
committed
fix: restrict reserved cargo to matching frogport shipment
1 parent d96f6b0 commit b50b8d0

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

‎src/main/java/com/innygr/icreateordernetworking/blocks/TerminalLoggerBlockEntity.java‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import com.innygr.icreateordernetworking.registry.ModBlockEntities;
88
import com.innygr.icreateordernetworking.delivery.TrainShipmentMarker;
9+
import com.innygr.icreateordernetworking.delivery.DeliveryRoute;
10+
import com.innygr.icreateordernetworking.delivery.ShipmentJournalData;
911
import com.innygr.icreateordernetworking.delivery.AutomatedDeliveryService;
1012
import com.innygr.icreateordernetworking.compat.FTBTeamsCompat;
1113
import com.innygr.icreateordernetworking.logistics.TerminalLoggerConnection;
@@ -94,11 +96,25 @@ public ItemStack extractItem(int slot, int amount, boolean simulate) {
9496
// Cargo reserved for a durable shipment is locked to its route
9597
// adapter. A belt, funnel, or other capability consumer must not
9698
// be able to steal it from the logger while dispatch is pending.
97-
if (TrainShipmentMarker.transactionId(inventory.getStackInSlot(slot)) != null) {
98-
// A Packager directly attached to the configured output face
99-
// is the one permitted consumer for Frogport-bound reserved
100-
// cargo. Other pipes, belts, and automation still cannot steal it.
101-
BlockEntity adjacent = level == null ? null : level.getBlockEntity(worldPosition.relative(side));
99+
ItemStack existing = inventory.getStackInSlot(slot);
100+
UUID transactionId = TrainShipmentMarker.transactionId(existing);
101+
if (transactionId != null) {
102+
// Only the source Packager for a live Frogport reservation may
103+
// consume marked cargo. A nearby Packager must never steal a
104+
// train/airship shipment or a marker from another logger.
105+
if (!(level instanceof net.minecraft.server.level.ServerLevel serverLevel)) {
106+
return ItemStack.EMPTY;
107+
}
108+
ShipmentJournalData.Shipment shipment =
109+
ShipmentJournalData.get(serverLevel).find(transactionId);
110+
String source = worldPosition.getX() + "," + worldPosition.getY() + "," + worldPosition.getZ();
111+
if (shipment == null || shipment.route() != DeliveryRoute.FROGPORT
112+
|| shipment.stage() != ShipmentJournalData.Stage.RESERVED
113+
|| !shipment.sourceReference().startsWith(source + ">")
114+
|| !TrainShipmentMarker.matches(existing, shipment)) {
115+
return ItemStack.EMPTY;
116+
}
117+
BlockEntity adjacent = level.getBlockEntity(worldPosition.relative(side));
102118
if (!(adjacent instanceof com.simibubi.create.content.logistics.packager.PackagerBlockEntity packager)
103119
|| packager.getBlockState().getValue(
104120
com.simibubi.create.content.logistics.packager.PackagerBlock.FACING) != side

0 commit comments

Comments
 (0)