User:Aeldrion/Projects/AESTD/Function library

The AESTD function library is the biggest feature of AESTD. It is a collection of functions that can be used by other datapacks. Functions are sorted in seven categories:,  ,  ,  ,  ,   and. The function library is multi version compatible: two data packs that use different versions of AESTD can both use a function without conflicts. From AESTD 1.0 onwards, all functions use the  namespace. In previous versions, they used the  namespace.

Some functions take the executing entity's scores and tags as input. In these cases, setting the right tags and scores should always be done right before executing the function as some functions in AESTD can modify these scores and tags.

The following documentation is up-to-date with the latest release of AESTD; older versions may not contain some of the features listed below.

anger
Makes the executing entity angry at an entity with a given UUID if it can (see aestd1:entity/get_uuid). Also includes the effects of aestd1:entity/fake_damage for technical reasons. If the executing entity is neutral or hostile, it will become angry at the target entity. If the entity whose UUID was last saved to storage is a player, the entity's death will count as a player kill and experience orbs will drop. Does not work for players (obviously).

execute as @p run function aestd1:entity/get_uuid function aestd1:entity/anger
 * 1) This function will make the executing entity angry against the nearest player

damage
Damages the executing entity by (damage/100) HP, does not work on players. Input:

Settings:
 * : if the executing mob has this tag, it will act as if it was hit by the latest entity whose UUID was previously saved to the save chunk (see aestd1:entity/get_uuid)
 * : if the executing mob has this tag, it will be set on fire

scoreboard players set @s aestd.damage 600 tag @s add aestd.damage.hurt_by_player tag @s add aestd.damage.fire function aestd1:entity/damage tag @s remove aestd.damage.hurt_by_player tag @s remove aestd.damage.fire
 * 1) This function will damage the executing entity by 6HP, make it angry against the nearest player and set it on fire

fake_damage
Hurts the executing entity without actually dealing damage, playing its hurt sound and turning it red. Does not work on players.

execute as @e[type=minecraft:cow] at @s if block ~ ~-1 ~ #aestd1:concrete run function aestd1:entity/fake_damage
 * 1) This command will simulate the damaging of all cows that stand on concrete

get_direction
Saves the executing entity's direction multiplied by 1000 to its direction scores. Output: | |

execute as @e[type=minecraft:fireball,limit=1,sort=nearest] run function aestd1:entity/get_direction execute as @e[type=minecraft:fireball,limit=1,sort=nearest] run tellraw @a {"score":{"name":"@s","objective":"aestd.dir.y"}}
 * 1) This function will display the nearest fireball's vertical direction in the chat

get_direction_magnitude
Gets the magnitude of the executing entity's direction vector multiplied by 1000. Example: if the executing entity's direction is 1.784; 5.139; 3.396, the magnitude is 6412. Output:

execute as @e[type=minecraft:fireball] run function aestd1:entity/get_direction_magnitude execute at @e[type=minecraft:fireball,scores={aestd.math.out=1000..}] run particle minecraft:flame ~ ~ ~ 0 0 0 0 1 force
 * 1) This function will display flame particles at fireballs whose direction speed is more than 1

get_distance
Gets the distance (x50) between the executing entity's position and the context position. Caps at 46300 or 926 blocks away (otherwise overflows happen). Output:

execute as @a at @s at @e[type=minecraft:creeper,limit=1,sort=nearest] run function aestd1:entity/get_distance execute as @a run title @s actionbar {"score":{"name":"@s","objective":"aestd.math.out"}}
 * 1) This function displays to all players their distance to the nearest creeper
 * 1) Executing entity: the player, context position: the position of the nearest creeper (because the command is ran as the player, at the creeper)
 * 2) Therefore, the measured distance is the distance from the player to the creeper
 * 3) The first at only ensures the selected creeper is the nearest to the player

get_motion
Saves the executing entity's motion multiplied by 1000 to its motion scores. Output: | |

