Skip to content

Commit c99604b

Browse files
committed
fix: define factory identity boundary for shared stock frequencies
1 parent 7f3b5fd commit c99604b

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎src/main/java/com/innygr/icreateordernetworking/logistics/StockLinkBindingData.java‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ public record Binding(String dimension, long packedPosition, UUID createNetworkI
2929
UUID factoryId, UUID factoryOwnerId, UUID factoryTeamId) {}
3030
private record Key(String dimension, long packedPosition) {}
3131

32+
/**
33+
* A shared Create frequency is not a factory permission boundary. Source
34+
* Stock Links must be bound to the same factory identity as the selected
35+
* root link, even when the actor belongs to both factories' team.
36+
*/
37+
static boolean belongsToSameFactory(Binding expected, Binding candidate) {
38+
return expected != null && candidate != null
39+
&& expected.factoryId().equals(candidate.factoryId())
40+
&& expected.factoryOwnerId().equals(candidate.factoryOwnerId())
41+
&& java.util.Objects.equals(expected.factoryTeamId(), candidate.factoryTeamId())
42+
&& expected.createNetworkId().equals(candidate.createNetworkId());
43+
}
44+
3245
public static StockLinkBindingData get(ServerLevel level) {
3346
return level.getServer().overworld().getDataStorage().computeIfAbsent(
3447
new SavedData.Factory<>(StockLinkBindingData::new, StockLinkBindingData::load), DATA_NAME);

0 commit comments

Comments
 (0)