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 generator skipping item drop #22

Merged
merged 1 commit into from
Nov 1, 2021
Merged

Conversation

dhiepp
Copy link
Contributor

@dhiepp dhiepp commented Nov 1, 2021

Identify the Bug

Iron and Gold generators don't drop the correct amount of items
For example if you set in config amount: 3 then it will only drop 2 items
and if you set in config amount: 5 then it will only drop 3 items

This bug is caused by an extra line in OreGenerator class dropItem method
temp--;
We don't need that extra line because the loop's logic is flawed:
temp = amount as the starting statement will set temp variable to the amount we want
temp >= 0 as the ending condition will make it spawn an extra item because when temp variable is at zero, the loop still continues one more time

Description of the Change

Set the loop's ending condition to temp > 0 will make the loop stop when the correct amount of items have been spawned, so we don't need that extra line anymore

@andrei1058
Copy link
Owner

Thank you!

@andrei1058 andrei1058 merged commit e0919d9 into andrei1058:master Nov 1, 2021
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