execute as @e[type=minecraft:arrow] run function aestd1:entity/get_motion execute as @e[type=minecraft:arrow] at @s[scores={aestd.motion.y=1..}] run particle minecraft:end_rod ~ ~ ~ 0 0 0 0 1 force execute as @e[type=minecraft:arrow] at @s[scores={aestd.motion.y=..-1}] run particle minecraft:flame ~ ~ ~ 0 0 0 0 1 force
 * 1) This function will display end rod particles at arrows that are going upwards, flame particles at arrows that are going downwards

get_motion_magnitude
Gets the magnitude of the executing entity's motion vector multiplied by 1000. Example: if the executing entity's motion is 1.784; 5.139; 3.396, the magnitude is 6412. Output:

execute as @e[type=minecraft:arrow] run function aestd1:entity/get_motion_magnitude execute at @e[type=minecraft:arrow,scores={aestd.math.out=1000..}] run particle minecraft:flame ~ ~ ~ 0 0 0 0 1 force
 * 1) This function will display flame particles at arrows whose motion is more than 1

get_position
Saves the executing entity's position to its position scores. Output: | |

tag @a[nbt={SelectedItem:{id:"minecraft:compass"}}] add holding_compass execute as @a[tag=holding_compass] run function aestd1:entity/get_position execute as @a[tag=holding_compass] run title @s actionbar [{"score":{"name":"@s","objective":"aestd.pos.x"}}," ",{"score":{"name":"@s","objective":"aestd.pos.y"}}," ",{"score":{"name":"@s","objective":"aestd.pos.z"}}] tag @a remove holding_compass
 * 1) This function will display a player's position in their actionbar if they are holding a compass

get_position_scale50
Saves the executing entity's position (x50) to its position scores. Output: | |

get_rotation
Saves the executing entity's rotation to its rotation scores. Output: |

get_uuid
Saves the UUID least/most pair of the executing entity to storage. The entity whose UUID was last saved has the  tag. This UUID can then be used in aestd1:entity/anger, aestd1:entity/damage, aestd1:entity/projectile/set_owner_uuid and aestd1:entity/wolf/tame. Output: storage   |  tags tags

knockback
Simulates the hitting of the executing entity from another at context position. Caps horizontal motion at 0.3 in both axes, and vertical motion is always 0.3. Does not work on players.

execute as @e[type=minecraft:cow,limit=1,sort=nearest] at @p run function aestd1:entity/knockback execute as @p run function aestd1:entity/get_uuid scoreboard players set @e[type=minecraft:cow,limit=1,sort=nearest] aestd.damage 100 tag @e[type=minecraft:cow,limit=1,sort=nearest] add aestd.damage.hurt_by_entity execute as @e[type=minecraft:cow,limit=1,sort=nearest] run function aestd.damage.hurt_by_entity
 * 1) This function simulates the hitting of the nearest cow by the nearest player (see also aestd1:entity/damage)

offset_position
Offsets the executing entity's position by its vector scores, in millimeters (1000 = 1 block). Input: | |.

scoreboard players set @s aestd.vector.x 4000 scoreboard players set @s aestd.vector.y 500 scoreboard players set @s aestd.vector.z -2000 function aestd1:entity/offset_position
 * 1) This function will have the same effect as teleport @s ~4 ~0.5 ~-2

scoreboard players set @s aestd.random.max 32000 function aestd1:math/random_lcg scoreboard players operation @s aestd.vector.x = @s aestd.random function aestd1:math/random_lcg scoreboard players operation @s aestd.vector.z = @s aestd.random scoreboard players set @s aestd.random.max 256000 function aestd1:math/random_lcg scoreboard players operation @s aestd.vector.y = @s aestd.random function aestd1:entity/teleport_to_chunk_corner execute at @s run teleport @s ~ 0 ~ function aestd1:entity/offset_position
 * 1) Another, more useful example: this function will teleport the executing entity randomly in the current chunk
 * 2) (see random functions and aestd1:entity/teleport_to_chunk_corner)

set_direction
Sets the executing entity's direction from its direction scores divided by 1000. Input: | | Does not work on players and entities that use  instead of.

