Modding:Item Json Properties: Difference between revisions

From Vintage Story Wiki
No edit summary
No edit summary
Line 173: Line 173:
"*-south-*-closed-right": 180
"*-south-*-closed-right": 180
}
}
},
</syntaxhighlight>
Since Vintagestory v1.8 it is also possible to use the variantgroup as a placeholder:
<syntaxhighlight lang="json">
variantgroups: [
{ code: "metal", states: ["copper", "tinbronze", "bismuthbronze", "blackbronze", "gold", "silver", "iron" ] },
],
textures: {
"metal": { base: "block/metal/ingot/{metal}" },
"wood": { base: "item/tool/material/wood" }
},
},
</syntaxhighlight>
</syntaxhighlight>

Revision as of 11:26, 25 October 2018

Overview

A complete list of all available properties

Property Type Default Usage
json
Core (no byType available)
Code
string required A unique identifier for the item.

A domain prefix will be added dynamically depending on the location of the file. Every mod and VintageStory itself have a unique prefix.

For example the code stone turns into game:stone.

The code identifier has to be unique inside its domain. In theory there could be equal identifiers with different domain prefixes. Find out more about Domains.

Enabled
boolean true If the item will be loaded or not. Can be used to temporarily remove the item.
VariantGroups
array of object - Allows you define multiple variants of the same item.

The variantgroups property allows you to define multiple variants of this item. All of them will have their unique pattern, which will be added to the item code.

An easy example would be a bowl, which can either be raw or burned:

	variantgroups: [
		{ code:"type", states: ["raw", "burned"] },
	],

Meaning there will be two variants bowl-raw and bowl-burned.


It's also possible to define multiple groups.

	variantgroups: [
		{ code:"state", states: ["closed", "opened"] },
		{ code:"contents", states: ["empty", "cabbage"] },
	],

As a result you will have 2x2 groups, which will be added one after each other: barrel-closed-empty, barrel-closed-cabbage, barrel-opened-empty and barrel-opened-cabbage.


Additionally it is possible to refer to external lists (used for blocks) that are found in the worldproperties folder, such as block/rock, which contains all states of all rock types. This used for gravel, sand and rock. It's a good way to keep everything organized:

	variantgroups: [
		{ loadFromProperties: "block/rock" },
	],

Here is a full list of all groups and their variants (you can also find them in the assets/worldproperties folder): The world properties are stored in the assets/survival/worldproperties folder. They are used to help fill in the variantgroups field. Instead of directly specifying every state in the variant group, the states can be loaded from a world property through the loadFromProperties key. The states from multiple world properties can be added with the loadFromPropertiesCombine key, which takes an array of strings. The states key can still be optionally added to the variant group to specify additional states.

For example, the following creates a variant group named orientation. It contains 5 states. north, east, south, and west are loaded from the abstract/horizontalorientation world property. up is added to the list of states.

	variantgroups: [
		{ code: "orientation", states: ["up"], loadFromProperties: "abstract/horizontalorientation" }
	],

Unwanted variant states can be filtered out with the skipVariants property. Or all states that do not match an expression can be filtered out with the allowedVariants property.

