Skip to content

Translation notice

This page was translated with machine translation and may contain inaccuracies. If you can help improve it, please open an issue or submit a pull request.

Second cover

What's New in the Library?

Command Flashlight Command Flashlight

Fast entity accessor

We know that using Itementity's Throwertag can save the UUID reference of the entity and access it efficiently:

mcfunction
# 将当前实体的UUID保存到物品NBT中
# 假设我们物品实体的uuid固定为0-0-0-0-1
data modify entity 0-0-0-0-1 Thrower set from entity @s UUID

As long as this entity still exists, we can access this entity through this item anywhere in our data pack:

mcfunction
execute as 0-0-0-0-1 on origin run <命令>

But what if you want to store references to multiple entities? We can let multiple items ride on a world entity and access it with the help of world entity:

mcfunction
# 假设世界实体是0-0-0-0-2
execute as 0-0-0-0-2 on passengers on origin run <命令>

When we want to add a new entity reference, we only need to let a new itemity ride on the world entity without limiting the UUID of the itemity.

Powered by VitePress and GitHub Pages