Frepo Posted January 29 Report Share Posted January 29 (edited) THE SOLUTION { "op": "add", "side": "server", "path": "/variantgroups/-", "value": {"code": "material", "states": ["bone"]}, "file": "game:itemtypes/tool/arrow.json" }, I was a bit confused, to say the least, reading the patching "tutorial" at the VS modding page. At the "overwriting issue" part, there's a little demo-snippet of adding a behavior (which I thought would be pretty much the same as adding a new element to the variantgroup array). As you can see at the "value" line, the syntax differs from my (finally working) solution, the brackets "[ ]" are placed differently. I'm not adept enough yet to draw any conclusions about this. { "op": "add", "path": "/behaviors", "value": [{ "name": "SealPlacedCrock" }], "file": "game:itemtypes/resource/fat.json" } ------------------------------------ Is it possible to add additional types into a variantgroup through patching? And how would that patch look like? Can't find any examples online. Eg. variantgroups: [ { code: "material", states: ["crude", "flint" ] }, ], ...and add "bone" to the list variantgroups: [ { code: "material", states: ["crude", "flint", "bone" ] }, ], I've gotten all other forms of patching working so far. But trying this won't work no matter how I try to write it.So I've started to mod this wonderful masterpiece of a game! Haven't got into C# coding yet. But I think I've gotten the hang of changing recipes and patching stuff like nutrition in food and textures on vanilla items (noticed that lead and silver solderbars both used the tin texture, and fixed that). Then I made some custom items; Shroompowder (made mushrooms grindable in the quern) and a steel variant of the soldering iron. So far so good. THE PROBLEM So I ran into some serious trouble when attempting to add a new type of arrow (bone arrow). First I made the arrow head and the arrow itself in their own jsons (copied from vanilla). Just changed the texture of the arrow head, had it use the flint arrow shape and set it's own damage and breakchange values (so the arrow item/entity is still an instance of the ItemArrow and EntityProjectile classes). So I crafted a couple of arrows, threw them on the ground, picked them up again, took aim with my bow, bone arrow loaded, and let loose.... that's when the game crashed. The log mentions the ItemBow.cs class. Looked for ages in the itemtype, shape and entity jsons, but can't see what could cause the problem. I thought maybe the ItemBow class somehow must recognize the arrow, and it won't with custom arrows this way (I don't know, maybe all arrow types are instanciated at startup of VS before starting a server and loading the mods or something). I realize that this item is a little more complex since it involves projectile entities. So my next attempt was to instead just patch the jsons to include "bone" as a material, and thus as it's own type. The game doesn't crash anymore, but the arrow won't show up when I search for it. It simply doesn't exist.MY QUESTION What am I missing here? Is it even possible to add custom arrows without coding? Edited January 31 by Frepo problem solved Link to comment Share on other sites More sharing options...
DArkHekRoMaNT Posted February 1 Report Share Posted February 1 (edited) You can access an array element by its id (0, 1, 2, 3, etc). Or use "-" to add to the end of the array (same as 2 for ["crude", "flint"]) { "op": "add", "side": "server", "path": "/variantgroups/0/states/-", "value": "bone", "file": "game:itemtypes/tool/arrow.json" }, Edited February 1 by DArkHekRoMaNT Link to comment Share on other sites More sharing options...
Frepo Posted February 2 Author Report Share Posted February 2 Aaaaah! I didn't understand you needed an index-position right after ("/variantgroups/n"). I actually never noticed that variantgroups was an array all along! Didn't see the "[ ]", I was focused on the path and the value lines, just took for granted that it was "{ }". Wow, that's a revelation! thank you thank you thank you! One more thing; I strangely messed up the gold and silver arrows arrowhead texture (notice: just the arrow head) when inserting the bone texture for my arrow. { "op": "replace", "side": "server", "path": "/texturesByType", "value": { "*-bone": {"material": { "base": "game:block/bonesrotten" }}, "*-flint": {"material": { "base": "game:block/stone/flint" }}, "*-crude": { }, "*": {"material": { "base": "game:block/metal/ingot/{material}" }} }, "file": "game:itemtypes/tool/arrow.json" }, First I tried with the "add" operation, but that messed all other texures up, except for my bone arrow. So I just replaced the entire section. Then everything looked good except for silver and gold. But I thought what ever, noone makes those arrows anyway, right? Link to comment Share on other sites More sharing options...
DArkHekRoMaNT Posted February 19 Report Share Posted February 19 On 2/2/2023 at 12:19 PM, Frepo said: Aaaaah! I didn't understand you needed an index-position right after ("/variantgroups/n"). I actually never noticed that variantgroups was an array all along! Didn't see the "[ ]", I was focused on the path and the value lines, just took for granted that it was "{ }". Wow, that's a revelation! thank you thank you thank you! One more thing; I strangely messed up the gold and silver arrows arrowhead texture (notice: just the arrow head) when inserting the bone texture for my arrow. { "op": "replace", "side": "server", "path": "/texturesByType", "value": { "*-bone": {"material": { "base": "game:block/bonesrotten" }}, "*-flint": {"material": { "base": "game:block/stone/flint" }}, "*-crude": { }, "*": {"material": { "base": "game:block/metal/ingot/{material}" }} }, "file": "game:itemtypes/tool/arrow.json" }, First I tried with the "add" operation, but that messed all other texures up, except for my bone arrow. So I just replaced the entire section. Then everything looked good except for silver and gold. But I thought what ever, noone makes those arrows anyway, right? If you need to add something before "*" (takes any values), then you can use a little hack: 1. "op": "move" with "path": "/temp" for "*" 2. Add others 3. "op": "move" with "path": "/originalpath" for "*"Example Link to comment Share on other sites More sharing options...
Frepo Posted February 19 Author Report Share Posted February 19 (edited) I didn't know you could target a specific entry (or line or whatever it's called) within a "{ } -list". So if I understand this right, the op's behave like the following in a case like this (with /texturesByType) :add: adds a new entry at the end (we can't target a specific index since it's not an [ ]-array). and I can't use this command since "*" comes before my added line, making it unreachable? or is add only used to add a new property that isn't already present, e.g. /combustibleProps?replace: simply replaces the entire section. again, we can't target any specific entries?move: this one actually CAN target a specific entry. (/move on "*"). so I could (if I wanted) use it to move e.g. "*-flint"?remove: removes entire section (/textureByType). again, we can't target any specific entries? Edited February 19 by Frepo Link to comment Share on other sites More sharing options...
Recommended Posts