Name States
abstract/alloy -
abstract/coating n, e, s, w, u, d, ud, ns, ew, nd, ed, sd, wd, su, wu, nu, eu, es, sw, nw, ne, nwd, ned, esd, swd, nwu, neu, esu, swu, nsd, ewd, sud, wud, nud, eud, nsu, ewu, nes, esw, nsw, new, newd, nesd, eswd, nswd, eswu, nswu, newu, nesu, nesw, ewud, nsud, neud, esud, swud, nwud, neswd, neswu, newud, nesud, eswud, nswud, neswud
abstract/fertility verylow, low, medium, compost, high
abstract/grasscoverage none, verysparse, sparse, normal
abstract/horizontalorientation north, east, south, west
abstract/rockgroup -
abstract/verticalorientation up, down
block/flower catmint, cornflower, forgetmenot, edelweiss, heather, horsetail, orangemallow, wilddaisy, westerngorse, cowparsley, goldenpoppy, lilyofthevalley, woad, redtopgrass
block/fruit blueberry, cranberry, redcurrant, whitecurrant, blackcurrant, saguaro, pineapple, redapple, pinkapple, yellowapple, cherry, peach, pear, orange, mango, breadfruit, lychee, pomegranate
block/grass -
block/herb basil, chamomile, cilantro, lavender, marjoram, mint, saffron, sage, thyme
block/metal bismuth, bismuthbronze, blackbronze, brass, chromium, copper, cupronickel, electrum, gold, iron, meteoriciron, lead, molybdochalkos, platinum, nickel, silver, stainlesssteel, steel, tin, tinbronze, titanium, uranium, zinc
block/mushroom flyagaric, fieldmushroom, almondmushroom, bitterbolete, blacktrumpet, chanterelle, commonmorel, deathcap, devilstooth, devilbolete, earthball, elfinsaddle, golddropmilkcap, greencrackedrussula, indigomilkcap, jackolantern, kingbolete, lobster, orangeoakbolete, paddystraw, puffball, redwinecap, saffronmilkcap, violetwebcap, witchhat, beardedtooth, chickenofthewoods, dryadsaddle, pinkoyster, tinderhoof, whiteoyster, reishi, funeralbell, deerear, livermushroom, pinkbonnet, shiitake
block/ore-gem-cut diamond, emerald, peridot
block/ore-gem-rough diamond,emerald,olivine_peridot
block/ore-graded nativecopper,limonite,quartz_nativegold,galena,cassiterite,chromite,ilmenite,sphalerite,quartz_nativesilver,galena_nativesilver,bismuthinite,magnetite,hematite,malachite,pentlandite,uranium,wolframite,rhodochrosite
block/ore-nugget nativecopper,limonite,nativegold,galena,cassiterite,chromite,ilmenite,sphalerite,nativesilver,bismuthinite,magnetite,hematite,malachite,pentlandite,uranium,wolframite,rhodochrosite
block/ore-ungraded alum,lapislazuli,corundum,anthracite,borax,cinnabar,lignite,bituminouscoal,sylvite,quartz,olivine,sulfur,fluorite,graphite,kernite,phosphorite
block/painting howl,elk,underwater,prey,forestdawn,fishandtherain,bogfort,castleruin,cow,hunterintheforest,seraph,sleepingwolf,sunkenruin,traveler,oldvillage,lastday,sodhouse
block/rock andesite,chalk,chert,conglomerate,limestone,claystone,granite,sandstone,shale,basalt,peridotite,phyllite,slate,bauxite
block/rockwithdeposit andesite,chalk,chert,conglomerate,limestone,claystone,granite,sandstone,shale,basalt,peridotite,phyllite,slate,obsidian,kimberlite,scoria,tuff,bauxite,halite,suevite,whitemarble,redmarble,greenmarble
block/tallgrass veryshort,short,mediumshort,medium,tall,verytall,eaten
block/toolmetal bismuth,bismuthbronze,blackbronze,brass,copper,gold,iron,meteoriciron,lead,molybdochalkos,silver,steel,tinbronze
block/wood birch,oak,maple,pine,acacia,kapok,baldcypress,larch,redwood,ebony,walnut,purpleheart
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.



Futhermore there are two ways of combining groups together. So far we covered the default combination mode, which is multiplicative (the total count of variants is the product of all states).

Let's take a look at a different example (flowerpot), which uses the additive combination mode:

	variantgroups: [
		{ code: "type", states: ["raw"] },
		{ code: "empty", states: ["empty"], combine: "additive" },
		{ code: "flower", loadFromProperties: "block/flower", combine: "additive" },
		{ code: "mushroom", loadFromProperties: "block/mushroom", combine: "additive" },
		{ code: "sapling", loadFromProperties: "block/wood", combine: "additive" },
	],

