Patching Operation Failed

Started by WolfgangPolska, October 21, 2018, 12:25:49 PM

Previous topic - Next topic

WolfgangPolska

Hello, I have recently started developing my own mod and I have trouble with changing yield type of mineables to item made by me.
Also adding recipes to smelter give out similar results.
Here is a code:
<?xml version="1.0" encoding="utf-8" ?>
<Patch>


<Operation Class="PatchOperationReplace">
<xpath>/Defs/ThingDef[@Name = "MineableSteel"]/building</xpath>
<value>
<isResourceRock>true</isResourceRock>
      <mineableThing>ChunkIronOre</mineableThing>
      <mineableYield>1</mineableYield>
      <mineableScatterCommonality>1</mineableScatterCommonality>
      <mineableScatterLumpSizeRange>
        <min>1</min>
        <max>1</max>
      </mineableScatterLumpSizeRange>
</value>
</Operation>


<Operation Class="PatchOperationAdd">
<xpath>/Defs/ThingDefs[@Name = "ElectricSmelter"]/recipes</xpath>
<value>
<li>SmeltIronOreChunk</li>
</value>
</Operation>
</Patch>
I have no idea how, but it works!!!

AileTheAlien

What errors do you get? (Attaching the log file will help too.) Does this work if you just edit the base-game's XML directly instead of making a patch?

WolfgangPolska

Yes, it works just fine
Here is an error log:
RimWorld 1.0.2059 rev1005
Verse.Log:Message(String, Boolean)
RimWorld.VersionControl:LogVersionNumber()
Verse.Root:CheckGlobalInit()
Verse.Root:Start()
Verse.Root_Entry:Start()

Attempt to use string thingdefs to refer to field thingDefs in type Verse.ThingFilter; xml tags are now case-sensitive. XML: <filter><thingdefs><li>CoalOre</li></thingdefs></filter>
Verse.Log:Error(String, Boolean)
Verse.DirectXmlToObject:GetFieldInfoForType(Type, String, XmlNode)
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
Verse.DirectXmlToObject:ListFromXml(XmlNode)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.DirectXmlLoader:DefFromNode(XmlNode, LoadableXmlAsset)
Verse.LoadedModManager:ParseAndProcessXML(XmlDocument, Dictionary`2)
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__1()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__1()

[Ore processing] Patch operation Verse.PatchOperationReplace(/Defs/ThingDef[@Name = "MineableSteel"]/building) failed
file: D:\64 Bit\Mods\Rimworld ore processing mod\Patches\orepatches.xml
Verse.Log:Error(String, Boolean)
Verse.PatchOperation:Complete(String)
Verse.LoadedModManager:ClearCachedPatches()
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__1()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__1()

[Ore processing] Patch operation Verse.PatchOperationAdd(/Defs/ThingDefs[@Name = "ElectricSmelter"]/recipes) failed
file: D:\64 Bit\Mods\Rimworld ore processing mod\Patches\orepatches.xml
Verse.Log:Error(String, Boolean)
Verse.PatchOperation:Complete(String)
Verse.LoadedModManager:ClearCachedPatches()
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__1()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__1()

Config error in CoalOre: description has trailing whitespace
Verse.Log:Error(String, Boolean)
Verse.DefDatabase`1:ErrorCheckAllDefs()
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.GenGeneric:InvokeStaticMethodOnGenericType(Type, Type, String)
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__1()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__1()

Could not load UnityEngine.Texture2D at resources\coal in any active mod or in base resources.
Verse.Log:Error(String, Boolean)
Verse.ContentFinder`1:Get(String, Boolean)
Verse.Graphic_Single:Init(GraphicRequest)
Verse.GraphicDatabase:GetInner(GraphicRequest)
Verse.GraphicDatabase:Get(Type, String, Shader, Vector2, Color, Color, GraphicData, List`1)
Verse.GraphicData:Init()
Verse.GraphicData:get_Graphic()
Verse.ThingDef:<PostLoad>m__3()
Verse.LongEventHandler:ExecuteToExecuteWhenFinished()
Verse.LongEventHandler:UpdateCurrentAsynchronousEvent()
Verse.LongEventHandler:LongEventsUpdate(Boolean&)
Verse.Root:Update()
Verse.Root_Entry:Update()

MatFrom with null sourceTex.
Verse.Log:Error(String, Boolean)
Verse.MaterialPool:MatFrom(MaterialRequest)
Verse.Graphic_Single:Init(GraphicRequest)
Verse.GraphicDatabase:GetInner(GraphicRequest)
Verse.GraphicDatabase:Get(Type, String, Shader, Vector2, Color, Color, GraphicData, List`1)
Verse.GraphicData:Init()
Verse.GraphicData:get_Graphic()
Verse.ThingDef:<PostLoad>m__3()
Verse.LongEventHandler:ExecuteToExecuteWhenFinished()
Verse.LongEventHandler:UpdateCurrentAsynchronousEvent()
Verse.LongEventHandler:LongEventsUpdate(Boolean&)
Verse.Root:Update()
Verse.Root_Entry:Update()

Collection cannot init: No textures found at path orechunks\iron_chunk
Verse.Log:Error(String, Boolean)
Verse.Graphic_Collection:Init(GraphicRequest)
Verse.GraphicDatabase:GetInner(GraphicRequest)
Verse.GraphicDatabase:Get(Type, String, Shader, Vector2, Color, Color, GraphicData, List`1)
Verse.GraphicData:Init()
Verse.GraphicData:get_Graphic()
Verse.ThingDef:<PostLoad>m__3()
Verse.LongEventHandler:ExecuteToExecuteWhenFinished()
Verse.LongEventHandler:UpdateCurrentAsynchronousEvent()
Verse.LongEventHandler:LongEventsUpdate(Boolean&)
Verse.Root:Update()
Verse.Root_Entry:Update()
I have no idea how, but it works!!!

swampslug

Firstly, you are using @Name when you should be using defName. @Name is used when refering to anything where Abstract="True" such as RockBase or BenchBase; defName is used to refer to anything else.

Also, from my experience when you use a replace operation, you should refer to the node you are replacing in the values so your first patch operation becomes:


  <Operation Class="PatchOperationReplace">
    <xpath>*/ThingDef[defName = "MineableSteel"]/building</xpath>
    <value>
      <building>
        <isResourceRock>true</isResourceRock>
        <mineableThing>ChunkIronOre</mineableThing>
        <mineableYield>1</mineableYield>
        <mineableScatterCommonality>1</mineableScatterCommonality>
        <mineableScatterLumpSizeRange>
          <min>1</min>
          <max>1</max>
        </mineableScatterLumpSizeRange>
      </building>
    </value>
  </Operation>


The second patch operation is also failing because of a spelling mistake (using ThingDefs rather than ThingDef) and so should look like:


  <Operation Class="PatchOperationAdd">
    <xpath>*/ThingDef[defName = "ElectricSmelter"]/recipes</xpath>
    <value>
      <li>SmeltIronOreChunk</li>
    </value>
  </Operation>


There are a few other errors your mod appears to be generating but these should address the two Patch operation errors.

WolfgangPolska

@swampslug Thank you very much! I'm totally green in that field and tutorails are scarce so it  is more of a trail and error here
I have no idea how, but it works!!!