Jump to content

Modding firewood and firewood piles


CJH

Recommended Posts

Hey ya'all! I am wanting to mod the firewood logs and firewood piles to add textures for the different types of firewood. I am running into coding issues mostly because the game code only allows for one type of wood named "firewood". This presents the issue that all the code needs to be patched to allow for the different types of logs in the game, and added in the future. I would love to collaborate with someone to make this happen.

UPDATE:
I am at an impass as how to proceed. I think the best route would be an entirely new code mod, but I am not proficient in C# so I need help! I could use a GitHub collaborator that knows C# code and/or is well versed in modding Vintage Story.

GOALS:

  1. Create log textures to add in-game wood types. COMPLETE
  2. Modify the burn times of logs to be more realistic. COMPLETE
  3. Modify the temperature of logs to be more realistic. COMPLETE
  4. Have all code point to using survival/worldproperties/block/wood.json file as the variant group for future compatibility.
  5. Add new firewood recipe/grid JSON(s).
  6. Add new firewood resource/itemtype JSONs.
  7. Add new firewood shapes/item JSONs.
  8. Add new firewoodpile blocktypes/wood/generic JSONs.
  9. Add new firewoodpile shapes/block/wood JSONs.

PROJECT FILES:
Find them in my GitHub here

Edited by CJHKnight2
Changed GitHub URL
Link to comment
Share on other sites

It sounds like you're trying to add variant groups to firewood. This isn't too hard and just requires something like this added to firewood.json:

Spoiler

    variantgroups: [ { code: "type", states: ["acacia", "birch", "kapok", "maple", "oak", "pine", "aged"] }, ],

However, this will annihilate any existing firewood in someone's world, so you would want to add a patches folder and create a remap.json file that looks like this:

Spoiler

[
  {
    "file": "game:config/remaps.json",
    "op": "add",
    "path": "/MODNAME:MODNAME",
    "value": [
    "/iir remapq MODNAME:firewood-oak game:firewood force", 
    ]
  }
]

Obviously you would want to replace MODNAME with whatever your mod is called. Don't use spaces.

This will create your new types of wood and any pre-existing firewood will be prompted to change into oak firewood. From here you should be able to figure out how to apply the texture you made to these new variants. This is the easy part.

Quote

Have all code point to using survival/worldproperties/block/wood.json file as the variant group for future compatibility.

This is not easy. I'm not even 100% sure what you mean here, it sounds like you want the game and any mods in the future that reference game:firewood to automatically refer to your firewood instead. Is that correct?

Link to comment
Share on other sites

15 minutes ago, l33tmaan said:

This is not easy. I'm not even 100% sure what you mean here, it sounds like you want the game and any mods in the future that reference game:firewood to automatically refer to your firewood instead. Is that correct?

I am just trying to use the WorldProperties for block/wood in the survival folder. My thinking is that it would make it super easy to add more wood types just by patching this one JSON and have all the other JSONs and c# code use {wood} as the type. That way you just had to patch one JSON and add textures via the mod. Currently the game is coded for firewoodpile and firewood to create only one type of fire log. I want the new code to be universal to add more tree log types for future compatability.

Edited by CJHKnight2
  • Confused 1
Link to comment
Share on other sites

1 hour ago, l33tmaan said:

It sounds like you're trying to add variant groups to firewood. This isn't too hard and just requires something like this added to firewood.json:

  Reveal hidden contents

    variantgroups: [ { code: "type", states: ["acacia", "birch", "kapok", "maple", "oak", "pine", "aged"] }, ],

 

I tried this already and got the items to show up ok in the creative inventory with the proper textures and attributes, however I got the following error with the recipe JSON on server load:
 

Spoiler

19.3.2021 14:44:23 [Error] Grid Recipe 'realisticlogsandfirewood:birch firewood': Output Item code realisticlogsandfirewood:birchfirewood cannot be resolved
19.3.2021 14:44:23 [Error] Grid Recipe 'realisticlogsandfirewood:kapok firewood': Output Item code realisticlogsandfirewood:kapokfirewood cannot be resolved
19.3.2021 14:44:23 [Error] Grid Recipe 'realisticlogsandfirewood:maple firewood': Output Item code realisticlogsandfirewood:maplefirewood cannot be resolved
19.3.2021 14:44:23 [Error] Grid Recipe 'realisticlogsandfirewood:oak firewood': Output Item code realisticlogsandfirewood:oakfirewood cannot be resolved
19.3.2021 14:44:23 [Error] Grid Recipe 'realisticlogsandfirewood:pine firewood': Output Item code realisticlogsandfirewood:pinefirewood cannot be resolved

