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

craft all: properly invoke on_crafted callbacks #23

Merged
merged 3 commits into from
Feb 27, 2023

Conversation

fluxionary
Copy link
Member

a player reported that crafting coconut milk from moretrees using the "craft all" button resulted in the axe in the recipe being lost, instead of being worn down.

image

this is because the "wearing" of the tool is handled via a minetest.register_on_craft callback, and uip doesn't invoke those callbacks. the correct behavior, it seems, is to invoke core.on_craft, which isn't documented, but which is how the engine invokes those callbacks.

an upside of using this handler is that we no longer have to explicitly call the stamina/skyblock on_craft code, and we're probably now compatible w/ a number of other mods as well.

while i was updating the code, i also switched from using a detached inventory to a FakeInventory from my futil mod. this is because every modification of a detached inventory is sent to the player, even if the inventory is destroyed before the player can interact w/ it. basically, it cuts down on the number of packets sent to a player, which can be noticeable when working w/ very large stacks.

@SwissalpS
Copy link

+1 for moving away from detached_inventory

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.

3 participants