User:Aeldrion/Projects/AESTD

AESTD is a utility datapack written by Aeldrion for Minecraft vanilla 1.14 that adds useful functions and tools to help making complex command systems easier. Its development started in July 2018.

AESTD function library
The AESTD function library is the biggest feature of AESTD. It is divided in seven folders:,  ,  ,  ,  ,   and. Every function contains a comment documentation stating in what snapshot or version the function was last tested.

anger.mcfunction
Simulates the damaging of the executing entity by a 'target entity' whose UUID was saved in the save chunk with the  function. If the entity is neutral or hostile, it will become angry at the target entity. If the target entity is a player, the entity's death will count as a player kill and experience orbs will drop.

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

damage.mcfunction
Damages the executing entity by a score divided by 100. Can be set to burn or anger the damaged entity with  function. Does not work for players. Input:

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

fake_damage.mcfunction
Simulates the damaging of the executing entity. Unlike, this function will not trigger any behavior from the executing entity and will not cause it to drop experience at death.

get_direction.mcfunction
Returns the direction of the executing entity to three scores, scaled up by 1000 and rounded to integers. Output:,  ,

get_motion.mcfunction
Returns the motion of the executing entity to three scores, scaled up by 1000 and rounded to integers. Output:,  ,

get_rotation.mcfunction
Returns the direction of the executing entity to two scores, rounded to integers. Output: ,

get_position.mcfunction
Returns the position of the executing entity to three scores, rounded to integers. Output:,  ,

get_uuid.mcfunction
Saves the /  pair of the executing entity to the save chunk, which can then be used by other functions such as. Output: (1519204 6 0), (1519204 6 0)

offset_position.mcfunction
Offsets the executing entity's position by three scores. Input:,  ,

scoreboard players set @s aestd.delta.x 4 scoreboard players set @s aestd.delta.y 0 scoreboard players set @s aestd.delta.z -2 function aestd:entity/offset_position
 * 1) This function will have the same effect as teleport @s ~4 ~ ~-2

set_direction.mcfunction
Sets the direction of the executing entity from three scores. Does not work for players. Input:,  ,

set_head.mcfunction
Places on the executing entity's head slot a player head whose skin owner's name was previously saved using the  function. Does not work on players.

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

set_head_to_block.mcfunction
Places on the executing entity's head a block whose id was previously saved with the  function. Does not work on players. Input:  (generated by get_block_id)

execute positioned ~ ~-1 ~ run function aestd:block/get_block_id function aestd:entity/set_head_to_block
 * 1) This function places on a mob's head the block it is standing on

set_motion.mcfunction
Sets the motion of the executing entity from three scores. Does not work for players. Input:,  ,

set_position.mcfunction
Sets the position of the executing entity from three scores. For players, the function  should be more efficient, but both work. Input:,  ,

set_rotation.mcfunction
Sets the rotation of the executing entity from two scores. For players, the function  should be more efficient, but both work. Input: ,

tame.mcfunction
Tames the executing entity if its behavior allows it and sets its owner to a player whose UUID was saved in the save chunk with the  function. Input: (1519204 6 0)

execute as @r run function aestd:player/get_uuid function aestd:entity/tame
 * 1) This function will make a random player tame the executing entity, if possible

teleport_surface.mcfunction
Teleports the executing entity on the highest non-air block matching the x and z coordinates of the context position (the surface).

execute as @a[nbt={SelectedItem:{id:"minecraft:chorus_fruit"}}] at @s run function aestd:entity/teleport_surface
 * 1) This function teleports all players holding a chorus fruit to the

teleport_to_chunk_corner.mcfunction
Teleports the executing entity to the westernmost, northernmost corner of the chunk it is in. Does not work for players.

Item
Item functions modify an item. The item that is modified can be an item entity or an inventory item, in a block or in a mob's or a player'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.mcfunction
Adds a score to the count of an item, limiting to the item's stack size. Input:

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

add_custom_model_data.mcfunction
Adds a score to the custom model data field of an item. Input:

add_damage.mcfunction
Adds a score to the damage of an item. If this score is negative, the item will be repaired instead of damaged. Input:

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

add_lore.mcfunction
Adds a line of lore to an item from a text string saved to the save chunk. Input: (1519204 6 0). The  makes this function treat the text string as a text component.

data modify block 1519204 6 0 RecordItem.tag.aestd.text set value "Hello world" scoreboard players set @p aestd.item.slot 4 function aestd:item/add_lore data modify block 1519204 6 0 RecordItem.tag.aestd.text set value '{"text":"Hello world","color":"aqua","italic":false}' tag @s add aestd.preformatted_text function aestd:item/add_lore
 * 1) This function adds the text "Hello world" to the item contained in the fifth hotbar slot of the nearest player, with default formatting then with a different color and style.

load.mcfunction
Loads an item from the save chunk, previously saved with the  function.

remove_attribute_modifiers.mcfunction
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 aestd:item/remove_attribute_modifiers
 * 1) This function removes the last attribute modifier of the item in the center of a dropper

remove_data.mcfunction
Clear the entire item's NBT data (name, enchantments, lore, damage…)

remove_enchantments.mcfunction
Removes enchantments from an item.

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

remove_lore.mcfunction
Removes lines of lore from an item.

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

scoreboard players set @s aestd.item.slot -1 function aestd:item/save scoreboard players set @s aestd.item.slot -2 function aestd:item/load
 * 1) This function uses aestd:item/load and aestd:item/save to move a player's mainhand item to his offhand