Why am I getting those errors?

Here is the recipe JSON:

Spoiler

 

[
    {
        ingredientPattern: "A    L",
        ingredients: {
            "A": { type: "item", code: "game:axe-*", isTool: true  },
            "L": { type: "block", code: "game:log-*", allowedVariants: ["placed-acacia-ud"] }
        },
        width: 1,
        height: 2,
        name: "Acacia Firewood",
        output: { type: "item", code: "acaciafirewood", quantity: 3  }
    },

    {
        ingredientPattern: "A    L",
        ingredients: {
            "A": { type: "item", code: "game:axe-*", isTool: true  },
            "L": { type: "block", code: "game:log-*", allowedVariants: ["placed-birch-ud"] }
        },
        width: 1,
        height: 2,
        name: "Birch Firewood",
        output: { type: "item", code: "birchfirewood", quantity: 3  }
    },

    {
        ingredientPattern: "A    L",
        ingredients: {
            "A": { type: "item", code: "game:axe-*", isTool: true  },
            "L": { type: "block", code: "game:log-*", allowedVariants: ["placed-kapok-ud"] }
        },
        width: 1,
        height: 2,
        name: "Kapok Firewood",
        output: { type: "item", code: "kapokfirewood", quantity: 4  }
    },

    {
        ingredientPattern: "A    L",
        ingredients: {
            "A": { type: "item", code: "game:axe-*", isTool: true  },
            "L": { type: "block", code: "game:log-*", allowedVariants: ["placed-maple-ud"] }
        },
        width: 1,
        height: 2,
        name: "Maple Firewood",
        output: { type: "item", code: "maplefirewood", quantity: 4  }
    },

    {
        ingredientPattern: "A    L",
        ingredients: {
            "A": { type: "item", code: "game:axe-*", isTool: true  },
            "L": { type: "block", code: "game:log-*", allowedVariants: ["placed-oak-ud"] }
        },
        width: 1,
        height: 2,
        name: "Oak Firewood",
        output: { type: "item", code: "oakfirewood", quantity: 4  }
    },
    
    {
        ingredientPattern: "A    L",
        ingredients: {
            "A": { type: "item", code: "game:axe-*", isTool: true  },
            "L": { type: "block", code: "game:log-*", allowedVariants: ["placed-pine-ud"] }
        },
        width: 1,
        height: 2,
        name: "Pine Firewood",
        output: { type: "item", code: "pinefirewood", quantity: 4  }
    }
]

 

Is it because I am misunderstanding the output: line to point to the survival mod C# code firewood.cs and not the firewood.json in shapes/block/wood?

Edited by CJHKnight2
Added comment.
Link to comment
Share on other sites

Try something like this:

Spoiler

    {
        ingredientPattern: "A,L",
        ingredients: {
            "A": { type: "item", code: "game:axe-*", isTool: true  },
            "L": { type: "block", code: "game:log-*", allowedVariants: ["acacia", "birch", "kapok", "maple", "oak", "pine", "aged"], name: "type" }
        },
        width: 1,
        height: 2,
        name: "realisticfirewood",
        output: { type: "item", code: "firewood-{type}", quantity: 4  }
    }

By giving your Log ingredient the name "type" and using code: "firewood-{type}" in the output, when someone places an axe above an acacia log, the game will refer to the allowedVariants, see acacia, see that its name is "type", and then make an output of "firewood-acacia". The same applies to the other variants. Does that make sense?

Edited by l33tmaan
Link to comment
Share on other sites

Ok, but how do you get the firewoodpile.json to recognize the new firewood-{type}s? I guess I am not understanding what is being output by the recipe. Would the code for the firewood-acacia for example be in the survival/shapes/item folder with the name firewood-acacia.json? I am thinking to much into this? What I am asking is that do I need to create a new JSON file named firewood-acacia.json in the survival/shapes/item folder. this JSON happens to be the one that textures the firewood logs that you hold in your hand and inventory. I got this to work previously by creating the new firewood-{type}.json files in my mod folder assets/realisticlogsandfirewood/shapes/item folder.

Edited by CJHKnight2
Clarity
Link to comment
Share on other sites

What I posted won't automatically generate shape files on its own or anything, but it doesn't need to. You can still reference the original firewood.json shape. If you open it up, you'll notice something important:

Spoiler

