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 inconsistent craft replacements (#9250) #12819

Merged
merged 1 commit into from
Sep 30, 2022

Conversation

Wuzzy2
Copy link
Contributor

@Wuzzy2 Wuzzy2 commented Sep 28, 2022

Fixes #9250.

How to test:

Use this recipe in MTG:

minetest.register_craft({
	type = "shaped",
	recipe = {
		{"group:leaves", "default:apple"},
		{"default:apple", "group:leaves"},
	},
	output = "default:dirt",
	replacements = {
		{"group:leaves", "default:sapling"},
	},
})

Craft this recipe.
One time craft it with exactly 1 of each of the 4 recipe input slots in the grid.
The other time, craft it with exactly 2 of each recipe input slots in the grid.

Both times, you should get 1 dirt as regular output plus 1 sapling.
In the first time, the sapling appears in the crafting grid.
In the second time, the sapling appears in your inventory instead.

(The bug was that in the second time, you might end up with 2 instead of 1 sapling, depending on the stack sizes of your input items.)

Shoutout to @p-ouellette!

Copy link
Contributor

@TurkeyMcMac TurkeyMcMac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works.

@Wuzzy2
Copy link
Contributor Author

Wuzzy2 commented Sep 29, 2022

So I'm not going to change this PR because of the break statements, until a maintainer says otherwise (and it's still functional).

@fluxionary
Copy link
Contributor

fluxionary commented Sep 29, 2022

There's still a bug somewhere.

use this recipe:

minetest.register_craft({
    type = "shapeless",
    output = "default:tree",
    recipe = {"default:wood", "default:wood", "default:stick", "default:stick"},
    replacements = {
        {"default:wood", "default:coal_lump"},
        {"default:wood", "default:coal_lump"},
        {"default:stick", "default:stick"},
    },
})

expected results after crafting w/ stacks of count 2 in the crafting grid, crafting a single item:

  • get 1 default:tree
  • get 2 default:coal_lump in main inventory
  • get 1 default:stick in main inventory
  • crafting grid still contains 2 stacks of 1 default:wood and 2 stacks of 1 default:stick.

however, you will end up w/ 2 default:stick in main inventory instead of 1 (everything else as expected).

things still work as expected when the grid would be empty afterwards.

@TurkeyMcMac
Copy link
Contributor

I can't reproduce your issue.

@fluxionary
Copy link
Contributor

I can't reproduce your issue.

you're right, i was running the test in the wrong window. everything works fine now.

@sfan5 sfan5 added the Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines label Sep 30, 2022
@TurkeyMcMac TurkeyMcMac merged commit 6eb7d57 into minetest:master Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix 🐛 PRs that fix a bug One approval ✅ ◻️ @ Server / Client / Env. Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistency with crafting replacements with multiple inputs
5 participants