Open XFactHD opened 1 year ago
You're right. We had a similar issue in Dungeons Gear that was fixed. I had no idea the same problem was also present here.
As for why a constructor gets registered to the event bus, I...don't know what to tell you. I had the same reaction when I saw that in Dungeons Gear. I'll have to look back at the commit history and see who added that.
Fixed for 1.19.2 in next version. Need to backport
Fixed in 4.0.7-beta for 1.19.2.
I noticed this while looking at the log of a user in the Forge Discord. The data structures used by
ItemProperties
are not thread-safe and as such must be enqueued to run sequentially throughFMLClientSetupEvent#enqueueWork()
, otherwise you may get aConcurrentModificationException
when at least one other mod makes the same mistake.Example stacktrace
``` [17:53:02] [Worker-Main-2/ERROR] [ne.mi.fm.ja.FMLModContainer/LOADING]: Caught exception during event FMLClientSetupEvent dispatch for modid dungeons_mobs java.util.ConcurrentModificationException: null at java.util.HashMap.computeIfAbsent(HashMap.java:1221) ~[?:?] {re:mixin} at net.minecraft.client.renderer.item.ItemProperties.register(ItemProperties.java:53) ~[client-1.19.2-20220805.130853-srg.jar#336!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at com.infamous.dungeons_mobs.client.ModItemModelProperties.Forge version: 1.19.2-43.2.0 Dungeons Mobs version: 1.19.2-4.0.6-beta
Reading the involved code also makes me question why a constructor is used for the registration instead of a static method, considering the event bus registration of that instance seems to be completely pointless (https://github.com/Infamous-Misadventures/Dungeons-Mobs/blob/1.19/src/main/java/com/infamous/dungeons_mobs/DungeonsMobs.java#L92).