Sindarin27 / farsighted-mobs-forge

GNU Lesser General Public License v3.0
0 stars 0 forks source link

Crash `onLoadConfig`: `UnsupportedOperatationException` #6

Closed C0D3-M4513R closed 8 months ago

C0D3-M4513R commented 1 year ago

Not me that found it, but a person on the Magma discord.

Issue ticket:

My response: Mod issue. This line: https://github.com/Sindarin27/farsighted-mobs-forge/blob/efcb7043f4faad59f4902bbd1f27444dadf179fa/src/main/java/com/sindarin/farsightedmobs/Config.java#L52 Puts a list into com.sindarin.farsightedmobs.Config$Server.mobAttributeMap, that cannot be changed. (https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#singletonList-T-) This line however is not correct: https://github.com/Sindarin27/farsighted-mobs-forge/blob/efcb7043f4faad59f4902bbd1f27444dadf179fa/src/main/java/com/sindarin/farsightedmobs/Config.java#L48 because it tries to change the list, that cannot be changed.

Sindarin27 commented 1 year ago

Sorry for the late reply. I see the problem indeed; I naively assumed that Collections.singletonList would simply create a "normal" list containing the one element, but as you point out, it actually creates an immutable list. Since the mod currently only includes one attribute, this was not a problem. Seems like a simple enough fix, though.

C0D3-M4513R commented 1 year ago

I did a binary patch for that someone, that reported this btw. The change was actually simple.

(and yes I am accustomed to editing jvm bytecode by now, because many projects for 1.12.2 simply don't compile anymore... Thanks gradle for being so stable)