The variants are flowerpot-raw, flowerpot-empty, flowerpot-{all flowers}, flowerpot-{all mushrooms} and flowerpot-{all saplings}.

Additive mode could also be called separate, since it defines a variant separate from all the other groups:

	variantgroups: [
		{ code: "something", states: ["same", "different"] },
		{ code: "type", states: ["raw", "baked"] },
		{ code: "empty", states: ["red", "green"], "combine": "additive" },
	],

In this case, the result would be same-raw, same-baked, different-raw, different-baked, red and green

(any) byType
key: string; value: object - You can create properties for certain variants of the item.

In order to define properties for specific variants you can add byType to the property name. This allows you to define it depending on the type and always follows the same syntax:

	(property)ByType: {
		"selector": property,
		"selector2": property2,
		...
	}

If the selector matches the name of the variant the given property will be used. Keep in mind that only the first matching one will be used (everything below will be ignored).

A slab for example has two variants (up, down), which have different collision boxes:

	collisionboxByType: {
		"*-down": { x1: 0, y1: 0, z1: 0,   x2: 1, y2: 0.5, z2: 1 },
		"*-up": { x1: 0, y1: 0.5, z1: 0,   x2: 1, y2: 1, z2: 1 }
	},

The char * stands for anything. In this case it ignores the code of the item.

Furthermore this opens up even more possbilities for more advanced selectors like this one for doors: *-north-*-opened-left. This will ignore the second variantgroup. Additionally ByType can also be used for child properties:

	collisionboxnbox: { 
		x1: 0, y1: 0, z1: 0.875, x2: 1, y2: 1, z2: 1,
		rotateYByType: {
			"*-north-*-opened-left": 90,
			"*-north-*-closed-left": 0,
			"*-west-*-opened-left": 180,
			"*-west-*-closed-left": 90,

			"*-east-*-opened-left": 0,
			"*-east-*-closed-left": 270,
			"*-south-*-opened-left": 270,
			"*-south-*-closed-left": 180,

			"*-north-*-opened-right": 270,
			"*-north-*-closed-right": 0,
			"*-west-*-opened-right": 0,
			"*-west-*-closed-right": 90,

			"*-east-*-opened-right": 180,
			"*-east-*-closed-right": 270,
			"*-south-*-opened-right": 90,
			"*-south-*-closed-right": 180
		}
	},

Since Vintagestory v1.8 it is also possible to use the variantgroup as a placeholder:

	variantgroups: [
		{ code: "metal", states: ["copper", "tinbronze", "bismuthbronze", "blackbronze", "gold", "silver", "iron" ] },
	],
	textures: {
		"metal": { base: "block/metal/ingot/{metal}" },
		"wood": { base: "item/tool/material/wood" } 
	},
Specific
Class
string "item" The item class can add special functionalities for the item.

It can be used to open guis or adding other extra functionality to the item. A complete tutorial of how to add your own class to the game can be found here.

Durability
integer 0 How many uses does this item has when being used. Item disappears at durability 0.
DamagedBy
array of string - From which damage sources does the item takes durability damage.
BlockBreaking
0 Mining a block.
Attacking
1 Hitting an entity.
Fire
2 Currently not used.
Tool
string - If set, this item will be classified as given tool.
Knife
0 USed to break grass.
Pickaxe
1 Can mine rock and other stone materials
Axe
2 Useful for chopping trees.
Sword
3 No special abilities yet.
Shovel
4 Mines dirt, sand and gravel really fast.
Hammer
5 No special abilities yet.
Mallet
6 No special abilities yet.
Spear
7 No special abilities yet.
Bow
8 No special abilities yet.
Sickle
9 No special abilities yet.
Hoe
10 No special abilities yet.
Saw
11 No special abilities yet.
Common
CreativeInventory
key: string, value: string[] - In which creative inventory tabs the item should be visible in.

