Repository navigation
Compatibility and API
MKI edited this page Oct 9, 2026
·
1 revision
Every mob from another mod that is not a monster can be bound, and it keeps all of its own data when it is stored, archived or packed. It gets the Loyal Heart ability unless the mod says otherwise. Server owners can allow or forbid single mobs and set their food, see Configuration.
With PartyLink installed, companions never fight party members or the companions of party members, and companion attacks on players follow PartyLink's friendly fire setting.
com.mki.loyalcompanions.api.LoyalCompanionsApi is the public API. Call it during your mod initialization.
// Allow or forbid your mobs as companions
LoyalCompanionsApi.allowCompanionEntity(Identifier.fromNamespaceAndPath("examplemod", "deer"));
LoyalCompanionsApi.blockCompanionEntity(Identifier.fromNamespaceAndPath("examplemod", "boss_wolf"));
// Set the food (the text is a translation key shown in the menu)
LoyalCompanionsApi.setCompanionFood("examplemod:deer", "food.examplemod.deer", "minecraft:apple", "minecraft:carrot");Read-only queries:
| Method | Returns |
|---|---|
isCompanion(Entity) |
Whether the entity is a companion. |
isOwnedCompanion(Entity, UUID) / isOwnedByPlayer(Entity, ServerPlayer)
|
Whether it belongs to that player. |
getCompanionOwner(Entity) |
The owner's UUID. |
getCompanionLevel(Entity) |
The level, 0 for other entities. |
getCompanionStrength/Defense/Attack/Vitality(Entity) |
The attribute including rarity and accessories. |
isStoredCompanion(ItemStack) |
Whether the stack is a Companion Totem holding a companion. |
isCompanionDamageSource(DamageSource) / getCompanionAttacker(DamageSource)
|
Whether a companion caused the damage, and which one. |
Loyal Companions wiki · written for version 2.0.0 · values are the defaults and can be changed by the server owner
Playing
Your companions
- Team and Archive
- Leveling and Skills
- Species Abilities
- Behavior and Orders
- Inventory and Equipment
- Injuries and Revival
Reference