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

Fix: Farming Weight Overtake ETA #2158

Merged
merged 1 commit into from
Jun 30, 2024
Merged

Conversation

evhan3584
Copy link
Contributor

@evhan3584 evhan3584 commented Jun 26, 2024

PR Reviews

When your PR is marked as ready for review, some of our maintainers will look through your code to make sure everything is good to go. In order to do this, they may request some changes you will need to do, or fix smaller stuff (like merge conflicts) for you. If a maintainer has reviewed your PR, make sure to pull any of their changes into your local project before doing more work on your code. Having maintainers fix small stuff for you helps us speed up the process of merging your PR, so if some of your systems warrant further care, be sure to let us know (preferably with a code comment).

Make sure to only mark your PR as "Ready to review" when it is. If you still want to do major changes, you can keep a draft PR open until then.

What

This is a simple fix to the Farming Weight Overtake ETA.

Changelog Fixes

  • Fix an issue where the farming overtake ETA was being displayed as 60 times longer than it actually was. - Evhan_

@evhan3584 evhan3584 marked this pull request as ready for review June 26, 2024 01:42
@evhan3584
Copy link
Contributor Author

I frequently encounter the following error:

 
Caused by java.lang.IllegalArgumentException: Duration value cannot be NaN.
	at kotlin.time.DurationKt.toDuration(Duration.kt:1131)
	at SH.features.garden.farming.FarmingWeightDisplay.getETA(FarmingWeightDisplay.kt:313)
	at SH.features.garden.farming.FarmingWeightDisplay.update(FarmingWeightDisplay.kt:204)
	at SH.features.garden.farming.FarmingWeightDisplay.onTick(FarmingWeightDisplay.kt:81)
	at SH.data.MinecraftData.onTick(MinecraftData.kt:76)
	at FML.common.eventhandler.EventBus.post(EventBus.java:140)

Extra data:
weightPerSecond: 'NaN'
weightUntilOvertake: '2247.192604832075'
totalWeight: '320.29089239432443'
nextPlayer.weight: '2567.4834972264'

It appears that the issue is mitigated by replacing line 387 with the following code:

weightPerSecond = (weightDiff / diff * speed / 1000).let { if (it.isNaN()) -1.0 else it }

I suspect that diff can sometimes be set as NaN or 0 by GardenCropMilestoneDisplay. Should I include this change in my PR?

@hannibal002 hannibal002 added this to the Version 0.26 milestone Jun 26, 2024
@hannibal002 hannibal002 added the Bug Fix Bug fixes label Jun 26, 2024
@evhan3584 evhan3584 changed the title Fix: Farming Weight Overtake ETA - Initial Commit Fix: Farming Weight Overtake ETA Jun 26, 2024
@hannibal002 hannibal002 merged commit aaee445 into hannibal002:beta Jun 30, 2024
1 check passed
@github-actions github-actions bot removed the Bug Fix Bug fixes label Jun 30, 2024
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