{
    "textures": {
        "0": "block/wood/firewood/front",
        "1": "block/wood/firewood/side"
    },
    "elements": [
        {
            "name": "Cube",
            "from": [ 6.0, 6.0, 0.0 ], 
            "to": [ 10.0, 10.0, 16.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 12.0, 12.0, 16.0, 16.0 ] },
                "east": { "texture": "#1", "uv": [ 0.0, 0.0, 4.0, 16.0 ], "rotation": 90 },
                "south": { "texture": "#0", "uv": [ 8.0, 4.0, 12.0, 8.0 ] },
                "west": { "texture": "#1", "uv": [ 0.0, 0.0, 4.0, 16.0 ], "rotation": 90 },
                "up": { "texture": "#1", "uv": [ 0.0, 0.0, 4.0, 16.0 ] },
                "down": { "texture": "#1", "uv": [ 0.0, 0.0, 4.0, 16.0 ] }
            }
        }
    ]
}

Do you see how in the elements each texture is referred to as 0 or 1?  And up at the top under textures we have an entry for 0 and 1? This entry points to the texture that gets wrapped around firewood to make it look nice. We should be able to change what this path is within the firewood item. Go to itemtypes/resource/firewood.json. You'll want to add something like this in there:

Spoiler

    textures: {
            0: { base: "MODNAME:block/wood/firewood/{type}front"},
            1: { base: "MODNAME:block/wood/firewood/{type}side"}
        }   
    },

Remember from my first post that we defined our variantGroups. You see code: "type"This is similar to the name function from the recipe earlier, by defining the texture path and using {type}, when the game goes to search for the firewood shape's "0" texture, it will check your mod's files, know that firewood has variant groups, and replace {type} with that variant's name. This means you would need to have a file path in your mod that looks like block/wood/firewood/acaciafront, block/wood/firewood/acaciaside, and so on for each of your variants. This way you simply apply your textures to the existing firewood shape and save everyone time and effort.

I hope I got all that right...

Edited by l33tmaan
Link to comment
Share on other sites

Ok, but what if you want to also change other attributes of the firewood such as having a unique combustibleProps burnTemperture and burnDuration in the firewood.json in the itemtypes/resource/ folder? You mentioned adding code to the itemtypes/resource/firewood.json file, but that is not where that code is. It is located in the shapes/item folder as firewood.json. What makes this so confusing to me is the naming convention used where multiple JSONs in different locations are named the same thing, firewood.json in 2 places (shapes/item and itemtypes/resource)  and firewoodpile.json in 2 places (blocktypes/wood/generic and shapes/block/wood).

Edited by CJHKnight2
Link to comment
Share on other sites

That's where the code is. Add it to itemtypes/resource/firewood.json, it will overwrite the texture path detailed in shapes/item/firewood.json. If you want unique properties for each of your types, then utilize the byType function.  For example here's one of my foods:

Spoiler

    combustiblePropsByType: {
        "*-raw": {
            meltingPoint: 150,
            meltingDuration: 30,
            smeltedRatio: 1,
            smeltingType: "cook",
            smeltedStack: { type: "item", code: "hardtack-bake1" },
            requiresContainer: false
        },
        "*-bake1": {
            meltingPoint: 150,
            meltingDuration: 30,
            smeltedRatio: 1,
            smeltingType: "cook",
            smeltedStack: { type: "item", code: "hardtack-bake2" },
            requiresContainer: false
        },
    },

By adding byType to the regular combustibleProps, we can define different values for different variants. In this case, I have 3 variants: raw,  bake1, and bake2. I used the wildcard function * to save some space and avoid typing hardtack-raw or something. It's relatively simple as long as you don't forget a bracket.

Edited by l33tmaan
Link to comment
Share on other sites

Ah ok I think I may get it now. The file firewood.json in itemtypes/resource IS the code file that firewoodpile.json later looks for as line 1 in that JSON literally is code: "firewood",. That code points to the shape item/firewood JSON which is in shapes/item folder and that is where the logs are textured. The JSON firewoodpile.json in blocktypes/wood/generic/ points to the firewoodpile.json in the folder shapes/block/wood which gets its textures from the folder textures/block/wood/firewood.

Link to comment
Share on other sites

So I am getting my new firewood logs to show up in the creative inventory with the proper textures, but the firewood and firewoodpiles are not being replaced with realisticlogsandfirewood:firewood-oak and realisticlogsandfirewood:firewoodpile-oak. Upon appearing in the game I am getting a dialog box that reads:

"The save game was created with an older version of the game, to restore some of the blocks a remapping and world reload is required. This process may take a minute or two. Apply remapping now? Create a backup before applying [checkbox] button [Remind me later] button [No, ignore] button [Ok, apply now]".

It does not seem like the remaps.json I made is working which is in my realisticlogsandfirewood\patches\ folder. Here is the code:

