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 targeted players.

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 (prior to v0.3), computational loot tables, inventory manipulation and text component resolution. AESTD automatically marks three chunks for force loading, one in every dimension, at specific coordinates past the world border (x=-30000000, z=7776).

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 sign for text component resolution. These blocks are protected from survival players by bedrock. Before the release of v0.3, the save chunk also contained a jukebox for arbitrary NBT data storage: this is no longer the case as v0.3 now uses general storage added in 19w38a.

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 a save chunk, stop it from being force loaded or anything that could prevent the function library or other data packs from accessing a 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.
 * If you use v0.1 or v0.2, you should not clear data from the overworld save chunk's jukebox.
 * If you use v0.1 or v0.2, 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  )

Using AESTD in your map

 * 1) Download AESTD below. Note that only the latest version is supported, meaning that you are on your own if you encounter bugs. However, later AESTD versions may be incompatible with outdated Minecraft versions.
 * 2) Place the data pack in your map's   folder. You don't need to extract it - it works both as a zip and as a folder.
 * 3) AESTD will be automatically setup: all features are ready to be used.

Merging AESTD with your data pack
If you want to share your data pack and use AESTD in it but don't want to tell people to download two data packs, you can merge AESTD into your 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. Only   is optional.
 * 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.

Once that operation is finished, your data pack's structure should resemble the above file structure, with your own namespaces.

Troubleshooting
If AESTD does not load properly in your world, follow these instructions:
 * Make sure your download of AESTD corresponds to your Minecraft version. There is no release of AESTD for Minecraft 1.13 and below.
 * Run in the chat.
 * Make sure you have placed the zip download directly in your world's `datapacks` folder (don't place it in a subfolder, eg. ).
 * If you have downloaded the AESTD repository from GitHub directly using, extract the zip archive, open the created folder and move the subfolder  to the parent   folder, or use an official download corresponding to your Minecraft version (see Downloads).

AESTD may not work properly with mods or plugins.

If you still encounter issues in a vanilla world or server, you can ask for help in the #help channel of the AESTD Discord server (see Links below). The more information you provide, the easier it will be to find out what the problem is: see if the data pack itself loaded properly using in the chat to pinpoint what works and what does not.

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

Minecraft versions
AESTD v0.2 - Minecraft 1.14.4

Minecraft snapshots
AESTD v0.2 - Minecraft snapshot 19w34a

AESTD v0.1 - Minecraft snapshot 19w05a

Links
GitHub repository

Official AESTD Discord server

“Aeldrion Creations” Discord server