eideehi / valheim-automatics

[Valheim] Mods that automate a variety of tasks
https://www.nexusmods.com/valheim/mods/1700
MIT License
8 stars 4 forks source link

Wont load custom icons for jewelcrafting, throws error #46

Closed Travisclare closed 1 year ago

Travisclare commented 1 year ago

Is there an existing issue for this?

Mod version

1.4.0

Is this a bug caused by this mod alone?

This mod alone did not reproduce the bug

List of mods to reproduce bug

[all prereqs] automatics jewelcrafting (OdinHorse for comparison)

("Is this a bug cuased by this mod alone?" was set to "this mod alone did not reproduce the bug" because the bug is due to trying to use automatics with modded stuff

What happened?

Error making custom icons for jewelcrafting

When autopinning, it works.

in: net-eidee.valheim.automatics.cfg - entry for automatics autopinning for jewelcrafting example:

custom_mineral = "[{\"identifier\":\"RawGreenGemstone\",\"label\":\"Emerald\",\"matches\":[{\"regex\":false,\"value\":\"$jc_raw_green_gemstone\"}]}] "

But when trying to load the custom icon, it loads the default round white dot, and throws the following error:

[Error  : Unity Log] ArgumentException: An item with the same key has already been added. Key: Automatics.AutomaticMapping.StaticObjectMapping+MapPinIdentify
Stack trace:
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Automatics.AutomaticMapping.StaticObjectMapping.AddPin (ZDOID uniqueId, UnityEngine.Vector3 pos, System.String pinName, System.Boolean save, Automatics.AutomaticMapping.Target target) (at <8c72363294194c5aa81f46a90142a1c5>:0)
Automatics.AutomaticMapping.StaticObjectMapping.AddPin (ZDOID uniqueId, UnityEngine.Vector3 pos, System.String pinName, Automatics.AutomaticMapping.Target target) (at <8c72363294194c5aa81f46a90142a1c5>:0)
Automatics.AutomaticMapping.StaticObjectMapping.MineralMapping (UnityEngine.Component component, System.String name) (at <8c72363294194c5aa81f46a90142a1c5>:0)
Automatics.AutomaticMapping.StaticObjectMapping.Mapping () (at <8c72363294194c5aa81f46a90142a1c5>:0)
Automatics.AutomaticMapping.AutomaticMapping.Mapping (Player player, System.Single delta, System.Boolean takeInput) (at <8c72363294194c5aa81f46a90142a1c5>:0)
Automatics.AutomaticMapping.Patches.Minimap_UpdateMap_Postfix (Player player, System.Single dt, System.Boolean takeInput) (at <8c72363294194c5aa81f46a90142a1c5>:0)
(wrapper dynamic-method) Minimap.DMD<Minimap::UpdateMap>(Minimap,Player,single,bool)
(wrapper dynamic-method) Minimap.DMD<Minimap::Update>(Minimap)

in: custom-map-icons.json - entry for automatics custom map icons for jewelcrafting example:

    {
        "target": {
            "name": "$jc_raw_green_gemstone"
        },
        "sprite": {
            "file": "uncutgreen.png",
            "width": 64,
            "height": 64
        },
        "options": {
            "hideNameTag": true

        }
    }

Return from (in console) printobjects mineral:

"Emerald Formation" ($jc_raw_green_gemstone)
  Pos: *omitted*
  Recommended identifier: RawGreenGemstone
  Pattern: $jc_raw_green_gemstone

It does, however, work for odinhorse. Both autopinning and custom map icons. Info below for comparison

in: net-eidee.valheim.automatics.cfg - entry for automatics autopinning for odinhorse example:

custom_animal = "[{\"identifier\":\"RaeOdinHorse\",\"label\":\"Horse\",\"matches\":[{\"regex\":false,\"value\":\"$horse_odin\"}]}]"

in: custom-map-icons.json - entry for automatics custom map icons for odinhorse example:

    {
        "target": {
            "name": "$horse_odin"
        },
        "sprite": {
            "file": "horse.png",
            "width": 64,
            "height": 64
        },
        "options": {
            "hideNameTag": true
        }
    }

Return from (in console) printobjects animal


"Horse" ($horse_odin)
  Pos: *omitted*
  Recommended Identifier: RaeOdinHorse
  Pattern: $horse_odin

Steps to reproduce the bug

Install mods previously listed

append in the previously listed configs, as well as adding in the necessary automatics custom map pins pieces as well as icon .png's (blank placeholder .png's have been uploaded to use, as to not share assets that do not belong to me

Logs and screenshots

horse uncutgreen

eideehi commented 1 year ago

Hmm. I've looked at the error log, but it seems like an error that shouldn't occur based on the code structure (although there's a possibility that I may have overlooked something). The error log seems to indicate that an exception occurred while attempting to pin an emerald, but I couldn't reproduce the error even when I went near an emerald in the same environment as the report. Please provide me with more detailed information about the circumstances in which the error occurs (e.g. when emeralds are clustered together, when attacking emeralds, etc.). Also, since I'm not familiar with jewelcrafting, please let me know if emeralds exhibit any special behavior (such as dividing under specific conditions).

The environment I used to attempt to reproduce the bug is as follows: Automatics 1.4.0 Jewelcrafting 1.4.4 OdinHorse 1.1.5

eideehi commented 1 year ago

I was able to reproduce the bug when loading the saved data earlier. I will investigate a little more.

Travisclare commented 1 year ago

Questions:

More info:

Let me know if you need any other information. Thank you for taking the time to look at this, it is very appreciated.

eideehi commented 1 year ago

This bug has been fixed in commit e5cfbf1529326e0ea51d628441deecce2f699aa1. Ultimately, it was a standalone bug unrelated to other mods.

Please wait for the bug fix release. Thank you for reporting the bug.

Travisclare commented 1 year ago

Thanks a ton! :)

Travisclare commented 1 year ago

Was it supposed to delete child mod and textures folder? Is there any way i can recover this?

Travisclare commented 1 year ago

Still get the error.

[Error  : Unity Log] ArgumentException: An item with the same key has already been added. Key: Automatics.AutomaticMapping.StaticObjectMapping+MapPinIdentify
Stack trace:
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Automatics.AutomaticMapping.StaticObjectMapping.AddPin (ZDOID uniqueId, UnityEngine.Vector3 pos, System.String pinName, System.Boolean save, Automatics.AutomaticMapping.Target target) (at <e28d2479d5a7448381f5e5ecd0111e08>:0)
Automatics.AutomaticMapping.StaticObjectMapping.AddPin (ZDOID uniqueId, UnityEngine.Vector3 pos, System.String pinName, Automatics.AutomaticMapping.Target target) (at <e28d2479d5a7448381f5e5ecd0111e08>:0)
Automatics.AutomaticMapping.StaticObjectMapping.MineralMapping (UnityEngine.Component component, System.String name) (at <e28d2479d5a7448381f5e5ecd0111e08>:0)
Automatics.AutomaticMapping.StaticObjectMapping.Mapping () (at <e28d2479d5a7448381f5e5ecd0111e08>:0)
Automatics.AutomaticMapping.AutomaticMapping.Mapping (Player player, System.Single delta, System.Boolean takeInput) (at <e28d2479d5a7448381f5e5ecd0111e08>:0)
Automatics.AutomaticMapping.Patches.Minimap_UpdateMap_Postfix (Player player, System.Single dt, System.Boolean takeInput) (at <e28d2479d5a7448381f5e5ecd0111e08>:0)
(wrapper dynamic-method) Minimap.DMD<Minimap::UpdateMap>(Minimap,Player,single,bool)
(wrapper dynamic-method) Minimap.DMD<Minimap::Update>(Minimap)

Custom map icons for jewelcrafting still dont load

Travisclare commented 1 year ago

error in debug build

[Info   :   BepInEx] Loading [Automatics 1.4.2]
[Warning:  HarmonyX] AccessTools.Field: Could not find field for type Minimap+PinData and name m_nameElement
[Error  :  HarmonyX] Failed to patch void Minimap::UpdatePins(): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00029] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <695d1cc93cca45069c528c15c9fdd749>:0
  at HarmonyLib.CodeMatcher.get_Labels () [0x0000c] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.CodeMatcher.CreateLabel (System.Reflection.Emit.Label& label) [0x00011] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at Automatics.AutomaticMapping.Patches.Minimap_UpdatePins_Transpiler (System.Collections.Generic.IEnumerable`1[T] instructions, System.Reflection.Emit.ILGenerator generator) [0x001c2] in <e28d2479d5a7448381f5e5ecd0111e08>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <695d1cc93cca45069c528c15c9fdd749>:0
   --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
  at HarmonyLib.Internal.Patching.ILManipulator.ApplyTranspilers (System.Reflection.Emit.ILGenerator il, System.Reflection.MethodBase original, System.Func`2[T,TResult] getLocal, System.Func`1[TResult] defineLabel) [0x00093] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Internal.Patching.ILManipulator.WriteTo (Mono.Cecil.Cil.MethodBody body, System.Reflection.MethodBase original) [0x00066] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Public.Patching.HarmonyManipulator.WriteTranspilers () [0x00084] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Public.Patching.HarmonyManipulator.WriteImpl () [0x0002b] in <474744d65d8e460fa08cd5fd82b5d65f>:0
[Error  :Automatics] Error while initializing Initialize
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> HarmonyLib.HarmonyException: IL Compile Error (unknown location) ---> HarmonyLib.HarmonyException: IL Compile Error (unknown location) ---> HarmonyLib.HarmonyException: IL Compile Error (unknown location) ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00029] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <695d1cc93cca45069c528c15c9fdd749>:0
  at HarmonyLib.CodeMatcher.get_Labels () [0x0000c] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.CodeMatcher.CreateLabel (System.Reflection.Emit.Label& label) [0x00011] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at Automatics.AutomaticMapping.Patches.Minimap_UpdatePins_Transpiler (System.Collections.Generic.IEnumerable`1[T] instructions, System.Reflection.Emit.ILGenerator generator) [0x001c2] in <e28d2479d5a7448381f5e5ecd0111e08>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <695d1cc93cca45069c528c15c9fdd749>:0
   --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
  at HarmonyLib.Internal.Patching.ILManipulator.ApplyTranspilers (System.Reflection.Emit.ILGenerator il, System.Reflection.MethodBase original, System.Func`2[T,TResult] getLocal, System.Func`1[TResult] defineLabel) [0x00093] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Internal.Patching.ILManipulator.WriteTo (Mono.Cecil.Cil.MethodBody body, System.Reflection.MethodBase original) [0x00066] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Public.Patching.HarmonyManipulator.WriteTranspilers () [0x00084] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Public.Patching.HarmonyManipulator.WriteImpl () [0x0002b] in <474744d65d8e460fa08cd5fd82b5d65f>:0
   --- End of inner exception stack trace ---
  at HarmonyLib.Public.Patching.HarmonyManipulator.WriteImpl () [0x00378] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Public.Patching.HarmonyManipulator.Process (MonoMod.Cil.ILContext ilContext, System.Reflection.MethodBase originalMethod) [0x00042] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Public.Patching.HarmonyManipulator.Manipulate (System.Reflection.MethodBase original, HarmonyLib.PatchInfo patchInfo, MonoMod.Cil.ILContext ctx) [0x00006] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Public.Patching.HarmonyManipulator.Manipulate (System.Reflection.MethodBase original, MonoMod.Cil.ILContext ctx) [0x00007] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Public.Patching.ManagedMethodPatcher.Manipulator (MonoMod.Cil.ILContext ctx) [0x00012] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at MonoMod.Cil.ILContext.Invoke (MonoMod.Cil.ILContext+Manipulator manip) [0x00087] in <6733e342b5b549bba815373898724469>:0
  at MonoMod.RuntimeDetour.ILHook+Context.InvokeManipulator (Mono.Cecil.MethodDefinition def, MonoMod.Cil.ILContext+Manipulator cb) [0x00012] in <4e2760c7517c4ea79c633d67e84b319f>:0
  at (wrapper dynamic-method) MonoMod.RuntimeDetour.ILHook+Context.DMD<MonoMod.RuntimeDetour.ILHook+Context::Refresh>(MonoMod.RuntimeDetour.ILHook/Context)
  at (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition.Trampoline<MonoMod.RuntimeDetour.ILHook+Context::Refresh>?-714302464(object)
  at HarmonyLib.Internal.RuntimeFixes.StackTraceFixes.OnILChainRefresh (System.Object self) [0x00000] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at MonoMod.RuntimeDetour.ILHook.Apply () [0x00059] in <4e2760c7517c4ea79c633d67e84b319f>:0
  at HarmonyLib.Public.Patching.ManagedMethodPatcher.DetourTo (System.Reflection.MethodBase replacement) [0x00047] in <474744d65d8e460fa08cd5fd82b5d65f>:0
   --- End of inner exception stack trace ---
  at HarmonyLib.Public.Patching.ManagedMethodPatcher.DetourTo (System.Reflection.MethodBase replacement) [0x0005f] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.PatchFunctions.UpdateWrapper (System.Reflection.MethodBase original, HarmonyLib.PatchInfo patchInfo) [0x00033] in <474744d65d8e460fa08cd5fd82b5d65f>:0
   --- End of inner exception stack trace ---
  at HarmonyLib.PatchClassProcessor.ReportException (System.Exception exception, System.Reflection.MethodBase original) [0x00045] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.PatchClassProcessor.Patch () [0x00095] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Harmony.PatchAll (System.Type type) [0x00008] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Harmony.CreateAndPatchAll (System.Type type, System.String harmonyInstanceId) [0x0001e] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at Automatics.AutomaticMapping.Module.Initialize () [0x000c1] in <e28d2479d5a7448381f5e5ecd0111e08>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <695d1cc93cca45069c528c15c9fdd749>:0
   --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <695d1cc93cca45069c528c15c9fdd749>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
  at Automatics.Automatics.InitializeModules (System.Reflection.Assembly assembly) [0x00097] in <e28d2479d5a7448381f5e5ecd0111e08>:0
eideehi commented 1 year ago

Could you please provide the steps to reproduce the https://github.com/eideehi/valheim-automatics/issues/46#issuecomment-1467724261 error? Please describe in as much detail as possible the actions taken from the start of the game until the error occurred. Additionally, if possible, please check if the error can be reproduced using only Automatics.