Skip to content

Commit

Permalink
Fix bridges of different types joining
Browse files Browse the repository at this point in the history
  • Loading branch information
Mars committed Apr 9, 2023
1 parent d8a12bd commit d477ff0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/me/mars/Bridges.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public static void eventInit() {
Events.on(BlockBuildEndEvent.class, blockBuildEndEvent -> {
if (!(blockBuildEndEvent.tile.build instanceof ItemBridgeBuild bridge)) return;
// TODO: This may or may not fire late/early. It is an issue can't solve for now. Probably a source of bugs
// TODO: Figure out what the second part of my comment meant
if (blockBuildEndEvent.config == null) {
lastConfigs.remove(bridge.pos());
} else if (blockBuildEndEvent.config instanceof Integer pos) {
Expand Down Expand Up @@ -259,7 +260,7 @@ static void bridgeBuilt(ItemBridgeBuild bridge) {
}
// Form for link
Segment segment = findSegStrict(Point2.x(bridge.link), Point2.y(bridge.link), Segment.linkDir(bridge));
if (segment == null) {
if (segment == null || segment.block != bridge.block) {
formSegment(bridge);
} else {
QuadTree<Segment> tree = getTree(segment.linkDir());
Expand Down
4 changes: 3 additions & 1 deletion src/me/mars/Segment.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ static void setRect(int x, int y, int x2, int y2, Rect out) { // Non inclusive
public static ItemBridgeBuild getEnd(ItemBridgeBuild start, IntSeq bridges) {
ItemBridgeBuild next = start;
byte startDir = linkDir(start);
while (Vars.world.build(next.link) instanceof ItemBridgeBuild nextLink && next != nextLink && linkDir(next) == startDir) {
ItemBridge bridge = (ItemBridge) start.block;
while (Vars.world.build(next.link) instanceof ItemBridgeBuild nextLink && bridge.linkValid(next.tile, nextLink.tile) &&
next != nextLink && linkDir(next) == startDir) {
bridges.add(next.pos());
next = nextLink;
}
Expand Down

0 comments on commit d477ff0

Please sign in to comment.