Skip to content

Try and fix distribution pipe hang#206

Merged
multiplemonomials merged 3 commits into
masterfrom
bugfix/fix-distribution-pipe-hang
Mar 27, 2026
Merged

Try and fix distribution pipe hang#206
multiplemonomials merged 3 commits into
masterfrom
bugfix/fix-distribution-pipe-hang

Conversation

@multiplemonomials

@multiplemonomials multiplemonomials commented Oct 16, 2025

Copy link
Copy Markdown
Collaborator

This issue was very helpfully described by @Rishum-P here: #203 (comment)

I tried to reproduce it and I believe it's actually even easier to cause than described. You just need to have a distribution pipe with 0 values for all connected sides. Feeding items into that pipe is enough to cause an infinite loop and eventual crash (when running in singleplayer).

As I understand, this issue basically happens because toNextOpenSide() only tries all possible open sides once before giving up and returning. So if we are in a situation where no side is a valid destination for items, we will just get stuck in the while loop in splitStacks() forever and ever.

I added two different protections against this issue happening. First of all, toNextOpenSide() now returns false if it cannot find a valid side, and in this situation we just set no specific destination for the item stack. This fixes the crash, and causes buildcraft to route the item stack randomly.

However, I wanted un-routable items to be dropped on the ground, so I added a new sideCheck() event handler which disallows items from going to any side that has a distribution amount of 0. This should only have one effect, which is to cause items to be dropped unless there is at least one connected side that has a distribution amount greater than 0.

double horizontalRange = 16;
List<EntityWolf> list = world.getEntitiesWithinAABB(EntityWolf.class, new AxisAlignedBB(player.posX, player.posY, player.posZ,
player.posX + 1.0D, player.posY + 1.0D, player.posZ + 1.0D).grow(horizontalRange, 10.0D, horizontalRange));
List<EntityWolf> list = world.getEntitiesWithinAABB(EntityWolf.class, new AxisAlignedBB(player.posX, player.posY + 1.0D, player.posZ,

@multiplemonomials multiplemonomials Oct 16, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Randomly noticed that this logic is slightly broken. If we want to create the bounding box centered on the player, then it should be initially created with size of 0 and centered on the player's coordinates.

@multiplemonomials

Copy link
Copy Markdown
Collaborator Author

Here's a build from this branch: additionalpipes-6.0.1.jar.zip

@Munchy907

Copy link
Copy Markdown

Yeah, looks like it fixes the issue.

Does seem to introduce a interesting bug/quirk. If the input is side is set (is not 0), but no other side is, or the side(s) connected are not set (is 0), it'll drop the items (Assuming this is intended behaviour). The bug/quirk happens if the input side is set, and the side(s) connected are also set. The item will try go back the input side, if it's that sides turn.
Example below:
https://github.com/user-attachments/assets/03371aac-facb-4705-b0f3-d90afde37a00

Very minor thing, and if the input side is put as 0 then this never happens. But thought it worth mentioning.

Other than that, looks good!

@Munchy907

Copy link
Copy Markdown

So checked before the patch as I couldn't see what you changed to cause this, and it was already there. So I don't think this is a bug, and with a wooden transport pipe instead of gravity, the item goes back to the chest. I can imagine there'd be rare edge cases where this functionality would be wanted. Also this functionality can be turned off by setting input sides colour to 0.

Can still fix if you'd prefer

@multiplemonomials

Copy link
Copy Markdown
Collaborator Author

Ah yes this is intentional behavior, older versions of the mod also did this

@multiplemonomials
multiplemonomials merged commit b4bccd5 into master Mar 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants