[1.16.2] ImmutableMap passed into DimensionStructuresSettings.field_236193_d_ for Mining Dimension might crash some mods
TelepathicGrunt opened this issue ยท 7 comments
Hello! Once again, my mod has crashed again with yours lol. This time, it is due to the immutablemap that was passed into DimensionStructuresSettings's constructor for Mining Dimension's own dimension and I attempted to add my StructureSeparationSettings for my structures to it.
public final Map<Structure<?>, StructureSeparationSettings> structures;
However, I made the assumption that this map would always be mutable as vanilla's DimensionStructuresSettings.field_236193_d_ is always mutable. Hence why my mod crashed trying to add to the map to make sure that all dimensions truly does have the correct spacing settings for my structures. I did add a fix on my end to skip any dimension that used an immutable map but it might be a good idea on your end to change it to a mutable map just in case another mod makes the same assumption I did. It's best to replicate vanilla behavior with mutables/immutables.
That's all! :)
Oh I didn't realize source wa savaliable for you mod lol. Ok so looking closer, it seems the chunkgenerator is now made in json for mining dimension so that means the DimensionStructuresSettings is vanilla's.
Oh no. I think vanilla has it as mutable for hardcoded chunkgenerators but when doing datapacks, it immutable... why mojang lol.
Sorry about that, you can close this bug report. This is 100% an error on my end.
No problem. Maybe create a PR on the forge github. It seems that this problem is not only affecting your mod.
Yeah. Though if you know anyone who has the same issue, show them this fix I did after I used an access transformer to make field_236193_d_ not final. With the fix, everything works now. No crash and my structures appear in Mining Dimension perfectly
https://github.com/TelepathicGrunt/RepurposedStructures/blob/3a3a466272704073dde29a9079bdfb4a4d06d057/src/main/java/com/telepathicgrunt/repurposedstructures/mixin/MinecraftServerMixin.java#L86-L90
Like in my mod?
The old code I was using:
https://github.com/TelepathicGrunt/RepurposedStructures/blob/9cb280e3e75392cf722d95debcbec9bd3982436a/src/main/java/com/telepathicgrunt/repurposedstructures/mixin/MinecraftServerMixin.java#L80
The new code I'm using to skip immutable map and prevent my mod from crashing:
https://github.com/TelepathicGrunt/RepurposedStructures/blob/cdcb34e9064b34f5accfecb1e19eb2f0814299a9/src/main/java/com/telepathicgrunt/repurposedstructures/mixin/MinecraftServerMixin.java#L86-L109
To be clear on where the map is, it is in net.minecraft.world.gen.settings.DimensionStructuresSettings.field_236193_d_ (called structures in yarn). It seems to get stored in DimensionSettings in vanilla which then is stored into the ChunkGenerator. 1.16.2 codebase is kind of a mess lol
No. I mean the piece of code in my mod. I can't find anything related to this in my mod.