Valheim-Modding / Jotunn

Jötunn, the Valheim Library.
https://valheim-modding.github.io/Jotunn/
MIT License
128 stars 40 forks source link

[BUG] Minimap:m_pins is inaccessible when trying to read minimap pins in callback to `OnVanillaMapDataLoaded` #420

Closed marengohue closed 9 months ago

marengohue commented 10 months ago

Details: Jotunn Version: 2.16.2 Repeatability: Consistent

Problem Description: When following the tutorial page on minimap overlay / drawing manipulation, the provided code sample (https://valheim-modding.github.io/Jotunn/tutorials/map.html#example-1) throws an exception:

[Warning:Jotunn.EventExtensions] Exception thrown at event InvokeOnVanillaMapDataLoaded in Plugin.CreateMapDrawing:
System.FieldAccessException: Field `Minimap:m_pins' is inaccessible from method `Irrelephant.LotTW.Cartography.Plug
in:CreateMapDrawing ()'

Expected Behaviour: I expect to be able to read map pins.

Actual Behaviour: Overlay UI in the map doesn't show up, I can't execute the behaviour tied to the map pins.

Link to your server's and client's LogOutput.log all of the relevant log is in description above.

Plugin code: https://pastebin.com/xsKBPvcK

MSchmoecker commented 9 months ago

Sorry for the late response, you need to use an assembly publicizer like https://github.com/CabbageCrow/AssemblyPublicizer or https://github.com/BepInEx/BepInEx.AssemblyPublicizer. Also make sure to enable "Allow Unsafe Code" in your C# project so no errors are about protection levels are thrown at runtime.