A library data pack built with JMC which links entities to other entities, based on CloudWolfYT's video (https://www.youtube.com/watch?v=685vs5hNQmk)
Entity Link is a library data pack built with JMC which links entities to other entities based on CloudWolfYT's video. While CloudWolfYT's video is great and made Entity Link possible, Entity Link is assembled for you -- no need to figure out how to assemble it. Additionally, Entity Link allows you to link any entity to any other entity; CloudWolfYT's tutorial, while obviously just a tutorial to get started, only permits linking a player to an entity (the most common use-case).
Entity linking is incredibly useful. Use-case examples include:
- Multiplayer-friendly interactions between a player and player-specific entities which last over 1 tick:
- Linking a player and a villager for right-click detection to prevent any bugs in multiplayer. The
distance
selector is not a good idea! Just link them! - Linking a player and an entity for left-click detection.
- Linking a player and a chest minecart for multiplayer-compatible GUIs.
- Pets! Perhaps you want to make a pet-related data pack. UUIDs are annoying and require multiple scoreboards and NBT tag reading. Entity linking is more efficient and easier.
- Per-player armor stand/custom model cosmetics
- Get creative!
- Linking a player and a villager for right-click detection to prevent any bugs in multiplayer. The
- Multiplayer-friendly interactions between two entities
With JMC
- Tag entity 2 with entity_link.init
- Execute
entity_link.link()
as entity 1
Quite simple, right?
For an example, see the entity_link.examples.summon
function in src/examples.jmc.
- Execute
entity_link.search()
as entity 1 - Linked entities will now have the
entity_link.linked
tag. Select linked entities using@e[tag=entity_link.linked]
.
For an example, see the entity_link.examples.tp
function in src/examples.jmc.
- Tag entity 2 with entity_link.init
- Execute
function entity_link:entity_link/link
as entity 1
Quite simple, right?
For an example, see the entity_link.examples.summon
function in src/examples.jmc. JMC syntax is quite easy to convert to mcfuntion syntax. If you can't understand JMC syntax at all, you may refer to data/entity_link/functions/entity_link/examples/summon
after compiling with JMC. Be warned: the mcfunction files are computer-generated and undocumented!
- Execute
function entity_link:entity_link/search
as entity 1 - The entity you searched from will have the
entity_link.this
tag, and the linked entities will now have theentity_link.linked
tag. Select linked entities using@e[tag=entity_link.linked]
. Select the entity you searched from with@e[tag=entity_link.this]
. - Run your functions which deal with your linked entities.
For an example, see the entity_link.examples.tp
function in src/examples.jmc. JMC syntax is quite easy to convert to mcfuntion syntax. If you can't understand JMC syntax at all, you may refer to data/entity_link/functions/entity_link/examples/tp
after compiling with JMC. Be warned: the mcfunction files are computer-generated and undocumented!
Using DatapackBuildManager
- Install DatapackBuildManager using its instructions and construct a
dependencies.json
file. - Add the following object to the
dependencies
object independencies.json
:
{
"name": "Entity Link",
"url": "https://github.com/AmericanBagel/entity_link"
}
- Run
build-datapack.py
based on the instructions in DatapackBuildManager's docs, and Entity Link should be installed!
If none of your data pack's dependencies require Lantern Load:
- Drag, drop, and merge the
data
folder into your data pack's directory - Go into
data/load/tags/functions/load.json
and append your data pack's load tag/function. - Use Entity Link based on the docs
If you are already using Lantern Load or a dependency requires it:
- Install Lantern Load using the instructions in the docs if you haven't already.
- Drag and drop the
data/entity_link
directory into your pack'sdata
directory. - Go into
data/load/tags/functions/load.json
and add"entity_link:__load__",
before your pack's load tag/function or, if you prefer, add it todata/load/tags/functions/pre-load.json
instead. - Use Entity Link based on the docs above.
Feel free to redistribute and modify Entity Link in any way you want to. I don't care! I won't force you to, but please add credit if you care to. Simply adding, "This datapack uses EntityLink by AmericanBagel." to your README is enough! What? Your project isn't on an open-source git repository? Make it on an open-source git repository! Don't want to? Fine. Just add some form of credit if you feel like it! Again, I won't force you to! Do what you want! I don't care!
If you want to modify Entity Link for your pack:
- Search and replace "entity_link" in "entity_link.jmc" with a prefix followed by
entity_link
e.g.my_project.entity_link
. - In
src/jmc_config.json
, replaceentity_link
with that same prefixed variation, e.g.my_project.entity_link
. - Compile it with JMC!
If you don't have JMC, use some directory-wide search-and-replace function -- VSCode/VSCodium has one -- and replace entity_link
with your prefixed variation, i.e. my_project.entity_link
.
What's worse than not enough documentation? Too much! 😃