Confirmedusers, editor, Administrators
886
edits
CreativeMD (talk | contribs) |
CreativeMD (talk | contribs) No edit summary |
||
Line 53: | Line 53: | ||
== Mining Properties == | == Mining Properties == | ||
Our wand is still rather useless, so it might be a good idea to add our wand some mining functionality. How it works? We the property "miningspeedbytype" we can define the mining speed for each material. Here is a list of all [[Block Materials|block materials]]. | |||
A pickaxe looks like this: | |||
<syntaxhighlight lang="json"> | |||
miningspeedbytype: { | |||
"*": { | |||
"stone": 7, | |||
"metal": 7 | |||
}, | |||
}, | |||
</syntaxhighlight> | |||
Although the tool is working already, we should add some kind of durability. Therefore we need to define what can damage our tool and the durability itself. | |||
Our tool can be damaged by breaking a block, or using it for an weapon. The property <code>damagedby</code> allows us to define all possible damage source. For now we will stick to <code>blockbreaking</code> and <code>attacking</code>. | |||
<syntaxhighlight json="lang"> | |||
damagedby: ["blockbreaking", "attacking"], | |||
</syntaxhighlight> | |||
and the durability should be 2000: | |||
<syntaxhighlight json="lang"> | |||
durabilitybytype: { | |||
"*": 2000, | |||
}, | |||
</syntaxhighlight> | |||
== Variants == | == Variants == | ||
Pretty basic so far, let's go more advanced. Let's add some variants to our wand, each of them should represent another tool (shovel, pickaxe, axe). | |||
So first of all we have to add a new variantgroup. The name of your group is <code>tooltype</code> and possible values are <code>"shovel"</code>, <code>"pickaxe"</code>, <code>"axe"</code>: | |||
<syntaxhighlight lang="json"> | |||
variantgroups: [ | |||
{ code: "tooltype", states: ["shovel", "pickaxe", "axe" ] }, | |||
], | |||
</syntaxhighlight> | |||
Now we need to change our <code>miningspeedbytype</code> property to set the speed of each material for each type: | |||
<syntaxhighlight lang="json"> | |||
miningspeedbytype: { | |||
"*-shovel": { | |||
"soil": 7, | |||
"sand": 7, | |||
"gravel": 4.4 | |||
},"*-pickaxe": { | |||
"stone": 7, | |||
"metal": 7 | |||
},"*-axe": { | |||
"wood": 6, | |||
"leaves": 4 | |||
}, | |||
}, | |||
</syntaxhighlight> | |||
Every group will be added after each other to the item name <code>item-myitemname-mygroup-mysecondgroup</code>. In total, our wand has 3 types and their full names are: | |||
*item-wand-shovel | |||
*item-wand-pickaxe | |||
*item-wand-axe | |||
Each of our selectors starts with a <code>*</code> which is a custom symbol and means it can be anything. Through that way you can select specific variants of your item. | |||
If we would add another variant called <code>material</code> (values are <code>magic</code>, <code>air</code>, <code>death</code>) and wanted to select all shovels we would have to do it like that: <code>*-shovel-*</code>. Meaning it can be anything before, but it has to be a shovel and it can be any type of a shovel. | |||
We can also change the durability for each type individually. | |||
<syntaxhighlight json="lang"> | |||
durabilitybytype: { | |||
"*-shovel": 4000, | |||
"*-pickaxe": 3000, | |||
"*-axe": 2000, | |||
}, | |||
</syntaxhighlight> | |||
== Variant Textures == | |||
Using the same way we specified the mining speed for each type we can also specify a texture for each type. | |||
<syntaxhighlight json="lang"> | |||
texturebytype: { | |||
"*-shovel": { | |||
base: "tool/wand/wand-shovel", | |||
}, | |||
"*-pickaxe": { | |||
base: "tool/wand/wand-pickaxe", | |||
}, | |||
"*-axe": { | |||
base: "tool/wand/wand-axe", | |||
}, | |||
} | |||
</syntaxhighlight> | |||
But we can accomplish the same thing with an easier way: | |||
<syntaxhighlight json="lang"> | |||
texture: { | |||
base: "tool/wand/wand-{tooltype}", | |||
} | |||
</syntaxhighlight> | |||
<code>{tooltype}</code> will be replaced by either shovel, pickaxe or axe. | |||
== Texture Overlays == | == Texture Overlays == | ||
As everybody knows programmers are lazy, so instead of drawing a texture for each variant of our items, we can use overlays instead, which will make it a lot easier. |