execute as @e[type=minecraft:fireball,limit=1,sort=nearest] run function aestd1:entity/get_direction scoreboard players set $-1 aestd.math.var -1 scoreboard players operation @e[type=minecraft:fireball,limit=1,sort=nearest] aestd.dir.y *= $-1 aestd.math.var execute as @e[type=minecraft:fireball,limit=1,sort=nearest] run function aestd1:entity/set_direction
 * 1) This function mirrors the nearest fireball's vertical direction (if it is going upwards, it will go downwards at the same speed instead)
 * 1) Multiply by -1

set_direction_from_position
Sets the direction of the executing entity towards the context position. The magnitude of the direction vector is defined by distance to context position. Further than 40 blocks away, direction is not guaranteed to be exact due to Motion resetting values above 10. Does not work on players.

execute as @e[type=minecraft:fireball] at @p run function aestd1:entity/set_direction_from_position
 * 1) This command shoots all fireballs to the nearest player (the further away the faster)

execute as @e[type=minecraft:fireball] at @s facing entity @p eyes positioned ^ ^ ^5 run function aestd1:entity/set_direction_from_position
 * 1) This one shoots fireballs to the nearest player with a constant speed regardless of the player's distance, because the command is ran five blocks away from the fireball and facing the player

set_direction_from_rotation
Sets the direction of the executing entity following context rotation. Does not work on players. This is just a simple implementation of aestd1:entity/set_direction_from_position. The context position is five blocks in front of the executing entity, so the direction will have a magnitude of 1.25.

execute as @e[type=minecraft:fireball] at @s facing entity @p eyes run function aestd1:entity/set_direction_from_rotation
 * 1) This command shoots all fireball to the nearest player, similarly to the above command
 * 2) Note: running the function at the fireball (with at @s) is important because the context rotation needs to be the rotation from the fireball to the player

set_direction_magnitude
Sets the magnitude (/1000) of the executing entity's direction vector. Does not work on players. Input:

execute as @e[type=minecraft:wither_skull] run function aestd1:entity/get_direction_magnitude scoreboard players set #aestd aestd.math.var 3 execute as @e[type=minecraft:wither_skull] run scoreboard players operation @s aestd.math.out *= #aestd aestd.math.var execute as @e[type=minecraft:wither_skull] run scoreboard players operation @s aestd.math.in = @s aestd.math.out execute as @e[type=minecraft:wither_skull] run function aestd1:entity/set_direction_magnitude
 * 1) This function triples the speed of all wither skulls

set_head
Places a player head on the executing entity's head slot, replacing any helmet the entity may be wearing. The skin corresponds to the player name saved to storage (see function aestd1:player/get_name). For players, the player function alternative (aestd1:player/set_head) should be more efficient. Input: storage    tag

execute as @p run function aestd1:player/get_name function aestd1:entity/set_head
 * 1) This function copies the nearest player's head to the executing entity

set_head_to_block
Places a block with a given numerical block ID on the executing entity's head slot (see aestd1:block/get_block_id). Input:

execute as @e[type=#aestd1:mobs] positioned ~ ~-1 ~ run function aestd1:block/get_block_id execute as @e[type=#aestd1:mobs] run function aestd1:entity/set_head_to_block
 * 1) This function places on every mob's head the block it is standing on

set_motion
Sets the executing entity's motion from its motion scores divided by 1000. Input: | |. Does not work on players and entities that use  instead of   (eg fireballs).

scoreboard players set @s aestd.random.min -500 scoreboard players set @s aestd.random.max 500 function aestd1:math/random_range_lcg scoreboard players operation @s aestd.motion.x = @s aestd.random function aestd1:math/random_range_lcg scoreboard players operation @s aestd.motion.y = @s aestd.random function aestd1:math/random_range_lcg scoreboard players operation @s aestd.motion.z = @s aestd.random function aestd1:entity/set_motion
 * 1) This function gives a random motion to the executing entity

set_motion_from_position
Sets the motion of the executing entity towards the context position. The magnitude of the motion vector is defined by distance to context position. Further than 40 blocks away, direction is not guaranteed to be exact due to Motion resetting values above 10. Does not work on players.

execute as @e[type=minecraft:creeper] at @p run function aestd1:entity/set_motion_from_position
 * 1) This command shoots creepers to the nearest player (the further away the faster)

execute as @e[type=minecraft:creeper] at @s facing entity @p eyes positioned ^ ^ ^5 run function aestd1:entity/set_motion_from_position
 * 1) This one shoots creepers to the nearest player with a constant motion regardless of the player's distance, because the command is ran five blocks away from the creeper and facing the player

set_motion_from_rotation
Sets the motion of the executing entity following context rotation. Does not work on players. This is just a simple implementation of aestd1:entity/set_motion_from_position. The context position is five blocks in front of the executing entity, so the motion will have a magnitude of 1.25.

execute as @e[type=minecraft:creeper] at @s facing entity @p eyes run function aestd1:entity/set_motion_from_rotation
 * 1) This command shoots creepers to the nearest player, similarly to the above command
 * 2) Note: running the function at the creeper (with at @s) is important because the context rotation needs to be the rotation from the creeper to the player

set_motion_magnitude
Sets the magnitude (/1000) of the executing entity's motion vector. Does not work on players. Input:

execute as @e[type=#aestd1:mobs] run function aestd1:entity/get_motion_magnitude scoreboard players set #aestd aestd.math.var 3 execute as @e[type=#aestd1:mobs] run scoreboard players operation @s aestd.math.out *= #aestd aestd.math.var execute as @e[type=#aestd1:mobs] run scoreboard players operation @s aestd.math.in = @s aestd.math.out execute as @e[type=#aestd1:mobs] run function aestd1:entity/set_motion_magnitude
 * 1) This function triples the motion of all mobs

scoreboard players set @e[type=minecraft:creeper] aestd.math.in 1000 execute as @e[type=minecraft:creeper] run function aestd1:entity/set_motion_magnitude
 * 1) Simpler example: this function gives all creepers a constant motion magnitude of 1

set_position
Loads the executing entity's position from its position scores. For players, the player function alternative (aestd1:player/set_position) should be more efficient. Input: | |

execute as @e[type=minecraft:arrow,tag=!shot] run function aestd1:entity/get_position tag @e[type=minecraft:arrow] add shot execute as @e[type=minecraft:arrow,tag=shot,nbt={inGround:1b},tag=!in_ground] run function aestd1:entity/set_position execute as @e[type=minecraft:arrow,tag=shot,nbt={inGround:1b},tag=!in_ground] run data merge entity @s {Color:-1} tag @e[type=minecraft:arrow,tag=shot,nbt={inGround:1b}] add in_ground
 * 1) This function teleports all arrows that hit the ground back to where they were shot
 * 1) The Color tag ensures the arrow doesn't make potion particles once teleported (Minecraft bug)

set_position_scale50
Loads the executing entity's position (/50) from its position scores. For players, the player function alternative (aestd1:player/set_position_scale50) should be more efficient. Input: | |

set_rotation
Loads the executing entity's rotation from its rotation scores. For players, the player function alternative (aestd1:player/set_rotation) should be more efficient. Input: |

shoot_arrow
Shoots a fully charged arrow as the executing entity at context position following context rotation. By default, the arrow is shot from the entity's feet; use  to shoot from the eyes instead. The last shot arrow gets the  tag.

execute as @a[predicate=aestd1:flags/is_sneaking] at @s unless entity @e[tag=aestd.arrow.last_shot, distance=..3] anchored eyes run function aestd1:entity/shoot_arrow
 * 1) This command shoots an arrow from all sneaking players, unless the last shot arrow is still within three blocks

shoot_arrow
Shoots a fully charged arrow as the executing entity at context position following context rotation. By default, the arrow is shot from the entity's feet; use  to shoot from the eyes instead. The last shot arrow gets the  tag.

execute as @a[predicate=aestd1:flags/is_sneaking] at @s unless entity @e[tag=aestd.arrow.last_shot, distance=..3] anchored eyes run function aestd1:entity/shoot_arrow
 * 1) This command shoots an arrow from all sneaking players, unless the last shot arrow is still within three blocks

shoot_trident
Shoots a fully charged trident as the executing entity at context position following context rotation. By default, the trident is shot from the entity's feet; use  to shoot from the eyes instead. The last shot trident gets the  tag. If the executing entity has the aestd.trident.from_inventory tag:
 * If it is not holding a trident: No trident will spawn.
 * If there is a trident in the entity's mainhand, or otherwise in its offhand: This trident will be selected (preserves name, enchantments, ...).
 * If it is a survival/adventure mode player: The trident will be removed from the player's inventory, but can be picked back up. The item will take damage, taking into account Unbreaking enchantments.

tag @a add aestd.trident.from_inventory execute as @a[predicate=aestd1:flags/is_sneaking] at @s anchored eyes run function aestd1:entity/shoot_trident tag @a remove aestd.trident.from_inventory
 * 1) This command shoots all sneaking players' tridents if they are holding one

teleport_surface
Teleports the executing entity to the highest block matching the x and z coordinates of the context position. For players, the player function alternative (aestd1:player/teleport_surface) should be more efficient.

execute as @a[nbt={SelectedItem:{id:"minecraft:clock"}}] at @s run function aestd1:entity/teleport_surface
 * 1) This command teleports all players who hold a clock to the surface

teleport_to_chunk_corner
Teleports the executing entity to the minimum x and z coordinates in the chunk it is in. For players, the player function alternative (aestd1:player/teleport_to_chunk_corner) should be more efficient.

projectile/set_owner_uuid
Sets the executing entity's owner to an entity with a given UUID (see aestd1:entity/get_uuid). Input: storage   |  tags

execute anchored eyes run summon minecraft:arrow ^ ^ ^1 {Tags:["new"],Color:-1,pickup:1b} execute anchored eyes positioned ^ ^ ^13 as @e[type=minecraft:arrow,tag=new,limit=1] run function aestd1:entity/set_motion_from_position function aestd1:entity/get_uuid execute as @e[type=minecraft:arrow,tag=new,limit=1] run function aestd1:entity/projectile/set_owner_uuid tag @e[type=arrow] remove new playsound entity.arrow.shoot master @a
 * 1) This function shoots an arrow from the executing player. The arrow's owner is the player, registrating all damage dealt by the arrow as player damage, triggering neutral behaviours and counting as player deaths
 * 2) Summon arrow in front of the player's eyes
 * 1) Set motion forward
 * 1) Set arrow's owner UUID to the player's
 * 1) Play shooting sound

villager/resupply
Restocks the executing villager's current trades. Does not affect demand, price increases and discounts.

execute as @e[type=minecraft:villager] run function aestd1:entity/villager/resupply
 * 1) This command makes all villagers provide infinite trades as long as it is running

villager/zombify
Zombifies the executing villager, as if it had been converted by another zombie. Preserves profession, experience, offers and gossips.

execute at @a[nbt={SelectedItem:{id:"minecraft:rotten_flesh"}}] as @e[type=minecraft:villager,distance=..8] run function aestd1:entity/villager/zombify
 * 1) This command makes all players holding rotten flesh turn nearby villagers into zombie villagers

wandering_trader/set_wandertarget_position
Sets a wandering trader's  position from its position scores. Input: | |

wolf/tame
Tames the executing wolf and sets its owner to a player with a given UUID (see aestd1:player/get_uuid) Input: storage   |  tags

execute as @r run function aestd1:player/get_uuid execute as @e[type=minecraft:wolf,nbt={OwnerUUID:""}] run function aestd1:entity/wolf/tame
 * 1) This function makes all wild wolves tamed to a random player

zombie/drown
Turns the executing zombie/zombie villager into a drowned. Preserves equipment, name and age (whether the zombie is a baby zombie or not).

execute as @e[type=minecraft:zombie] at @s if block ~ ~ ~ minecraft:water run function aestd1:entity/zombie/drown
 * 1) This command instantly turns all zombies that step into water into drowneds

zombie_villager/cure
Cures the executing zombie villager. Preserves profession, experience, offers and gossips.

execute as @e[type=minecraft:zombie_villager] run function aestd1:entity/zombie_villager/cure
 * 1) This command instantly cures all zombies in the world

Item functions
Item functions can modify an item entity or an item in a player's, mob's or block entity's inventory. The item slot that is selected is defined by the  score of the executing entity and the tags it has.

If the executing entity has the  tag, an item will be selected in a block entity at context position. If there is no block entity there, nothing will happen. The executing entity's  score corresponds to the   tag of the selected item (0-26 in a chest, for example).

If the executing entity doesn't have the  tag and is an item entity, it will be directly modified. If it doesn't have the tag but is a mob, a player or an armor stand, its  score will tell what item is being modified. For players, the score corresponds to the  tag of the selected item: 0-8 is in the hotbar, 9-35 is in the inventory, 100-103 is the armor and -106 is the offhand slot. -1 will select the mainhand and -2 the offhand. For mobs and armor stands, 100-103 corresponds to armor items, -1 will select the mainhand and -2 the offhand.

add_count
Adds to the count of an item, limiting to the item's stack size (see aestd1:item/save for slot index and details) Input: |

scoreboard players set @s aestd.item.slot -2 scoreboard players set @s aestd.item.count -1 function aestd1:item/add_count
 * 1) This function reduces the count of a player's or mob's offhand item

add_custom_model_data
Adds a value to the custom model data field of an item (see aestd1:item/save for slot index and details) Input: |

add_damage
Adds to the damage of an item (see aestd1:item/save for slot index and details). Breaks the item if durability becomes negative. Negative inputs will repair the item instead of damaging it. Input: |

scoreboard players set @a aestd.item.dmg 5 scoreboard players set @a aestd.item.slot -1 execute as @a run function aestd1:item/add_damage
 * 1) This function damages all player's selected items

add_enchantment
Adds an enchantment to an item (see aestd1:item/save for slot index and details). Input: | |

Enchantments use the following values for, corresponding to their protocol ID:
 * 0 - Protection
 * 1 - Fire Protection
 * 2 - Feather Falling
 * 3 - Blast Protection
 * 4 - Projectile Protection
 * 5 - Respiration
 * 6 - Aqua Affinity
 * 7 - Thorns
 * 8 - Depth Strider
 * 9 - Frost Walker
 * 10 - Curse of Binding
 * 11 - Sharpness
 * 12 - Smite
 * 13 - Bane of Arthropods
 * 14 - Knockback
 * 15 - Fire Aspect
 * 16 - Looting
 * 17 - Sweeping Edge
 * 18 - Efficiency
 * 19 - Silk Touch
 * 20 - Unbreaking
 * 21 - Fortune
 * 22 - Power
 * 23 - Punch
 * 24 - Flame
 * 25 - Infinity
 * 26 - Luck of the Sea
 * 27 - Lure
 * 28 - Loyalty
 * 29 - Impaling
 * 30 - Riptide
 * 31 - Channeling
 * 32 - Multishot
 * 33 - Quick Charge
 * 34 - Piercing
 * 35 - Mending
 * 36 - Curse of Vanishing

These values do not all correspond to the ones previously used in the  NBT tag.

scoreboard players set @s aestd.item.slot -1 scoreboard players set @s aestd.item.ench 11 scoreboard players set @s aestd.item.lvl 5 function aestd1:item/add_enchantment
 * 1) This function adds sharpness V to a player's or mob's held item

break
Simulates the breaking of an item (see aestd1:item/save for slot index and details). Input:

get_max_durability
Returns the durability of an item (see aestd1:item/save for slot index and details). This will only work for vanilla items. Input:, output:

load
Loads an item to the executing entity's inventory (see details below and aestd1:item/save). Used internally along with aestd1:item/save by most item functions. Input: storage    tag|

If the executing entity is an item entity, its data will be changed directly from the save chunk.

If the executing is a player or a mob, its  score determines in what slot the item will be loaded: Slot index

If the executing entity has the  tag, the item will be loaded in a container's slot at context position instead. corresponds to the item's  tag (eg. 4 for the middle of a dropper)

scoreboard players set @a aestd.item.slot -2 execute as @a run function aestd1:item/save scoreboard players set @a aestd.item.slot 103 execute as @a run function aestd1:item/load
 * 1) This function moves all players' offhand item to their head slot

merge_nbt
Merges NBT from storage to the  tag of an item. This can be used to add custom tags as well as default vanilla tags. Input: |storage     tag.

