Curios API (Forge/NeoForge)

Curios API (Forge/NeoForge)

140M Downloads

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

iron431 opened this issue ยท 5 comments

commented

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

commented

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?

commented

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.

commented

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.

commented

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

commented

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.