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 event-itemstack for ComplexRecipe #7674

Open
wants to merge 1 commit into
base: dev/patch
Choose a base branch
from

Conversation

ChickChicky
Copy link

Description

With CraftEvent, the item stack is obtained through looking at the recipe's result. However, in the majority of cases, when the recipe is a ComplexRecipe, this result is air.
This PR adds a check to instead use the currentItem method in such cases, which solves the issue without altering the behaviour with 'normal' crafts.

This would potentially be an issue, as scripts relying on this bug would stop working.
However, it would eliminate some confusion, and allow to tell the items in question apart (as far as I know, there was no way to previously do so in such cases).


Target Minecraft Versions: any
Requirements: none
Related Issues: #5762

@Burbulinis
Copy link
Contributor

Burbulinis commented Mar 3, 2025

In my opinion, this fix is unreliable, and not what the user would want. Though, there is an existing recipe PR, which might include this

@TheAbsolutionism
Copy link
Contributor

Though, there is an existing recipe PR, which might include this

It does not

@Fusezion
Copy link
Contributor

Fusezion commented Mar 3, 2025

In my opinion, this fix is unreliable, and not what the user would want. Though, there is an existing recipe PR, which might include this

Sadly due to restrictions there really isn't any other fix, the only thing I could think of is implementing it as a future event-value to retain existing behavior, but since the method name is current it doesn't make sense for it to be future

@Efnilite Efnilite added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Mar 3, 2025
Copy link
Member

@Efnilite Efnilite left a comment

Choose a reason for hiding this comment

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

as long as the previous way for checking the result item (that isnt air) still works, lgtm

@Burbulinis
Copy link
Contributor

perhaps tests? :D

@ChickChicky
Copy link
Author

Right, I've run the test tasks and wrote a simple script that shows what items are crafted, but I'll try to see if some more advanced scripts (updated to work with the patch) still hold up.

@ChickChicky
Copy link
Author

In my opinion, this fix is unreliable, and not what the user would want.
Sadly due to restrictions there really isn't any other fix.

I would argue that the users probably would want the item to make sense, and not simply be a bogus "air" for some recipes.
Ideally a new separate event could be created to distinguish regular crafts from "special" ones, but due to the way events are managed, I can't find an easy way to do so.
Another solution could be exposing the Recipe to Skript for CraftItemEvent or some other way for the script to figure out what kind of craft it is processing.
Although, perhaps exposing the recipes for just this event isn't particulatily interesting as is. But it could also potentially be useful for PrepareItemCraftEvent or whenever custom recipes get implemented (#7150).

@Fusezion
Copy link
Contributor

Fusezion commented Mar 3, 2025

Another solution could be exposing the Recipe to Skript for CraftItemEvent or some other way for the script to figure out what kind of craft it is processing.

recipes will be exposed when the recipe pr is merged, a custom event would be discouraged by me since it's an extra step for no benefit. Only concern I have is possible breaking behavior in skripts, but the only two solutions would be

a) register a future event-value, which doesn't make sense as it's present
b) register a new expression along the lines of the method name but it's overly broad current item and current crafted item aren't great

So I'm fine with just adding it on top of the existing event-value

@ChickChicky
Copy link
Author

ChickChicky commented Mar 3, 2025

the only thing I could think of is implementing it as a future event-value to retain existing behavior

a) register a future event-value, which doesn't make sense as it's present
b) register a new expression along the lines of the method name but it's overly broad current item and current crafted item aren't great

Oh, my bad I am not super familiar with Skript, I wasn't aware of the time states system.
These two fixes would be the least disruptive ones. The new item syntax makes sense, but I agree that future item is a bit awkward, and to me, the crafted item syntax doesn't look too off. And both of them could have the benefit of referencing directly the crafted item stack itself rather than the supposed virtual result (although I haven't tested that yet, so still to be confirmed).

If what I just said turns out true, and we do go for completely removing the bug, wouldn't it make more sense to broaden the patch for all crafting recipes, after making sure, of course, that everything works fine that way too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants