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

Ingredient parsing may swallow parse errors #743

Open
Shadows-of-Fire opened this issue Mar 24, 2024 · 5 comments
Open

Ingredient parsing may swallow parse errors #743

Shadows-of-Fire opened this issue Mar 24, 2024 · 5 comments
Labels
1.20.4 Targeted at Minecraft 1.20.4 bug A bug or error triage Needs triaging and confirmation

Comments

@Shadows-of-Fire
Copy link
Contributor

Shadows-of-Fire commented Mar 24, 2024

I was porting something containing the following Ingredient:

{
    "type": "forge:nbt",
    "item": "minecraft:potion",
    "nbt": "{\"Potion\": \"minecraft:night_vision\"}"
}

Since the ingredient type is now neoforged:nbt, I would expect this to error. However, this actually results in a successful deserialization with an ingredient containing just the minecraft:potion item.

@Shadows-of-Fire Shadows-of-Fire added bug A bug or error triage Needs triaging and confirmation 1.20.4 Targeted at Minecraft 1.20.4 labels Mar 24, 2024
@Technici4n
Copy link
Member

That's a side-effect of using Either codecs. We probably want a way to skip the second codec if some key exists in the codec.

@KnightMiner
Copy link

Didn't we discuss this issue on Discord before? The solution recommend was instead of using an either codec, to just have the type field default to the ID of the vanilla serializer in the forge registry.

@marchermans
Copy link
Contributor

Yes this was a direct concequence of the requirement that if you used the vanilla ingredient it should not have a "type" field.

If somebody knows a better codec setup to do this, I would be open to figure this out.

@FiniteReality
Copy link
Member

If somebody knows a better codec setup to do this, I would be open to figure this out.

My thought would be a custom MapCodec based on KeyDispatchCodec which replaces the typeKey/keyCodec fields with a MapCodec which is built with optionalFieldOf

@Shadows-of-Fire
Copy link
Contributor Author

I have this codec which is a dispatch codec with the ability to set a default type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.20.4 Targeted at Minecraft 1.20.4 bug A bug or error triage Needs triaging and confirmation
Projects
None yet
Development

No branches or pull requests

5 participants