Spoiler

[
  {
    "op": "add",
    "path": "/realisticlogsandfirewood:realisticlogsandfirewood",
    "value": [
      "/iir remapq realisticlogsandfirewood:firewood-oak game:firewood force"
    ],
    "file": "config/remaps.json"
  },
  {
    "op": "add",
    "path": "/realisticlogsandfirewood:realisticlogsandfirewood",
    "value": [
      "/iir remapq realisticlogsandfirewood:firewoodpile-oak game:firewoodpile force"
    ],
    "file": "config/remaps.json"
  }
]



Also, the server-event.txt and server-main.txt log files have the following errors:
20.3.2021 00:29:39 [Error] The texture definition #0 in block with code realisticlogsandfirewood:firewoodpile is invalid. The base property is null. Will skip.
20.3.2021 00:29:39 [Error] The texture definition #1 in block with code realisticlogsandfirewood:firewoodpile is invalid. The base property is null. Will skip.
20.3.2021 00:29:39 [Error] The texture definition #2 in block with code realisticlogsandfirewood:firewoodpile is invalid. The base property is null. Will skip.
20.3.2021 00:29:39 [Error] The texture definition #3 in block with code realisticlogsandfirewood:firewoodpile is invalid. The base property is null. Will skip.
20.3.2021 00:29:39 [Error] The texture definition #4 in block with code realisticlogsandfirewood:firewoodpile is invalid. The base property is null. Will skip.
20.3.2021 00:29:39 [Error] The texture definition #5 in block with code realisticlogsandfirewood:firewoodpile is invalid. The base property is null. Will skip.
20.3.2021 00:29:39 [Error] The texture definition #6 in block with code realisticlogsandfirewood:firewoodpile is invalid. The base property is null. Will skip.

Here is my code for firewoodpile in my MOD folder blocktypes\wood\generic:
 

Spoiler

 

{
    code: "firewoodpile",
    class: "BlockFirewoodPile",
    entityClass: "FirewoodPile",
    shape: {
        base: "game:block/basic/invisible"
    },
    textures: {
        "*-acacia": {
            "front": { base: "realisticlogsandfirewood:block/wood/firewood/acacia/front" },
            "side": { base: "realisticlogsandfirewood:block/wood/firewood/acacia/side" }
        },
        "*-aged": {
            "front": { base: "game:block/wood/firewood/front10" },
            "side": { base: "game:block/wood/firewood/side10" }
        },
        "*-birch": {
            "front": { base: "realisticlogsandfirewood:block/wood/firewood/birch/front" },
            "side": { base: "realisticlogsandfirewood:block/wood/firewood/birch/side" }
        },
        "*-kapok": {
            "front": { base: "realisticlogsandfirewood:block/wood/firewood/kapok/front" },
            "side": { base: "realisticlogsandfirewood:block/wood/firewood/kapok/side" }
        },
        "*-maple": {
            "front": { base: "realisticlogsandfirewood:block/wood/firewood/maple/front" },
            "side": { base: "realisticlogsandfirewood:block/wood/firewood/maple/side" }
        },
        "*-oak": {
            "front": { base: "realisticlogsandfirewood:block/wood/firewood/oak/front" },
            "side": { base: "realisticlogsandfirewood:block/wood/firewood/oak/side" }
        },
        "*-pine": {
            "front": { base: "realisticlogsandfirewood:block/wood/firewood/pine/front" },
            "side": { base: "realisticlogsandfirewood:block/wood/firewood/pine/side" }
        },
    },
    sidesolid: { all: false },
    sideopaque: { all: false },
    blockmaterial: "Wood",
    creativeinventory: { "general": [""] },
    replaceable: 400,
    resistance: 3,
    lightAbsorption: 0,
    materialDensity: 600,
    combustibleProps: {
        burnTemperature: 800,
        burnDuration: 35,
    },
    sounds: {
        "place": "block/planks",
        "hit": "block/planks",
        "break": "block/planks",
        "walk": "walk/wood"
    },

}

 

Also, the recipe JSON is outputting only default firewood and not the rewalisticlogsandfirewood firewood types. Is this due to the C# code for firewood?

Here is the code for the recipe JSON:

Spoiler

 

[
    {
        ingredientPattern: "A    L",
        ingredients: {
            "A": { type: "item", code: "axe-*", isTool: true  },
            "L": { type: "block", code: "log-*", allowedVariants: ["acacia", "birch"], name: "type" }
        },
        width: 1,
        height: 2,
        name: "realisticacaciafirewood",
        output: { type: "item", code: "firewood-{type}", quantity: 3  }
    },

    {
        ingredientPattern: "A    L",
        ingredients: {
            "A": { type: "item", code: "axe-*", isTool: true  },
            "L": { type: "block", code: "log-*", allowedVariants: ["kapok", "maple", "oak", "pine"], name: "type" }
        },
        width: 1,
        height: 2,
        name: "realistickapokfirewood",
        output: { type: "item", code: "firewood-{type}", quantity: 4  }
    }

]

 

 

Edited by CJHKnight2
added recipe JSON code
Link to comment
Share on other sites

On 3/20/2021 at 8:13 AM, CJHKnight2 said:

Also, the recipe JSON is outputting only default firewood and not the rewalisticlogsandfirewood firewood types. Is this due to the C# code for firewood?

 

You need to define domain of blocks or items in recipe. Just add game: before any items/blocks from vanilla VS, and realisticlogsandfirewood: before items/blocks from your mod:

Spoiler

[
    {
        ingredientPattern: "A    L",
        ingredients: {
            "A": { type: "item", code: "game:axe-*", isTool: true  },
            "L": { type: "block", code: "game:log-*", allowedVariants: ["acacia", "birch"], name: "type" }
        },
        width: 1,
        height: 2,
        name: "realisticacaciafirewood",
        output: { type: "item", code: "realisticlogsandfirewood:firewood-{type}", quantity: 3  }
    },

    {
        ingredientPattern: "A    L",
        ingredients: {
            "A": { type: "item", code: "game:axe-*", isTool: true  },
            "L": { type: "block", code: "game:log-*", allowedVariants: ["kapok", "maple", "oak", "pine"], name: "type" }
        },
        width: 1,
        height: 2,
        name: "realistickapokfirewood",
        output: { type: "item", code: "realisticlogsandfirewood:firewood-{type}", quantity: 4  }
    }

]

But, i believe, you need to disable vanilla recipe for firewood first, or change shape in your recipe, to avoid possible conflicts.

Edited by Digitalr
Link to comment
Share on other sites

@Digitalr None of this is working, because.... the C# code is what rules here. I proved it to myself when I changed the name of my itemtype/ firewood.json to something else. All of my firewood in creative inventory now has a white ? texture because the shape is not being rendered anymore. This proves that the suvivalmod firewood.cs file has something to do with not only the log recipe, but the rendering of the shape of the log. So,  I am exploring ways to patch firewood.cs to make it work for me.

Link to comment
Share on other sites

Agreed.  Most of the magic happens in firewoodpile.json, but it's associated classes "BlockFirewoodPile" and "FirewoodPile" are referencing an item that is simply called "firewood" (the item you're talking about).  It would take some elbow grease to rework all of that into the variants you're after - those two classes would need to be tweaked, as well as firewood.json and firewoodpile.json.  Doable for sure, but...

Link to comment
Share on other sites

As far, as i remember, peat piles use same mechanic as firewood. Single item, stacked in pile as block. We use pressed peat bricks, as long burning low temperature fuel on our server. And this mod created without c# coding.

And my answer was about item recipe. It have same grid layout as vanilla recipe (problem #1). And ingredient/result domain not defined (problem #2). 

Link to comment
Share on other sites

You might be right about being able to do it entirely with json Digitalr (or at least close to entirely).  I only quickly looked over every related to firewood.  Peat is an entirely different thing (it's got all of its own classes for some reason), but there's definitely a lot of similar code there. 

I wouldn't know for certain without diving in and trying to do it, and I tend to overthink things.  :)

Edited by Spear and Fang
Link to comment
Share on other sites

Based on original GitHub version

Pure JSON

The only thing, i can't achieve, without C# coding, is retexturing firewood blok pile. Unfortunately, there is no direct shape definition for firewood pile block. So, it have vanilla texture.

But block name (in hint) are from mod. And modded firewoods can be placed or taken from pile.

rfw.zip

Edited by Digitalr
  • Like 1
  • Amazing! 1
Link to comment
Share on other sites

I would definitely recommend rotating the outside bark texture, that looks... wrong.
Now that I think about it, you might not want to show any exterior bark at all, only the inside. You're definitely not going to see that white birch bark on all 4 sides of your firewood, that's for sure.

Edited by l33tmaan
  • Like 1
Link to comment
Share on other sites

On 3/26/2021 at 9:24 AM, l33tmaan said:

I would definitely recommend rotating the outside bark texture, that looks... wrong.
Now that I think about it, you might not want to show any exterior bark at all, only the inside. You're definitely not going to see that white birch bark on all 4 sides of your firewood, that's for sure.

How would I rotate the texture?

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.