--- a/net/minecraft/world/entity/animal/horse/TraderLlama.java
+++ b/net/minecraft/world/entity/animal/horse/TraderLlama.java
@@ -20,6 +20,7 @@
 import net.minecraft.world.level.ServerLevelAccessor;
 
 public class TraderLlama extends Llama {
+
     private int despawnDelay = 47999;
 
     public TraderLlama(EntityType<? extends TraderLlama> type, Level world) {
@@ -33,7 +34,7 @@
 
     @Override
     protected Llama makeBabyLlama() {
-        return EntityType.TRADER_LLAMA.create(this.level);
+        return (Llama) EntityType.TRADER_LLAMA.create(this.level);
     }
 
     @Override
@@ -65,6 +66,7 @@
     @Override
     protected void doPlayerRide(Player player) {
         Entity entity = this.getLeashHolder();
+
         if (!(entity instanceof WanderingTrader)) {
             super.doPlayerRide(player);
         }
@@ -81,7 +83,7 @@
 
     private void maybeDespawn() {
         if (this.canDespawn()) {
-            this.despawnDelay = this.isLeashedToWanderingTrader() ? ((WanderingTrader)this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1;
+            this.despawnDelay = this.isLeashedToWanderingTrader() ? ((WanderingTrader) this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1;
             if (this.despawnDelay <= 0) {
                 this.dropLeash(true, false);
                 this.discard();
@@ -113,10 +115,11 @@
             entityData = new AgeableMob.AgeableMobGroupData(false);
         }
 
-        return super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt);
+        return super.finalizeSpawn(world, difficulty, spawnReason, (SpawnGroupData) entityData, entityNbt);
     }
 
     protected static class TraderLlamaDefendWanderingTraderGoal extends TargetGoal {
+
         private final Llama llama;
         private LivingEntity ownerLastHurtBy;
         private int timestamp;
@@ -133,12 +136,15 @@
                 return false;
             } else {
                 Entity entity = this.llama.getLeashHolder();
+
                 if (!(entity instanceof WanderingTrader)) {
                     return false;
                 } else {
-                    WanderingTrader wanderingTrader = (WanderingTrader)entity;
-                    this.ownerLastHurtBy = wanderingTrader.getLastHurtByMob();
-                    int i = wanderingTrader.getLastHurtByMobTimestamp();
+                    WanderingTrader entityvillagertrader = (WanderingTrader) entity;
+
+                    this.ownerLastHurtBy = entityvillagertrader.getLastHurtByMob();
+                    int i = entityvillagertrader.getLastHurtByMobTimestamp();
+
                     return i != this.timestamp && this.canAttack(this.ownerLastHurtBy, TargetingConditions.DEFAULT);
                 }
             }
@@ -146,10 +152,11 @@
 
         @Override
         public void start() {
-            this.mob.setTarget(this.ownerLastHurtBy);
+            this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit
             Entity entity = this.llama.getLeashHolder();
+
             if (entity instanceof WanderingTrader) {
-                this.timestamp = ((WanderingTrader)entity).getLastHurtByMobTimestamp();
+                this.timestamp = ((WanderingTrader) entity).getLastHurtByMobTimestamp();
             }
 
             super.start();
