Fix #7148: Andesite Tunnel not triggering on first segment of forward belts#9967
Open
Apertyotis wants to merge 2 commits intoCreators-of-Create:mc1.21.1/devfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix #7148
Issue
Andesite Tunnels placed on the first segment of a forward-moving belt never trigger, while the same setup works correctly on reverse belts.
This happens because belt logic only checks the upcoming segment index when items move forward.
For example:
0.9fto1.1f, it transitions into segment index1, triggering the tunnel at index1.0.0f.-1 → 0, the tunnel at index 0 is never evaluated.In contrast, reverse belts do not suffer from this issue:
[0, 4]with indices{0,1,2,3}.4.0fand move toward3.x.3, which corresponds to the first physical segment of the belt.Fix
To make forward belt behavior consistent with reverse belts:
When the belt moves forward and:
currentSegmentis treated as-1.The equality case (
== 0.0f) is included because items are inserted at exactly 0.0f, which should logically represent the pre-first-segment boundary.The
< 0.0fcase is necessary because blocked items may be pushed slightly negative (-0.01f), and due to integer truncation(int) -0.01fwould otherwise still resolve to0.This is not the only possible fix.
For example, Brass Tunnels avoid this issue because they can be evaluated through a different timing mechanism. It would be possible to refactor Andesite Tunnel checks similarly.
However, that would involve deeper changes to belt logic.
The current fix is intentionally minimal and preserves previous behavior as much as possible.
Additional Observation (Not Addressed in This PR)
If maximum rpm is increased via config and belts exceed 480 RPM, items may move across multiple segments in a single tick. This can cause intermediate tunnels to be skipped entirely.
Funnels do not suffer from this issue because they iterate across all segments along the movement path. Applying similar path traversal logic to tunnels could prevent this edge case.
However, this would require a more substantial refactor, and I do not feel confident proposing a safe implementation for it.