set_count.mcfunction
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.mcfunction
Sets the custom model data field of an item to a score. Input:

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

get_block_id.mcfunction
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.mcfunction
Highlights the block at context position with end rod particles.

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

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

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

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

get_biome.mcfunction
Saves the biome ID at context position to the sender's  score.

get_position.mcfunction
Saves the context position to 3 scores, rounded to integers.

get_rotation.mcfunction
Saves the context rotation to 2 scores, rounded to integers.

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

get_block_looking_at.mcfunction
Finds the coordinates of the block the player is looking at, in a distance defined by a score. Resets scores if the player isn't looking at a block. The maximum raycasting distance is 256 and the default is 80. Any value below 0 will be set to 3. Input:, output:  ,  ,

get_name.mcfunction
Saves the name of the player to the save chunk. Output: (1519204 6 0)

get_spawnpoint.mcfunction
Saves the player's spawnpoint to three scores. Output:,  ,

get_uuid.mcfunction
Saves the entire UUID of the player to the save chunk (not the same as, which saves the  /  pair). Output: (1519204 6 0)

set_experience_levels.mcfunction
Sets the player's experience levels to a score. Input:

set_position.mcfunction
Teleports the player to coordinates from three scores. Input:,  ,

Math
Most math functions take input from the executing entity's aestd.math.in and aestd.math.in2 scores and send output to its aestd.math.out score.

absolute.mcfunction
Returns |i|

cos.mcfunction
Returns 1000*cos(i) where x is an angle in degrees

power.mcfunction
Returns i^i2 where i2 is in the range [1;30]

random.mcfunction
Returns a random integer between 0 and aestd.random.max (excluded)

random_range.mcfunction
Returns a random integer in the [aestd.random.min;aestd.random.max[ range

sin.mcfunction
Returns 1000*sin(i) where i is an angle in degrees

add_marker.mcfunction
Summons a marker entity (area effect cloud) at given coordinates with an  tag for the current tick. Only one marker can exist at any given time; adding a marker will remove the last marker. Input:,  ,

get_daytime.mcfunction
Saves the current period of the day to the sender's  score.

get_moon_phase.mcfunction
Saves the current moon phase to the sender's  score.

get_weather.mcfunction
Saves the current weather to the sender's  score.

Useful tags
AESTD also features several item, block and entity tags.

Summary of item tags
,,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,

Summary of entity type flags
,,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,

Summary of block tags
,,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,

TPS calculator
The TPS calculator is a tool of the  namespace. It evaluates the ticks per second on a ten second period. To use the TPS calculator, use the command.

It uses the shrinking of the world border to compare ticks and actual time. When a TPS test has started, it must end before another TPS test starts.

Save chunk
The save chunk (positioned at x=1519204, z=0) is a chunk that AESTD uses to save data used by other functions. When AESTD is loaded for the first time in a new world, it will ask players to run a /forceload command to mark that chunk for force loading. Its loading is essential for many functions to work.

Setting up the save chunk
When you first load AESTD in your world, a message should appear in the chat, saying "WARNING - AESTD is not fully loaded. This may cause datapacks to malfunction." with a link suggesting a  command. Click it, and AESTD should load.
 * If you are not an administrator of the server: contact an administrator and ask them to run the following command:
 * If you are in singleplayer with cheats disabled: pause the game, click Open to LAN, set Allow Cheats to ON and click Start LAN world. You should now be able to run the command by clicking the link.

Merging your datapack with AESTD
If you want to share your datapack but don't want to tell people to download two datapacks, you can merge your datapack with AESTD by going through the following steps:


 * 1) Copy namespaces to your datapack. Open the AESTD datapack. Copy the ,   and   namespaces and move them to your datapack's   folder.
 * 2) Move loot tables to your datapack. Open the AESTD datapack. Go in   and copy loot tables to your datapack, under the   namespace. If your datapack modifies the player loot table or the orange shulker box loot table, make sure players still drop their heads when killed with   tag and that orange shulker boxes still drop only their contents when broken with a tool with the   NBT data.
 * 3) Merge  . Open your datapack. Go in   and add the following function:  . If there is no such file or directory, create it and copy from.
 * 4) Merge  . Open your datapack. Go in   and add the following functions: ,   and  . If there is no such file or directory, create it and copy from.

High range pick block
https://streamable.com/m3qge

main.mcfunction (called every tick by tick.json) execute as @a[scores={rightClick=1..}] run function pick_block
 * 1) rightClick detects the use of a carrot on a stick

pick_block.mcfunction function aestd:player/get_block_looking_at function aestd:world/add_marker execute at @e[tag=aestd.marker] run function aestd:block/get_block_id scoreboard players set @s aestd.item_slot -1 function aestd:item/set_block_id scoreboard players reset @s rightClick

Area of damage
The following function will cause all players to have a 1% chance of damaging nearby mobs every tick

main.mcfunction scoreboard players set @a aestd.random.max 100 execute as @a run function aestd:math/random execute as @a[scores={aestd.random=0}] at @s run function damage

damage.mcfunction tag @e[type=!player,distance=..5] add damaged scoreboard players set @e[tag=damaged] aestd.damage 400 tag @e[tag=damaged] add aestd.damage.hurt_by_player execute as @e[tag=damaged] run function aestd:entity/damage tag @e remove damaged
 * 1) Damage by 4HP

Links
GitHub repository

“Aeldrion Creations” Discord server