data modify storage aestd:input nbt set value {display:{Name:'"hello"'}} scoreboard players set @s aestd.item.slot 103 function aestd1:item/merge_nbt
 * 1) This function sets a player's head item's name to hello

remove_attribute_modifiers
Removes attribute modifiers from an item.

scoreboard players set @s aestd.item.slot 4 tag @s add aestd.item.container scoreboard players set @s aestd.list_mode -1 execute if block ~ ~ ~ minecraft:dropper run function aestd1:item/remove_attribute_modifiers
 * 1) This function removes the last attribute modifier of the item in the center of a dropper

remove_data
Removes all NBT data from an item (name, enchantments, lore, damage…) (see aestd1:item/save for slot index). Input:

remove_enchantments
Removes enchantments from an item.

scoreboard players set @s aestd.item.slot 103 scoreboard players set @s aestd.list_mode 1 function aestd1:item/remove_enchantments
 * 1) This function removes all enchantments on the player's helmet

remove_lore
Removes lines of lore from an item.

save
Saves an item to the save chunk. This function is used internally by most item functions.

set_count
Sets the count of an item to a score, limiting to the item's stack size. Setting the score to 0 or any negative value before running this function will delete the item. Input:

set_custom_model_data
Sets the custom model data field of an item to a score. Input:

set_damage
Sets the damage of an item to a score. Input:

set_nbt
Sets an item  tag's NBT to NBT from storage. This can be used to add custom tags as well as default vanilla tags. Input: storage    tag

data modify storage aestd:input nbt set value {display:{Name:'"hello"'}} scoreboard players set @s aestd.item.slot 103 function aestd1:item/set_nbt
 * 1) Resets a player's head item NBT and sets the NBT {display:{Name:'"hello"'}}

swap
Swaps two items in a given inventory. Input: |

scoreboard players set @a aestd.item.slot -1 scoreboard players set @a aestd.item.slot2 -2 execute as @a run function aestd1:item/swap
 * 1) This function forces all players to swap hand items

get_block_id
Saves a block's numerical ID to a score. This numerical ID corresponds to a protocol ID in the  file. This ID is used in other functions. Output:

highlight_block
Highlights the block at context position with end rod particles.

load
Loads a previously saved block to the block at context position.

randomize_structure_block
Randomizes the mirror and the rotation of the load structure block at context position.

save
Copies the block at context position to the save chunk.

set_skull_owner
Sets the owner of the player head at context position to a player whose name was previously saved by the aestd1:player/get_name function.

get_biome
Stores the context position biome's numerical ID into a score. Output:

get_dimension
Stores the context dimension into a score. Output:

get_light_level
Stores the light level at context position into a score. Output:

get_position
Saves the context position to the executing entity's position scores if the position is loaded. Output: | |

get_position_scale50
Saves the context position to the executing entity's position scores if the position is loaded. Output: | |

get_rotation
Saves the context position to the executing entity's rotation scores. Output: |

get_structure
Returns an ID corresponding to the structure at context position. If none is found, sets to 0. If context position is in the intersection of two different structures, the highest ID is returned.

load_chunk
Loads the chunk in which this function runs for the current tick.

get_block_looking_at
Finds the block the player is looking at, up to 64 blocks away. Looks through water and lava. Resets scores if no block is found. Output: | |

get_name
Saves the name of the executing player to storage. This name can then be used by other functions such as aestd1:entity/set_head and aestd1:block/set_skull_owner. The player whose name is currently saved has the tag. Output: storage    tag.

get_spawnpoint
Saves the coordinates of the executing player's spawnpoint to its position scores. Output: | |

get_uuid
Saves the string UUID of the executing player to storage. This UUID can then be used by other functions such as aestd1:entity/wolf/tame. Not to be confused with aestd1:entity/get_uuid, which saves the UUID as two tags which can be used in different situations by different functions (e.g. aestd1:entity/anger and aestd1:entity/projectile/set_owner_uuid). The player whose UUID is currently saved has the tag. Output: storage    tag

set_damage
Sets the attack damage of the executing player (default = 100 = half a heart). Stacks with strength/weakness effects, attribute modifiers and weapon damage. Damage is reset at death. Input:

