Modding:Entity Attribute guardedPlayerUid
The guardedEntityId entity instance attribute is used to mark which target entity the entity should guard. If the target is a player, then the guardedPlayerUid entity instance attribute is also set. Essentially the guarded entity is the owner of the entity. Out of the vanilla entities, only the hacked locust and mech helpers set the attribute.
Note that entity instance attributes are different from entity type attributes. Since the instance attributes are unique to every instance of the entity, they cannot be set through json files. Server admins can read the instance id attribute of the currently selected entity with this command:
/entity cmd l[] attr guardedPlayerUid
Admins can also set the attribute with the following command.
/entity cmd l[] setattr string guardedPlayerUid value
Players with the clock maker class can set the attribute by hacking a locust. Players in creative mode can set it by placing a mech helper or hacked locust item (the item that spawns the entity).