From bdc7a62c39def703d9cdd9868628cf140bb3dcfe Mon Sep 17 00:00:00 2001 From: EggleEgg <125359838+EggleEgg@users.noreply.github.com> Date: Wed, 10 Jun 2026 14:16:49 +0200 Subject: [PATCH] linkSameType field for ItemBridge --- .../world/blocks/distribution/ItemBridge.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/mindustry/world/blocks/distribution/ItemBridge.java index 5141e14109be..4d5cb53561f2 100644 --- a/core/src/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/mindustry/world/blocks/distribution/ItemBridge.java @@ -33,6 +33,8 @@ public class ItemBridge extends Block{ public boolean fadeIn = true; public boolean moveArrows = true; public boolean pulse = false; + /** If true, only allows this bridge to link with the same block type. Otherwise this can link with any ItemBridge. */ + public boolean linkSameType = true; public float arrowSpacing = 4f, arrowOffset = 2f, arrowPeriod = 0.4f; public float arrowTimeScl = 6.2f; public float bridgeWidth = 6.5f; @@ -147,18 +149,28 @@ public boolean linkValid(Tile tile, Tile other){ } public boolean linkValid(Tile tile, Tile other, boolean checkDouble){ - if(other == null || tile == null || !positionsValid(tile.x, tile.y, other.x, other.y)) return false; + if(other == null || tile == null || !positionsValid(tile.x, tile.y, other.x, other.y, linkSameType ? range + : Math.max(tile.block() instanceof ItemBridge bt ? bt.range : range, other.block() instanceof ItemBridge bo ? bo.range : range))) return false; + if(!linkSameType){ + //false if at least 1 module isn't shared + if(!(tile.block().hasItems && other.block().hasItems) && !(tile.block().hasLiquids && other.block().hasLiquids)) return false; + } - return ((other.block() == tile.block() && tile.block() == this) || (!(tile.block() instanceof ItemBridge) && other.block() == this)) + return ((linkSameType ? other.block() == tile.block() && tile.block() == this : (other.block() instanceof ItemBridge && tile.block() instanceof ItemBridge)) + || (!(tile.block() instanceof ItemBridge) && other.block() == this)) && (other.team() == tile.team() || tile.block() != this) && (!checkDouble || ((ItemBridgeBuild)other.build).link != tile.pos()); } public boolean positionsValid(int x1, int y1, int x2, int y2){ + return positionsValid(x1, y1, x2, y2, range); + } + + public boolean positionsValid(int x1, int y1, int x2, int y2, int baseRange){ if(x1 == x2){ - return Math.abs(y1 - y2) <= range; + return Math.abs(y1 - y2) <= baseRange; }else if(y1 == y2){ - return Math.abs(x1 - x2) <= range; + return Math.abs(x1 - x2) <= baseRange; }else{ return false; }