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.

It contains 94 functions that can do, among other things, the following:
 * Biome/weather detection
 * Player inventory manipulation
 * Flexible mob damage ("/damage")
 * Getting the name/the head of a player
 * Random number generation
 * 2D Perlin noise generation

Tag library
The AESTD tag library is a collection of 187 block, entity type, item and function tags. Other data packs may append their functions to the function tags in order to detect efficiently the following events:
 * Taking damage
 * Dealing damage
 * Killing an entity
 * Dying
 * Using a carrot on a stick (right-click detection)
 * Inventory changes

A summary of tags contained in the library can be found in the main article.

Benchmarking tool
AESTD features a benchmark function in the  namespace that can evaluate the performance cost of a function by running it as many times as possible in a second, and displaying the total number of iterations of that function. It uses the shrinkage of the world border, which updates depending on system time and not on in-game time (ticks). To use it, append your function to the  function tag and run the   function in the overworld.

When a benchmark is launched, the  is extended to 2000000 (from 65536). If the command limit is reached anyway, the benchmark will fail.

Warning: Using commands in your benchmarked function may crash the player running the benchmark.

Save chunk
The save chunk system relies on the constant loading of "save chunks", chunks in which AESTD automatically places blocks that are needed for data storage, computational loot tables, inventory manipulation and text component resolution. AESTD automatically marks three chunks for force loading, one in every dimension, at specific coordinates (x=1519204, z=0).

Every dimension's save chunk contains a yellow shulker box, which is used by functions that rely on computational loot tables or that modify a player's inventory, and a quartz block, which is used by AESTD to detect that the save chunk was correctly loaded and setup. Additionally, the overworld save chunk contains an oak sign for text component resolution, and a jukebox for arbitrary NBT data storage. These blocks are protected from survival players by bedrock.

Data packs are free to use the save chunks and the blocks they contain, but it is advised to follow some guidelines to avoid incompatibility issues with other data packs that use AESTD:
 * You should not destroy or move blocks that are in the save chunk, stop it from being force loaded or anything that could prevent the function library or other data packs from accessing the save chunk and its data
 * You should not reset data contained in the jukebox in the overworld save chunk
 * You should not use the yellow shulker box for long-term item storage, as other data packs (including AESTD itself) can use the shulker box at anytime
 * You should save data in your own compound tag when using the jukebox (for example, the function library uses ; if you want to save data in a   tag, you should save it in  )

Merging AESTD with your data pack
If you want to share your data pack and use AESTD but don't want to tell people to download two data packs, you can merge AESTD into yuour data pack by going through the following steps:


 * 1) Copy namespaces to your data pack. Open the AESTD data pack. Copy the ,  ,   and   namespaces and move them to your data pack's   folder.
 * 2) Move loot tables to your data pack. Open the AESTD data pack. Go in   and copy the yellow shulker box loot table to your data pack, under the   namespace.
 * 3) Merge  . Open your data pack. Go in   and add the following function:  . If there is no such file or directory, create it and copy from.
 * 4) Merge  . Open your data pack. Go in   and add the following function:  . 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

Official AESTD Discord server

“Aeldrion Creations” Discord server