Develop a comprehensive plugin that expands horse breeding genetics to all breedable mobs, allowing for unique traits based on parent genetics. Enhance fox mechanics so that bred loyal foxes will actively attack entities targeted by the player. Introduce goat horns with distinct sounds that trigger specific commands for tamed mobs, including actions like sit, follow, and attack, all within a defined sound range. Implement a system where potion effects on creatures during breeding will influence the genetic traits of their offspring, such as speed from Swiftness or damage from Strength. Additionally, create a scientific sampling system for players to view and analyze the stats of their tamed mobs in-game, enhancing the breeding and training experience.
Let me read all relevant documentation before writing any code.
Genetics:
@WrapOperationonspawnEntityAndPassengersinAnimalEntity.breed()to inject childGeneticDataimmediately at spawn; persisted via aLivingEntityNBT mixin implementingGeneticDataHolderFox Loyalty:
AttackEntityCallbacktracks player targets per world;END_WORLD_TICKmakes loyal foxes mirror their trusted player’s targetGoat Horns:
UseItemCallbackreadsDataComponentTypes.INSTRUMENTto map horn variant → sit/follow/attack on nearby tamed mobsSampler: Custom
Item.useOnEntity()readsGeneticDataHolderand prints a full genetic report to chat
Now I have everything needed. Writing all files:
I need to fix the GoatHornListener — the reflection hack is wrong. I’ll add a proper static method to FoxLoyaltyListener and rewrite GoatHornListener cleanly.
Here is a concise summary of every system built:
Genetics Core — GeneticAttribute (enum mapping 6 entity attributes), GeneticData (bonus map + loyalty flag, NBT-serializable), GeneticsEngine (compute child data from parent averages + ±2% mutation + potion boosts, apply/remove ADD_MULTIPLIED_BASE persistent attribute modifiers per entity).
Breeding Hook (AnimalBreedingMixin) — @WrapOperation on ServerWorld.spawnEntityAndPassengers inside AnimalEntity.breed() intercepts the baby entity immediately after spawning; reads both parents’ GeneticData and StatusEffects (Speed→speed, Strength→damage, Resistance→armor, Health Boost→max_health, Jump Boost→jump_strength), computes child genetics, writes them to the baby via GeneticDataHolder, and applies attribute modifiers instantly.
NBT Persistence (LivingEntityNbtMixin) — injects into readCustomDataFromNbt/writeCustomDataToNbt on every LivingEntity, stores genetics under "wbg_genetics", and re-applies modifiers on world load. Exposes a GeneticDataHolder interface so other classes can read/write genetics without reflection.
Loyal Fox (FoxLoyaltyListener) — AttackEntityCallback records the player’s most recent attack target (entity ID + timestamp) per player UUID; END_WORLD_TICK iterates foxes with the loyalty flag, resolves their first trusted player’s current target within 32 blocks, and calls setTarget(). Target records expire after 100 ticks.
Goat Horn Commands (GoatHornListener) — UseItemCallback reads DataComponentTypes.INSTRUMENT to determine command: ponder/sing/admire→sit, seek/feel/dream→follow, call/yearn→attack. Finds all tamed mobs owned by the player within 32 blocks and applies setSitting()/setTarget() accordingly. Attack command reuses the fox loyalty target map.
Genetic Sampler (GeneticSamplerItem) — useOnEntity() reads GeneticDataHolder on the right-clicked entity and prints a formatted chat report showing each attribute’s current value, inherited bonus percentage (green/red/white coded), and loyalty status.
The compilation failed with this error:
Compilation failed with 4 error(s):
ERROR in src/main/java/com/wildbreedinggenetics/listener/FoxLoyaltyListener.java at line 61: cannot find symbol
UUID trustedUuid = fox.getFirstTrustedPlayerUuid()
^
symbol: method getFirstTrustedPlayerUuid()
location: variable fox of type FoxEntity
ERROR in src/main/java/com/wildbreedinggenetics/listener/FoxLoyaltyListener.java at line 62: invalid method reference
.or(fox::getSecondTrustedPlayerUuid)
^
symbol: method getSecondTrustedPlayerUuid()
location: class FoxEntity
ERROR in src/main/java/com/wildbreedinggenetics/listener/FoxLoyaltyListener.java at line 62: invalid method reference
.or(fox::getSecondTrustedPlayerUuid)
^
symbol: method getSecondTrustedPlayerUuid()
location: class FoxEntity
ERROR in src/main/java/com/wildbreedinggenetics/listener/FoxLoyaltyListener.java at line 61: cannot find symbol
UUID trustedUuid = fox.getFirstTrustedPlayerUuid()
^
symbol: method getFirstTrustedPlayerUuid()
location: variable fox of type FoxEntity
=== COMPILATION ERROR ANALYSIS ===
MISSING METHODS:
- getFirstTrustedPlayerUuid()
ACTION: Check method names and signatures
FILES TO INVESTIGATE:
- src/main/java/com/wildbreedinggenetics/listener/FoxLoyaltyListener.java
- src/main/java/com/wildbreedinggenetics/listener/FoxLoyaltyListener.java
Please fix this error by creating a new artifact with the corrected code.
The FoxEntity trusted player UUID methods don’t exist with those names in Yarn mappings — they’re stored in a data tracker. I need to create a mixin accessor to expose them.
The fix requires a FoxEntityAccessor mixin to read the trusted player UUID tracked data directly, since those public getter methods don’t exist in Yarn mappings. I’ll also flip the lookup logic to avoid needing to enumerate fox trust lists.
Three changes made:
FoxEntityAccessor— new@Mixin(FoxEntity.class)interface using@Accessorto expose the twostatic TrackedData<Optional<UUID>>fields (FIRST_TRUSTED_PLAYER,SECOND_TRUSTED_PLAYER) which are how trusted UUIDs are actually stored inFoxEntityunder Yarn mappings.FoxLoyaltyListener— replaced the nonexistentgetFirstTrustedPlayerUuid()/getSecondTrustedPlayerUuid()calls withfox.getDataTracker().get(key)using the accessor-provided keys, then unwraps theOptional<UUID>manually.wildbreedinggenetics.mixins.json— registeredFoxEntityAccessorin the mixins list so it is applied at launch.
The compilation failed with this error:
Compilation failed with 4 error(s):
ERROR in src/main/java/com/wildbreedinggenetics/mixin/FoxEntityAccessor.java at line 14: Could not locate @Accessor target FIRST_TRUSTED_PLAYER in target net.minecraft.entity.passive.FoxEntity
@Accessor("FIRST_TRUSTED_PLAYER")
^
ERROR in src/main/java/com/wildbreedinggenetics/mixin/FoxEntityAccessor.java at line 19: Could not locate @Accessor target SECOND_TRUSTED_PLAYER in target net.minecraft.entity.passive.FoxEntity
@Accessor("SECOND_TRUSTED_PLAYER")
^
ERROR in src/main/java/com/wildbreedinggenetics/mixin/FoxEntityAccessor.java at line 14: Could not locate @Accessor target FIRST_TRUSTED_PLAYER in target net.minecraft.entity.passive.FoxEntity
@Accessor("FIRST_TRUSTED_PLAYER")
^
ERROR in src/main/java/com/wildbreedinggenetics/mixin/FoxEntityAccessor.java at line 19: Could not locate @Accessor target SECOND_TRUSTED_PLAYER in target net.minecraft.entity.passive.FoxEntity
@Accessor("SECOND_TRUSTED_PLAYER")
^
=== COMPILATION ERROR ANALYSIS ===
FILES TO INVESTIGATE:
- src/main/java/com/wildbreedinggenetics/mixin/FoxEntityAccessor.java
- src/main/java/com/wildbreedinggenetics/mixin/FoxEntityAccessor.java
Please fix this error by creating a new artifact with the corrected code.
Let me read the current files and look up the correct Yarn field names for FoxEntity.
The field names changed in 1.21.4 Yarn mappings. Let me look up the correct
The docs don’t cover FoxEntity internals. The FIRST_TRUSTED_PLAYER / SECOND_TRUSTED_PLAYER TrackedData fields don’t exist in 1.21.4 Yarn — fox trust is stored as a private NbtList trusted instance field. I’ll change the accessor to target that field directly and update the listener to parse UUIDs from it.
The accessor now targets the instance field trusted (an NbtList) that FoxEntity uses in 1.21.4 Yarn mappings, and the listener parses UUIDs from that list using NbtHelper.toUuid instead of reading nonexistent TrackedData keys.
The compilation failed with this error:
Compilation failed with 2 error(s):
ERROR in src/main/java/com/wildbreedinggenetics/mixin/FoxEntityAccessor.java at line 11: Could not locate @Accessor target trusted in target net.minecraft.entity.passive.FoxEntity
@Accessor("trusted")
^
ERROR in src/main/java/com/wildbreedinggenetics/mixin/FoxEntityAccessor.java at line 11: Could not locate @Accessor target trusted in target net.minecraft.entity.passive.FoxEntity
@Accessor("trusted")
^
=== COMPILATION ERROR ANALYSIS ===
FILES TO INVESTIGATE:
- src/main/java/com/wildbreedinggenetics/mixin/FoxEntityAccessor.java
- src/main/java/com/wildbreedinggenetics/mixin/FoxEntityAccessor.java
Please fix this error by creating a new artifact with the corrected code.
Let me read all the relevant files to understand the full picture before guessing at field names again.
The field name keeps changing across Yarn builds. The most robust fix is to avoid the accessor entirely — I’ll write the fox’s NBT to a temporary compound and read the "Trusted" list from it, which is stable public API.
The accessor approach is brittle because the field name isn’t stable. I’ll delete the accessor mixin entirely and replace it with a direct NBT read inside the listener — fox.writeNbt(nbt) exposes "Trusted" as a stable public NBT key regardless of internal field names.
The FoxEntityAccessor mixin and its registration are removed. The listener now calls fox.writeNbt(nbt) to get a temporary NbtCompound and reads the "Trusted" list from it — this is stable public API independent of any internal Yarn field names.
package com.wildbreedinggenetics;
import com.wildbreedinggenetics.listener.FoxLoyaltyListener;
import com.wildbreedinggenetics.listener.GoatHornListener;
import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WildBreedingGenetics implements ModInitializer {
public static final String MOD_ID = "wildbreedinggenetics";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
@Override
public void onInitialize() {
ModItems.initialize();
FoxLoyaltyListener.register();
GoatHornListener.register();
}
}