Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mechanical multiblock speedometers sometimes stop outputting redstone when world reloaded #5

Open
Hawk777 opened this issue Jan 2, 2022 · 4 comments

Comments

@Hawk777
Copy link

Hawk777 commented Jan 2, 2022

Create a mechanical multiblock. Include a speedometer. Get the shaft spinning nice and fast. Quit Minecraft, start it up again, and load the world. Sometimes, but not always, the redstone output signal from the speedometer will be zero (as measured with either IE redstone connectors or even just vanilla redstone dust), even though the shaft is still spinning. Removing and replacing the redstone beside the speedometer does not seem to help. However, when the speed changes a bit, or if you use the hammer to change the speed limit, the output seems to update properly.

@Hawk777
Copy link
Author

Hawk777 commented Jan 2, 2022

I wonder if this might possibly be related to this line? When the speedometer has just been created, the old values will be −1, I believe, as those are the fields’ default values. Now floor==old can never be true in that case; however, certainly old<newExact will always be true, but if mod is ≤ THRESHOLD then that branch will not be taken, and old>newExact is obviously also not true (since old is −1), so then the function will return old, which is −1.

It also seems like this code might be wrong if the speed of the multiblock can change quickly enough that it goes from, say, 10.5 to 12 in a single tick. That should obviously update the output, but since you’re using the mod operator, mod will be zero which is less than THRESHOLD and the output will not update AFAICT—it will stay at 10. It seems to me that the output should update if newExact >= old + 1 + THRESHOLD or if newExact <= old - THRESHOLD, which would probably actually be faster to calculate anyway due to the lack of mod operator.

@kappa-maintainer
Copy link

I fixed this bug in my fork, but the fork is only compatible with IC2:Classic

@Hawk777
Copy link
Author

Hawk777 commented Jan 31, 2022

@kappa-maintainer if you fixed it in a separate commit, would you want to send it upstream (here)? If not I might eventually get around to doing a fix myself.

@kappa-maintainer
Copy link

Well, I will commit it to the translation update PR.

kappa-maintainer added a commit to kappa-maintainer/IndustrialWires-Classic that referenced this issue Feb 2, 2022
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

No branches or pull requests

2 participants