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

[Bug]: CuriosApi.getSlotHelper() is null on client during multiplayer #387

Closed
iron431 opened this issue Feb 28, 2024 · 5 comments
Closed
Assignees
Labels
status: resolved This issue or pull request has been resolved type: bug Something isn't working

Comments

@iron431
Copy link

iron431 commented Feb 28, 2024

Minecraft Version

1.19.2

What happened?

CuriosApi.getSlotHelper() returns null on a client when it's connected to a dedicated server (although not in singleplayer) causing a client side crash.

This can be seen through the Iron's Spells 'n Spellbooks mod, when trying to upgrade a spellbook, which is a curio item (Upgrades apply attributes to an item, meaning it requires an equipment or curio slot)

If this is intended, then I am unaware of how to collect all registered slot types from the client safely.
edit: does not happen in 1.20.1, so I assume it is not supposed to be null

How do you trigger this bug?

  1. Have common code that relies the SlotHelper that gets run on the client (ie Iron's spells n spellbooks)
  2. Connect to a dedicated server
  3. Trigger that code (ie apply any upgrade orb to a spell book in the arcane anvil)

Loader

Forge

Loader Version

43.3.0

Mod Version

1.19.2-5.1.6.1

Relevant Log Outputs

https://gist.github.com/iron431/330465ccc0f64e756841b0ea00a7f6ad

@iron431 iron431 added status: triage This issue or pull request is awaiting review type: bug Something isn't working labels Feb 28, 2024
@TheIllusiveC4 TheIllusiveC4 added status: pending This issue or pull request is pending further information or consideration and removed status: triage This issue or pull request is awaiting review labels Feb 28, 2024
@TheIllusiveC4
Copy link
Owner

If this is intended, then I am unaware of how to collect all registered slot types from the client safely.
edit: does not happen in 1.20.1, so I assume it is not supposed to be null

It's intended, as slot types do not exist on the client as they do on the server. I'm not entirely sure why it doesn't happen on 1.20.1 since the code is the same, in that setSlotHelper is only called on server start-up.

The question of how to get registered slot types safely on the client depends on what you need it for, and there are many potential solutions. Can you explain more about what your use-case is for these slot types?

@iron431
Copy link
Author

iron431 commented Feb 28, 2024

The question of how to get registered slot types safely on the client depends on what you need it for, and there are many potential solutions. Can you explain more about what your use-case is for these slot types?

I have an upgrade system where you can add attributes bonuses to equipment pieces, including curios. If a curio item is being upgraded, I need to know what slots the curio can be equipped in, to be handled in the CurioAttributeModifierEvent later. Currently, I do that by iterating over SlotHelper#getSlotTypes, checking if that slot is valid, then storing it in NBT if so.

@TheIllusiveC4
Copy link
Owner

Would you be able to use ICuriosHelper#getCurioTags(Item) for this? It returns a list of curio tags for the item that is passed in, which is effectively the same as the list of slot identifiers.

@iron431
Copy link
Author

iron431 commented Feb 28, 2024

That sounds like a good enough solution for now, hopefully there aren't many psychos with mismatching names

@TheIllusiveC4
Copy link
Owner

TheIllusiveC4 commented Feb 28, 2024

You don't have to worry in that regard, as mismatched names wouldn't work to begin with: the tag has to match the identifier, otherwise it can't be equipped anywhere. It's actually what's used for the main validity checks.

@TheIllusiveC4 TheIllusiveC4 added status: resolved This issue or pull request has been resolved and removed status: pending This issue or pull request is pending further information or consideration labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: resolved This issue or pull request has been resolved type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants