-
Notifications
You must be signed in to change notification settings - Fork 52
Scripting
Scripting is an advanced method that can be used for many different things.
You could for example make a script that renders all small entities on your shoulders instead of in your hands,
or you could have custom pickup conditions like XP levels, achievements and even positioning in the world.
The scripts are simple json files, that can have any name and must be placed in the config/carryon-scripts folder.
Contents
The pickup object refers to which objects this script are affected by.
The object can either be of type block
or entity
.
Blocks can be specified using name
for the blockname, meta
for meta value, nbt
for any NBT Tags. NBT structure works like vanilla's default nbt structure.
Blocks can also have a material
type, which can be used to specify a block material. Valid material names here.
Blocks can also be matched based on resistance
, meaning explosion resistance and hardness
, meaning break time.
Entites also have a name
type, which is used to specifiy the name.
The height
and weight
types can be used to specify dimensions of the entity.
They can, like blocks, be matched on nbt
. They can also be matched based on health
.
This probably sounds very strange, so let's explain with some examples.
{
"object":
{
"block":
{
"name" : "minecraft:gold_block"
}
}
}
This script runs for Minecraft's Gold Block.
{
"object":
{
"block":
{
"hardness" : ">=1"
}
}
}
This script runs for any block with a hardness value that's greater than or equal to 1 These types can be combined in any way.
{
"object":
{
"block":
{
"hardness" : ">=1",
"material" : "rock",
"meta" : "<=11",
"nbt" :
{
"SomeString" : "foo",
"SomeInt" : 2
}
}
}
}
This script runs for any block with a hardness that's greater than or equal to 1, has the material "rock" (like stone, bricks..), has a meta value that's below or equal to 11, and has an NBT tag with two tags, one called "SomeString" and one called "SomeInt". So as you can see, they can get very specific.
{
"object":
{
"entity":
{
"width" : "<=1",
"height" : "<1.2",
"health" : ">=20",
"nbt" :
{
"SomeString" : "foo",
"SomeInt" : 2
}
}
}
}
Likewise, for entities.
The Pickup Object specify which scripts apply for which objects. The conditions check, if the player is allowed to carry said object. These are all possible conditions:
-
achievement
A simple string, which symbolizes which achievement must be unlocked. -
gamemode
A numeric value, that specifies which gamemode the player must have. -
gamestage
A string, that corresponds to a Game Stage that must be unlocked. This of course only works if GameStages is actually installed. -
position
An advanced string, that states the position where the player must stand in the world. -
xp
A numeric value that determines, how many levels the player must have. -
scoreboard
A scoreboard score that the player must have.
{
"object":
{
"block":
{
"name" : "minecraft:gold_block"
}
},
"conditions":
{
"xp" : "<=3",
"achievement" : "achievement.bakeCake",
"gamemode" : 0,
"gamestage" : "gold_blocks",
"scoreboard" : "gold_score=32",
"position" : "x=30,y=72,z=125,dx=65,dy=20,dz=200"
}
}
This advanced example uses all possible conditions to determine, if the player should be able to pick up a gold block. The player will be able, if they have less than or equal to 3 levels, they have unlocked the achievement "bake cake", the are in survival mode, they have unlocked the gamestage "gold_block", have a scoreboard value of exactly 32 for the objective "gold_score" and are situated in a box from x=30,y=72,z=125 to x=95,y=92,z=325. The d-coordinates get added to the base coordinates.