Many entities are "linked" together in some way. An cat might have an owner, or a snowball might have a thrower, or a zombie might have an aggro target. I propose a way to test and modify these links with commands.
/link <entity1> <linkType> set <entity2>
/link <entity1> <linkType> test [<entity2>]
/link <entity> <linkType> remove
/execute linked <linkType> -> execute
/link <entity1> <linkType> set <entity2>
- entity1: Specifies the entity/entities whose links to other entities are to be modified.
- linkType: The type of link in question. Different kinds of entities support different types of links.
- entity2: The entity to be linked. Must be a single entity.
Sets the entity1
's link of type linkType
to entity2
.
Examples:
/link @e[type=zombie] aggro set @p
Make all zombies attack the nearest player.
/link <entity1> <linkType> test [<entity2>]
- entity1: Specifies the entity/entities whose links to other entities are to be tested.
- linkType: The type of link in question. Different kinds of entities support different types of links.
- entity2 (optional): The entity or entities to test for. If left blank, the command tests whether any entity at all is linked.
If entity2
was included, the command's result
is the number of entity1
s whose linked entity was any of entity2
.
If entity2
was not included, the command's result
is the number of entity1
s who had a linked entity.
Examples:
/link @e[type=arrow] shooter test @e[type=skeleton]
Find the number of arrows that were fired by a skeleton.
/link @e[type=item] thrower test
Find the number of items that have a thrower (instead of being dropped on death, fired from a dispenser, etc.).
/link <entity> <linkType> remove
- entity: Specifies the entity/entities whose links to other entities are to be removed.
- linkType: The type of link in question. Different kinds of entities support different types of links.
Removes the entity
's linkType
, if any.
Examples:
/link @e[type=pig] attacking_entity remove
Calm any pigs that are panicking after being attacked.
/execute linked <linkType> -> execute
- linkType: The type of link in question. Different kinds of entities support different types of links.
Works much like /execute as <entity> -> execute
, except that this allows us to follow links in the execute
command.
Examples:
/execute as @e[type=arrow,tag=!mentioned] linked shooter then say I fired an arrow! /scoreboard players tag @e[type=arrow,tag=!mentioned] add mentioned
Cause every entity that fires an arrow to say "I fired an arrow!" in chat.
All may be optionally prefixed with minecraft:
.
- All entities:
steed
: The entity that is being ridden.
- All mobs:
attacking_player
: The most recent player to attack the mob. Used to determine drops.attacking_entity
: The most recent mob to attack the mob. Used to determine aggro for hostile mobs and panic for passive mobs.leash_holder
: The entity that this mob is leashed to.
- Hostile/Neutral mobs:
aggro
: The entity that the mob is currently attacking.
- Breedable mobs:
mate
: The entity that the mob is trying to mate with.love_cause
: The player that caused the mob to fall in love.
- Tameable mobs:
owner
: The player that tamed the mob.
- Projectiles:
shooter
: The entity that fired the projectile.
- Area Effect Cloud:
cloud_cause
: The entity that caused the cloud.
- Fish Hook (Also please give it an ID, just for selectors):
angler
: The player holding the fishing rod.hooked
: The entity hooked by the rod.
- Item:
item_owner
: Only this player can pick up the item until it is about to despawn. Used by the/give
command.thrower
: The player who threw the item.
- Primed TNT:
igniter
: The player who lit the TNT by hand.
- Wither:
aggro_head_1
,aggro_head_2
, andaggro_head_3
: The targets of each head, since each head can have a different target.
- Zombie Pigman:
pigman_anger
: The player that the pigman is angry at.
- Zombie Villager:
zombie_healer
: The player that started converting the zombie into a villager.
also, it would be
execute link
becauseas_link
is ugly