/entity_link

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)

Primary Languagemcfunction

Entity Link

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)

About

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).

Uses

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!
  • Multiplayer-friendly interactions between two entities

Using

With JMC

Linking entities

  • 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.

Searching for linked entity

  • 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.

With vanilla mcfunction

  • 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!

Searching for linked entity

  • 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 the entity_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!

Installing

  1. Install DatapackBuildManager using its instructions and construct a dependencies.json file.
  2. Add the following object to the dependencies object in dependencies.json:
    {
        "name": "Entity Link",
        "url": "https://github.com/AmericanBagel/entity_link"
    }
  1. Run build-datapack.py based on the instructions in DatapackBuildManager's docs, and Entity Link should be installed!

Manually

If none of your data pack's dependencies require Lantern Load:

  1. Drag, drop, and merge the data folder into your data pack's directory
  2. Go into data/load/tags/functions/load.json and append your data pack's load tag/function.
  3. Use Entity Link based on the docs

If you are already using Lantern Load or a dependency requires it:

  1. Install Lantern Load using the instructions in the docs if you haven't already.
  2. Drag and drop the data/entity_link directory into your pack's data directory.
  3. 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 to data/load/tags/functions/pre-load.json instead.
  4. Use Entity Link based on the docs above.

Redistributing or modifying Entity Link

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:

  1. Search and replace "entity_link" in "entity_link.jmc" with a prefix followed by entity_link e.g. my_project.entity_link.
  2. In src/jmc_config.json, replace entity_link with that same prefixed variation, e.g. my_project.entity_link.
  3. 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! 😃