There are several tabs to you can add your stuff. Note that general should always be included, since it should contain everything.

  • general
  • terrain
  • flora
  • construction
  • decorative
  • items

Rock adds all of it's variantions to general, terrain and construction:

	creativeinventory: { "general": ["*"], "terrain": ["*"], "construction": ["*"] },

* reprents the variants which will be added. You can specify multiple and separate them with a comma. It follows the same way as the byType property.

A Torch on the other hand only adds the variation up:

	creativeinventory: { "general": ["*-up"], "decorative": ["*-up"] },
MaxStackSize
integer 64 Determines the maximum amount you can stack the item in one slot.
AttackPower
decimal number 0.5 The damage the deals when hitting an entity.
AttackRange
decimal number 1.5 The maximum distance you can hit an entity.
MaterialDensity
integer 9999 Determines on whether an object floats on liquids or not.

Water has a density of 1000, meaning everything below or equal will float on water. The same goes for lava which has a density of 5000.

LiquidSelectable
boolean false If the item can select a liquid while holding it in hand.

Used for buckets in order to fill it with water and to place waterlily on top of water.

MiningSpeed
key: string, value: decimal number - The mining speed for each material.
MiningTier
integer 0 Determines which blocks it can break. If the required miningtier is above the defined one there will be no drop from it.
Attributes
key: string, value: object - Custom Attributes that's always assiociated with this item.

Extra attributes added to a item or block. Those are final and cannot be modified. It's a good way to keep things oragnized and and modifiable. The oreblastingbomb for example has attributes, which define its radius and type. These can be used by behaviors and blockentities:

    attributes: {
		"blastRadius": 4,
		"blastType": 0,
	},
CombustibleProps
object - Information about the items burnable states.
BurnTemperature
integer - The temperature at which it burns in degrees celsius.
BurnDuration
decimal number - For how long it burns in seconds.
HeatResistance
integer 500 How many degrees celsius it can resists before it ignites (not implemented yet).
MeltingPoint
integer - How many degrees celsius it takes to smelt/transform this into another. Only used when put in a stove and Melted is set.
MeltingDuration
decimal number - For how many seconds the temperature has to be above the melting point until the item is smelted.
SmokeLevel
decimal number 1 How much smoke this item produces when being used as fuel.
SmeltedRatio
integer 1 How many ores are required to produce one output stack.
SmeltedStack
object - If set, the block/item is smeltable in a furnace and this is the resulting itemstack once the MeltingPoint has been reached for the supplied duration.
RequiresContainer
boolean true If set to true, the block/item requires a smelting/cooking/baking container such as the Crucible. If false, it can be directly baked/melted without smelting/cooking/baking container.

This property can be used to define a burning material. Plank for example can get on fire:

    combustibleProps: {
        burnTemperature: 800,
        burnDuration: 12,
    },

Futhermore it can be used to define smelting processes. An example would be an ingotmold which turns into an ingotmold-burned:

    combustiblePropsByType: {
        "ingotmold-raw": {
            meltingPoint: 600,
            meltingDuration: 30,
            smeltedRatio: 1,
            smeltedStack: { type: "block", code: "ingotmold-burned" },
            requiresContainer: false
        }
    },
NutritionProps
object - Information about the items nutrients.
FoodCategory
string - Defines the type of food. It can be fruit, vegetable, protein, grain and dairy.
Saturation
decimal number 0 How much saturation it can restore.
Health
decimal number 0 How much health it can restore.
Rendering
Textures
string required The texture definitions for the item held in hand or dropped on the ground.
Shape
object - The items shape. Empty for automatic shape based on the texture.
GuiTransform
object item default Used for scaling, rotation or offseting the item when rendered in guis.
FpHandTransform
object item default Used for scaling, rotation or offseting the item when rendered in the first person mode hand.
TpHandTransform
object item default Used for scaling, rotation or offseting the item when rendered in the third person mode hand.
GroundTransform
object item default Used for scaling, rotation or offseting the rendered as a dropped item on the ground.


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.