Fix error message appearing if crafting replacements drop on the floor #12820
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.
This PR fixes a faulty error message.
There was a rare log error message which appeared if you crafted something that had replacements and your inventory and crafting grid are too full so the items are dropped on the floor instead.
The error message was:
Relevant code snippet:
The mistake was in the
if
statement. The>=
was the wrong way and should be<=
.The check is there to see if the stack count of the new stack is smaller than the original stack after dropping it on the floor with
item_OnDrop
. Another indicator that something was wrong that the itemstring in the actual error message was the empty string.The original count is
count
and the new count isoutput_replacement.count
. So, the expected case is thatcount
is larger, and the error case should trigger if it is smaller or equal.As you can see, the check is
count >= output_replacement.count
, so it got it wrong.The fix is to change it to
count <= output_replacement.count
.How to test
Use this code for MTG:
Fill your inventory completely with dirt and put in the recipe, but with multiple gold ingots in the input slots. Then craft.
Expected: You get a gold block in your cursor, and a gold lump, iron lump and coal lump drop on the floor. NO error message.