set_experience_levels
Sets the executing player's experience levels to a fixed value. Input:

set_head
See aestd1:entity/set_head

set_knockback_resistance
Sets the knockback resistance chance (in percents) of the executing player (default = 0). Stacks with attribute modifiers. Knockback resistance is reset at death. Input:

set_movement_speed
Sets the movement speed of the executing player (default = 100). Stacks with swiftness/slowness effects, sprinting, crouching and attribute modifiers. Movement speed is reset at death. Input:

set_position
See aestd1:entity/set_position

set_position_scale50
See aestd1:entity/set_position_scale50

set_rotation
See aestd1:entity/set_rotation

teleport_surface
See aestd1:entity/teleport_surface

teleport_to_chunk_corner
See aestd1:entity/teleport_to_chunk_corner

Math
Most math functions take input from the executing entity's  and   scores and send output to its   score. This means that a math function needs to be executed by an entity and not directly ran from a command block or from.

absolute
Returns the absolute value of an integer. Input:, output:

Examples: 316 -> 316; -752 -> 752

cos
Returns the cosine of an integer (in degrees) multiplied by 1000. Input:, output:

Examples: 0 -> 1000, 30 -> 866, 120 -> -500

get_vector_magnitude
Gets the magnitude of a vector with given coordinates. Input: | |, output:

Example: (1784, 5139, 3396) -> 6412

linear_interpolation
Calculates an interpolation between two inputs (in and in2) for a parameter (var) in the closed interval [0, 1000] When var is 0, returns in. When var is 1000, returns in2. Input: | |, output:

Example: (in=3, in2=68, var=400) -> 29

perlin_noise
Uses a modified Perlin noise algorithm to generate values between 0 and 1000. Interpolates between thousands (actual Perlin noise interpolates between integers but the scoreboard cannot compute decimals). Input: | |, output:

power
Calculates pow(a,b) with b in [1;30]. Input: |, output:

Example: (in=2, in2=26) -> 67108864

random
Generates a random integer from 0 (included) to aestd.random.max (excluded). Input:, output:

random_lcg
Generates a random integer from 0 (included) to aestd.random.max (excluded). Uses a linear congruential generator, which is more efficient than the UUID method used in aestd1:math/random. Input:, output:

random_range
Generates a random integer from min (included) to max (excluded). Input: |, output:

random_range_lcg
Generates a random integer from min (included) to max (excluded). Uses a linear congruential generator, which is more efficient than the UUID method used in aestd1:math/random_range. Input: |, output:

set_vector_magnitude
Modifies the magnitude of a vector. Input: | |, output:

Example: (1784, 5139, 3396), magnitude=5000 -> (1391, 4007, 2648)

sin
Calculates the sine of an integer (in degrees) multiplied by 1000. Input:, output:

Examples: 0 -> 0, 30 -> 500, 240 -> -866

smoothstep
Returns S1(x)=3x^2 - 2x^3. x should be between 0 and 1000 and will be divided by 1000 in the operation. Clamps x to the interval [0, 1000]: if x<0, returns 0; if x>1000, returns 1000. Input:, output:

Example: 400 -> 352

square_root
Calculates the square root of a given number using the Babylonian method. If input is strictly negative, resets output. Input:, output:

Example: 2 147 395 600 -> 46 340

ticks_to_time
Converts a time in ticks into hours, minutes, seconds and hundredths. Input:, output:   (Playernames:  ,  ,  ,  )

add_marker
Summons an area_effect_cloud entity at given coordinates for this tick only with tag This marker can be targeted with the UUID. There can only be a single marker at the same time. Input: | |

get_daytime
Returns the period of the day to a score. Output:

get_moon_phase
Calculates the moon phase of the current night/upcoming night, updates at sunrise. Output:

get_weather
Returns the current weather. Output:

remove_time
Removes a duration in ticks from the world time (opposite operation of ). If an entity is executing this function, its score will be used. Otherwise (function ran from a command block or from ), uses the score of. Input:

set_time
Sets the world time to any value. If an entity is executing this function, its score will be used. Otherwise (function ran from a command block or from ), uses the score of. Input: