-
Notifications
You must be signed in to change notification settings - Fork 74
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
[Forge 1.16.1] Crash while locking a slot type in an onUnequip() method override #68
Comments
I'm not sure how you did expect this to play out totally fine. Take a look at Curios event handler, if you are curious: Curios/src/main/java/top/theillusivec4/curios/common/event/CuriosEventHandler.java Line 328 in 2b76762
It crashes because you basically attempt to modify the list of available slot handlers while Curios is in the process of cycling through that list to call things like onEquip()/onUnequip()/onTick()/etc., henceforth is your ConcurrentModificationException .
|
I don't think this is entirely correct, considering this crash doesn't happen when you're using any of the other methods, such as |
It does also crash, granted that the slot you are unlocking is not unlocked already and that it actually exists. onEquip() also isn't any different from onUnequip() in this context, since they are both called within same event handler when cycling through same list. I specifically did testing to confirm that my mind does not deceive me. My gotcha code looked as following:
What I got in log output:
It worked fine at first two equips since I already had slot unlocked, but as soon as I used Curios command to lock it back, I got exactly what I expected to behold. The moral stays simple - don't chop a tree when you sit on top of it. |
Extegral is correct in that this is an expected crash considering the context. However, I'm looking into the best viable solution for locking/unlocking slots based on equipment changes, which is the use-case that this issue stems from and the one that I'd like to resolve. If there's currently a workaround for that, I'd be interested to hear about it. |
Well, under current circumstances this crash can be avoided by any sort of system that would schedule slot locking/unlocking to be executed later, outside of ICurio calls. The simplest implementation of it I can think of would look something like this:
This is a specific example that takes into account only locking and assumes it is only required for players, and only one slot type will need to be locked per tick. But I suppose it is fairly understandable how it can be expanded to handle more complicated cases. |
Versions:
1.16.1-3.0.0.2
1.16.1-32.0.108
Observed Behavior: Item slot locking/disappearing, then game crashing immediately after
Expected Behavior: Item slot locking/disappearing, without game crashing
Steps to Reproduce:
CuriosApi.getSlotHelper().lockSlotType("name", livingEntity);
within anonUnequip()
method override of a different slot typeCrash Log: Pastebin
The text was updated successfully, but these errors were encountered: