Modding:Asset System: Difference between revisions

From Vintage Story Wiki
m (Tyron moved page Getting Started to Getting Started with Advanced Modding without leaving a redirect)
m (Updated navbox to new content navbox.)
 
(46 intermediate revisions by 14 users not shown)
Line 1: Line 1:
<languages/>
<translate>
<!--T:1-->
{{GameVersion|1.19}}
__FORCETOC__
__FORCETOC__


= Asset System =
<!--T:2-->
Vintage Story loads most of its game content from asset JSONs. Many examples of these can be found inside the <code>assets</code> directory inside your [[Vintagestory folder]]. Things such as blocks, items, world generation, recipes, etc. are all loaded from assets during startup.


Vintage Story loads most of its game content from so called assets. Those can be found inside the <code>assets</code> directory inside your [[Vintagestory folder]]. Things such as blocks, items, world generation, recipes, etc. are all loaded from assets during startup.
== Finding the assets folder == <!--T:3-->


These assets are easily modifiable and using the integrated mod system you can easily add your own stuff without having to mess with coding.
<!--T:4-->
All the functioning assets for Vintage Story are visible in the game's folder, allowing you to peruse them and learn to write your own. You can find these files using the following methods for each type of OS you're running Vintage Story on. If you're looking for source code (ie C# classes) your best option is to dive into the '''[https://github.com/anegostudios Vintage Story Github]''' and peruse the '''vsapi''', '''vssurvivalmod''', '''vsessentialsmod''' and '''vscreativemod''' repositories for class references.  


== Categories ==
=== Windows === <!--T:5-->
If you're running Vintage Story on Windows, and installed the game to the default location, you can navigate to this folder by typing %appdata% in desktop search bar, which will take you to your computer's roaming folder. Find the <code>Vintagestory</code> folder here and you'll immediately come across the assets folder, which contains assets for "creative", "game" and "survival".
* '''creative''' contains assets for creative mode only. 
* '''game''' contains many universal assets, such as lang files, the player entity shape, and other essential assets to the game.
* '''survival''' contains the bulk of the actual content most players will come across, and contains all the resources Vintage Story uses, such as textures sounds and world generation.


Here is an overview of categories:
== List of Asset Types == <!--T:6-->
 
<!--T:7-->
The following are the categories of assets you can expect to use while modding for Vintage Story. Each are easily modifiable and can be used to easily add your own content or changes without having to do any advanced coding. You can also read some [[Modding:Basic Modding Examples|examples]] to learn about what you can do with it.
 
<!--T:8-->
<table id="treeviewtable" class="table table-bordered tt-table" style='table-layout: fixed'>
<table id="treeviewtable" class="table table-bordered tt-table" style='table-layout: fixed'>
   <tr style='background-color: gray;'>
   <tr style=''>
     <th width='300' align='left'>Name</th>
     <th width='300' align='left'>Name</th>
     <th width='200' align='left'>Affects Gameplay</th>
     <th width='200' align='left'>Affects Gameplay</th>
Line 27: Line 42:
     <td>true</td>
     <td>true</td>
     <td>universal</td>
     <td>universal</td>
     <td>Blocks</td>
     <td>Defines all the blocks that are in the game</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_config" data-tt-parent="root">config</div></td>
    <td>true</td>
    <td>universal</td>
    <td>Used for generic data that does not fit into the other categories.</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_dialog" data-tt-parent="root">dialog</div></td>
    <td>false</td>
    <td>client only</td>
    <td>Contains some of the dialog layouts</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_entity" data-tt-parent="root">entities</div></td>
    <td>true</td>
    <td>server only</td>
    <td>Creatures and other entities</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 33: Line 66:
     <td>true</td>
     <td>true</td>
     <td>universal</td>
     <td>universal</td>
     <td>Items</td>
     <td>Defines all the items that are in the game</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 40: Line 73:
     <td>universal</td>
     <td>universal</td>
     <td>Translation</td>
     <td>Translation</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_music" data-tt-parent="root">music</div></td>
    <td>false</td>
    <td>client only</td>
    <td>The games music tracks and its configuration</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_patches" data-tt-parent="root">patches</div></td>
    <td>true</td>
    <td>universal</td>
    <td>Used to patch game data defined in other json files</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 45: Line 90:
     <td>true</td>
     <td>true</td>
     <td>universal</td>
     <td>universal</td>
     <td></td>
     <td>Contains some commonly used lists of properties</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 69: Line 114:
     <td>false</td>
     <td>false</td>
     <td>universal</td>
     <td>universal</td>
     <td>Blocks</td>
     <td>Contains the 3d models for all the items, blocks and creatures</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 93: Line 138:
     <td>true</td>
     <td>true</td>
     <td>server only</td>
     <td>server only</td>
     <td>Recipes for all kinds of machinery</td>
     <td>The crafting, knapping, smithing and clay forming recipes</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 99: Line 144:
     <td>true</td>
     <td>true</td>
     <td>server only</td>
     <td>server only</td>
     <td></td>
     <td>How metals can be combined to create alloys</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 105: Line 150:
     <td>true</td>
     <td>true</td>
     <td>server only</td>
     <td>server only</td>
     <td>Recipes for Workbench</td>
     <td>Recipes for 3x3 grid crafting</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 111: Line 156:
     <td>true</td>
     <td>true</td>
     <td>server only</td>
     <td>server only</td>
     <td></td>
     <td>Recipes for smithing on the anvil</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 117: Line 162:
     <td>true</td>
     <td>true</td>
     <td>server only</td>
     <td>server only</td>
     <td></td>
     <td>Contains all the configuration for world generation</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 123: Line 168:
     <td>true</td>
     <td>true</td>
     <td>server only</td>
     <td>server only</td>
     <td></td>
     <td>Defines how the terrain should look and with what it should be decorated with</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 129: Line 174:
     <td>true</td>
     <td>true</td>
     <td>server only</td>
     <td>server only</td>
     <td></td>
     <td>Defines the shapes of trees</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_entities" data-tt-parent="root">entities</div></td>
    <td>true</td>
    <td>server only</td>
    <td>Entities</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 141: Line 180:
     <td>false</td>
     <td>false</td>
     <td>client only</td>
     <td>client only</td>
     <td></td>
     <td>Contains GLSL source code, that defines how the game is rendered</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 147: Line 186:
     <td>false</td>
     <td>false</td>
     <td>client only</td>
     <td>client only</td>
     <td></td>
     <td>Contains GLSL source code, that defines how the game is rendered</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 153: Line 192:
     <td>false</td>
     <td>false</td>
     <td>client only</td>
     <td>client only</td>
     <td></td>
     <td>Contains all the graphics of the game</td>
   </tr>
   </tr>
   <tr>
   <tr>
     <td scope="row"><div class="tt" data-tt-id="p_textures_blocks" data-tt-parent="p_textures">blocks</div></td>
     <td scope="row"><div class="tt" data-tt-id="p_textures_blocks" data-tt-parent="p_textures">block</div></td>
     <td>false</td>
     <td>false</td>
     <td>client only</td>
     <td>client only</td>
Line 162: Line 201:
   </tr>
   </tr>
   <tr>
   <tr>
     <td scope="row"><div class="tt" data-tt-id="p_textures_item" data-tt-parent="p_textures">decal</div></td>
     <td scope="row"><div class="tt" data-tt-id="p_textures_items" data-tt-parent="p_textures">item</div></td>
     <td>false</td>
     <td>false</td>
     <td>client only</td>
     <td>client only</td>
     <td>Item textures</td>
     <td>Item textures</td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_textures_decal" data-tt-parent="p_textures">decal</div></td>
    <td>false</td>
    <td>client only</td>
    <td>Decaltextures</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 197: Line 242:
     <td>Particle textures</td>
     <td>Particle textures</td>
   </tr>
   </tr>
  <tr>
 
    <td scope="row"><div class="tt" data-tt-id="p_music" data-tt-parent="root">music</div></td>
<!--T:9-->
    <td>false</td>
    <td>client only</td>
    <td></td>
  </tr>
  <tr>
    <td scope="row"><div class="tt" data-tt-id="p_dialog" data-tt-parent="root">dialog</div></td>
    <td>false</td>
    <td>client only</td>
    <td></td>
  </tr>
</table>
</table>


= Domains =
= Domains = <!--T:10-->


Domains are used to separate mod added content from the original one. Basically a domain is a prefix for any given code (identifier for item, block, etc.) or path (textures, sounds, etc.). VintageStory itself has its own prefix <code>game</code>.
<!--T:11-->
Domains are used to separate mod added content from the original one. Basically a domain is a prefix for any given code (identifier for item, block, etc.) or path (textures, sounds, etc.). VintageStory itself has its own prefix <code>game</code> for all its assets (game, survival and creative folders).


So if you want to create a new block, which uses the original leather texture, you would have to specify the domain (since your block has a different one). So instead of using  <code>assets/textures/blocks/leather.png</code>, you would have add the prefix for the domain <code>game:assets/textures/blocks/leather.png</code>.
<!--T:12-->
When [[Mod Packaging|packaging a mod]] you specify a domain by placing a directory inside the mod <code>assets</code> directory with all your mod assets inside. The name of your domain directory will be the "current domain" for all assets inside it. If no domain has been specified in an asset code the game will assume it is in the current domain, meaning you only have to add a domain prefix if you want to refer to something outside the current domain.


If no domain has been specified it will refer to the current domain. Meaning you only have to add a domain prefix if you want to refer to something outside the current domain.
<!--T:13-->
For example, if you want to create a new block which uses the original leather texture, you would have to specify the domain (since your block has a different one). Instead of using  <code>block/leather</code> for <code>assets/survival/textures/block/leather.png</code>, you would have add the prefix for the domain <code>game:block/leather</code>.


= Mods =
== Overwriting assets == <!--T:14-->


A mod (most likely a zip file) can be installed by copying the file in your Mods directory inside your [[Vintagestory folder]].
<!--T:15-->
There are no limitations to the system. So you can overwrite assets from Vintagestory itself by using the <code>game</code> domain folder.


== Creating your own domain ==
<!--T:16-->
To overwrite the bed blocktype you can put your own json file inside your mod zip archive with the following path: <code>assets/game/blocktypes/wood/bed.json</code>. So Vintagestory will load your json file instead of the original one.


In order to make the game load your own assets, you have to create a zip file, which has to have a similar structure as the assets folder of Vintagestory. The only difference is the domain folder, which is located below the assets directory and allows you to either create a new domain or refer to existing ones.
<!--T:17-->
If you want to create a new block for example you can use your own domain <code>assets/mymoddomain/blocktypes/myblock.json</code>. In this case the folder <code>mymoddomain</code> specifies the domain and therefore the code of the added block will be <code>mymoddomain:myblock</code>.
Theme packs can only override assets that do not affect game mechanics, the other mod types can override any asset.
 
== Overwriting assets ==
 
There are no limitations to the system. So you can overwrite assets from Vintagestory itself by using the <code>game</code> domain folder.


To overwrite the bed blocktype you can put your own json flie inside your mod zip archive with the following path: <code>assets/game/blocktypes/bed.json</code>. So Vintagestory will load your json file instead of the original one.
== Accessing assets in code == <!--T:18-->  


= Resourcepacks =
<!--T:19-->
To access assets in a code mod, you can use the [[Modding:AssetManager| AssetManager]].


You can install a resourcepack by copying the file iton the Resourcepacks directory inside your [[Vintagestory folder]].
= Moving Forward = <!--T:20-->


== Overwriting assets ==
<!--T:21-->
Once you have an idea of what assets are and how they're organized, it's time to move onto your first content mod. Head over to the '''[[Modding:Basic Block | Basic Block ]]''' page to learn how to make your first block, or go to the '''[[Modding:Basic Item |Basic Item]]''' page if you'd like to start by making an item. Both are great ways to learn how to make your first mod.


Resourcepacks have the same structure as mods. They can overwrite assets of any domain. However the cannot use categories which affect gameplay. Meaning a resourcepack can overwrite textures, but not blocktypes for example.
<!--T:22-->
{{Navbox/contentmodding}}
</translate>

Latest revision as of 14:11, 27 March 2024

Other languages:

This page was last verified for Vintage Story version 1.19.


Vintage Story loads most of its game content from asset JSONs. Many examples of these can be found inside the assets directory inside your Vintagestory folder. Things such as blocks, items, world generation, recipes, etc. are all loaded from assets during startup.

Finding the assets folder

All the functioning assets for Vintage Story are visible in the game's folder, allowing you to peruse them and learn to write your own. You can find these files using the following methods for each type of OS you're running Vintage Story on. If you're looking for source code (ie C# classes) your best option is to dive into the Vintage Story Github and peruse the vsapi, vssurvivalmod, vsessentialsmod and vscreativemod repositories for class references.

Windows

If you're running Vintage Story on Windows, and installed the game to the default location, you can navigate to this folder by typing %appdata% in desktop search bar, which will take you to your computer's roaming folder. Find the Vintagestory folder here and you'll immediately come across the assets folder, which contains assets for "creative", "game" and "survival".

  • creative contains assets for creative mode only.
  • game contains many universal assets, such as lang files, the player entity shape, and other essential assets to the game.
  • survival contains the bulk of the actual content most players will come across, and contains all the resources Vintage Story uses, such as textures sounds and world generation.

List of Asset Types

The following are the categories of assets you can expect to use while modding for Vintage Story. Each are easily modifiable and can be used to easily add your own content or changes without having to do any advanced coding. You can also read some examples to learn about what you can do with it.

Name Affects Gameplay Side Type Usage
AssetCategory
blocktypes
true universal Defines all the blocks that are in the game
config
true universal Used for generic data that does not fit into the other categories.
dialog
false client only Contains some of the dialog layouts
entities
true server only Creatures and other entities
itemtypes
true universal Defines all the items that are in the game
lang
false universal Translation
music
false client only The games music tracks and its configuration
patches
true universal Used to patch game data defined in other json files
worldproperties
true universal Contains some commonly used lists of properties
abstract
true universal
block
true universal
sounds
false universal Sounds
shapes
false universal Contains the 3d models for all the items, blocks and creatures
block
false universal Shapes for blocks
entity
false universal Shapes for entities
item
false universal Shapes for items
recipes
true server only The crafting, knapping, smithing and clay forming recipes
alloy
true server only How metals can be combined to create alloys
grid
true server only Recipes for 3x3 grid crafting
smithing
true server only Recipes for smithing on the anvil
worldgen
true server only Contains all the configuration for world generation
terrain
true server only Defines how the terrain should look and with what it should be decorated with
tree
true server only Defines the shapes of trees
shaders
false client only Contains GLSL source code, that defines how the game is rendered
shaderincludes
false client only Contains GLSL source code, that defines how the game is rendered
textures
false client only Contains all the graphics of the game
block
false client only Block textures
item
false client only Item textures
decal
false client only Decaltextures
entities
false client only Entities textures
environment
false client only Environment textures (Sky, Moon, Sun, etc.)
gui
false client only Gui textures
hud
false client only Hud textures
particle
false client only Particle textures

Domains

Domains are used to separate mod added content from the original one. Basically a domain is a prefix for any given code (identifier for item, block, etc.) or path (textures, sounds, etc.). VintageStory itself has its own prefix game for all its assets (game, survival and creative folders).

When packaging a mod you specify a domain by placing a directory inside the mod assets directory with all your mod assets inside. The name of your domain directory will be the "current domain" for all assets inside it. If no domain has been specified in an asset code the game will assume it is in the current domain, meaning you only have to add a domain prefix if you want to refer to something outside the current domain.

For example, if you want to create a new block which uses the original leather texture, you would have to specify the domain (since your block has a different one). Instead of using block/leather for assets/survival/textures/block/leather.png, you would have add the prefix for the domain game:block/leather.

Overwriting assets

There are no limitations to the system. So you can overwrite assets from Vintagestory itself by using the game domain folder.

To overwrite the bed blocktype you can put your own json file inside your mod zip archive with the following path: assets/game/blocktypes/wood/bed.json. So Vintagestory will load your json file instead of the original one.

Theme packs can only override assets that do not affect game mechanics, the other mod types can override any asset.

Accessing assets in code

To access assets in a code mod, you can use the AssetManager.

Moving Forward

Once you have an idea of what assets are and how they're organized, it's time to move onto your first content mod. Head over to the Basic Block page to learn how to make your first block, or go to the Basic Item page if you'd like to start by making an item. Both are great ways to learn how to make your first mod.


Content Modding
Basics Content Mods Developing a Content Mod Packaging & Release
Tutorials
Concepts Modding Concepts Modinfo Variants Domains Patching Remapping World Properties
Moddable Assets
Uncategorized
Icon Sign.png

Wondering where some links have gone?
The modding navbox is going through some changes! Check out Navigation Box Updates for more info and help finding specific pages.

Modding
Modding Introduction Getting Started Theme Pack
Content Modding Content Mods Developing a Content Mod Basic Tutorials Intermediate Tutorials Advanced Tutorials Content Mod Concepts
Code Modding Code Mods Setting up your Development Environment
Property Overview ItemEntityEntity BehaviorsBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsCollectible BehaviorsWorld properties
Workflows & Infrastructure Modding Efficiency TipsMod-engine compatibilityMod ExtensibilityVS Engine
Additional Resources Community Resources Modding API Updates Programming Languages List of server commandsList of client commandsClient startup parametersServer startup parameters
Example ModsAPI DocsGitHub Repository