--- a/net/minecraft/world/entity/monster/piglin/Piglin.java
+++ b/net/minecraft/world/entity/monster/piglin/Piglin.java
@@ -4,15 +4,6 @@
 import com.mojang.serialization.Dynamic;
 import java.util.List;
 import javax.annotation.Nullable;
-import net.minecraft.core.BlockPos;
-import net.minecraft.nbt.CompoundTag;
-import net.minecraft.network.syncher.EntityDataAccessor;
-import net.minecraft.network.syncher.EntityDataSerializers;
-import net.minecraft.network.syncher.SynchedEntityData;
-import net.minecraft.resources.ResourceLocation;
-import net.minecraft.server.level.ServerLevel;
-import net.minecraft.sounds.SoundEvent;
-import net.minecraft.sounds.SoundEvents;
 import net.minecraft.util.RandomSource;
 import net.minecraft.util.VisibleForDebug;
 import net.minecraft.world.DifficultyInstance;
@@ -53,15 +44,33 @@
 import net.minecraft.world.level.ServerLevelAccessor;
 import net.minecraft.world.level.block.Blocks;
 import net.minecraft.world.level.block.state.BlockState;
+// CraftBukkit start
+import java.util.stream.Collectors;
+import java.util.HashSet;
+import java.util.Set;
+import net.minecraft.core.BlockPos;
+import net.minecraft.core.registries.BuiltInRegistries;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.ListTag;
+import net.minecraft.nbt.StringTag;
+import net.minecraft.nbt.Tag;
+import net.minecraft.network.syncher.EntityDataAccessor;
+import net.minecraft.network.syncher.EntityDataSerializers;
+import net.minecraft.network.syncher.SynchedEntityData;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.sounds.SoundEvent;
+import net.minecraft.sounds.SoundEvents;
+import net.minecraft.world.item.Item;
+// CraftBukkit end
 
 public class Piglin extends AbstractPiglin implements CrossbowAttackMob, InventoryCarrier {
+
     private static final EntityDataAccessor<Boolean> DATA_BABY_ID = SynchedEntityData.defineId(Piglin.class, EntityDataSerializers.BOOLEAN);
     private static final EntityDataAccessor<Boolean> DATA_IS_CHARGING_CROSSBOW = SynchedEntityData.defineId(Piglin.class, EntityDataSerializers.BOOLEAN);
     private static final EntityDataAccessor<Boolean> DATA_IS_DANCING = SynchedEntityData.defineId(Piglin.class, EntityDataSerializers.BOOLEAN);
     private static final ResourceLocation SPEED_MODIFIER_BABY_ID = ResourceLocation.withDefaultNamespace("baby");
-    private static final AttributeModifier SPEED_MODIFIER_BABY = new AttributeModifier(
-        SPEED_MODIFIER_BABY_ID, 0.2F, AttributeModifier.Operation.ADD_MULTIPLIED_BASE
-    );
+    private static final AttributeModifier SPEED_MODIFIER_BABY = new AttributeModifier(Piglin.SPEED_MODIFIER_BABY_ID, 0.20000000298023224D, AttributeModifier.Operation.ADD_MULTIPLIED_BASE);
     private static final int MAX_HEALTH = 16;
     private static final float MOVEMENT_SPEED_WHEN_FIGHTING = 0.35F;
     private static final int ATTACK_DAMAGE = 5;
@@ -69,53 +78,15 @@
     private static final int MAX_PASSENGERS_ON_ONE_HOGLIN = 3;
     private static final float PROBABILITY_OF_SPAWNING_AS_BABY = 0.2F;
     private static final EntityDimensions BABY_DIMENSIONS = EntityType.PIGLIN.getDimensions().scale(0.5F).withEyeHeight(0.97F);
-    private static final double PROBABILITY_OF_SPAWNING_WITH_CROSSBOW_INSTEAD_OF_SWORD = 0.5;
+    private static final double PROBABILITY_OF_SPAWNING_WITH_CROSSBOW_INSTEAD_OF_SWORD = 0.5D;
     public final SimpleContainer inventory = new SimpleContainer(8);
     public boolean cannotHunt;
-    protected static final ImmutableList<SensorType<? extends Sensor<? super Piglin>>> SENSOR_TYPES = ImmutableList.of(
-        SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR
-    );
-    protected static final ImmutableList<MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(
-        MemoryModuleType.LOOK_TARGET,
-        MemoryModuleType.DOORS_TO_CLOSE,
-        MemoryModuleType.NEAREST_LIVING_ENTITIES,
-        MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES,
-        MemoryModuleType.NEAREST_VISIBLE_PLAYER,
-        MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER,
-        MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS,
-        MemoryModuleType.NEARBY_ADULT_PIGLINS,
-        MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM,
-        MemoryModuleType.ITEM_PICKUP_COOLDOWN_TICKS,
-        MemoryModuleType.HURT_BY,
-        MemoryModuleType.HURT_BY_ENTITY,
-        MemoryModuleType.WALK_TARGET,
-        MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE,
-        MemoryModuleType.ATTACK_TARGET,
-        MemoryModuleType.ATTACK_COOLING_DOWN,
-        MemoryModuleType.INTERACTION_TARGET,
-        MemoryModuleType.PATH,
-        MemoryModuleType.ANGRY_AT,
-        MemoryModuleType.UNIVERSAL_ANGER,
-        MemoryModuleType.AVOID_TARGET,
-        MemoryModuleType.ADMIRING_ITEM,
-        MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM,
-        MemoryModuleType.ADMIRING_DISABLED,
-        MemoryModuleType.DISABLE_WALK_TO_ADMIRE_ITEM,
-        MemoryModuleType.CELEBRATE_LOCATION,
-        MemoryModuleType.DANCING,
-        MemoryModuleType.HUNTED_RECENTLY,
-        MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN,
-        MemoryModuleType.NEAREST_VISIBLE_NEMESIS,
-        MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED,
-        MemoryModuleType.RIDE_TARGET,
-        MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT,
-        MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT,
-        MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN,
-        MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD,
-        MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM,
-        MemoryModuleType.ATE_RECENTLY,
-        MemoryModuleType.NEAREST_REPELLENT
-    );
+    protected static final ImmutableList<SensorType<? extends Sensor<? super Piglin>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR);
+    protected static final ImmutableList<MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryModuleType.NEARBY_ADULT_PIGLINS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.ITEM_PICKUP_COOLDOWN_TICKS, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, new MemoryModuleType[]{MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.PATH, MemoryModuleType.ANGRY_AT, MemoryModuleType.UNIVERSAL_ANGER, MemoryModuleType.AVOID_TARGET, MemoryModuleType.ADMIRING_ITEM, MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM, MemoryModuleType.ADMIRING_DISABLED, MemoryModuleType.DISABLE_WALK_TO_ADMIRE_ITEM, MemoryModuleType.CELEBRATE_LOCATION, MemoryModuleType.DANCING, MemoryModuleType.HUNTED_RECENTLY, MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN, MemoryModuleType.NEAREST_VISIBLE_NEMESIS, MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, MemoryModuleType.RIDE_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT});
+    // CraftBukkit start - Custom bartering and interest list
+    public Set<Item> allowedBarterItems = new HashSet<>();
+    public Set<Item> interestItems = new HashSet<>();
+    // CraftBukkit end
 
     public Piglin(EntityType<? extends AbstractPiglin> type, Level world) {
         super(type, world);
@@ -134,6 +105,14 @@
         }
 
         this.writeInventoryToTag(nbt, this.registryAccess());
+        // CraftBukkit start
+        ListTag barterList = new ListTag();
+        this.allowedBarterItems.stream().map(BuiltInRegistries.ITEM::getKey).map(ResourceLocation::toString).map(StringTag::valueOf).forEach(barterList::add);
+        nbt.put("Bukkit.BarterList", barterList);
+        ListTag interestList = new ListTag();
+        this.interestItems.stream().map(BuiltInRegistries.ITEM::getKey).map(ResourceLocation::toString).map(StringTag::valueOf).forEach(interestList::add);
+        nbt.put("Bukkit.InterestList", interestList);
+        // CraftBukkit end
     }
 
     @Override
@@ -142,6 +121,10 @@
         this.setBaby(nbt.getBoolean("IsBaby"));
         this.setCannotHunt(nbt.getBoolean("CannotHunt"));
         this.readInventoryFromTag(nbt, this.registryAccess());
+        // CraftBukkit start
+        this.allowedBarterItems = nbt.getList("Bukkit.BarterList", 8).stream().map(Tag::getAsString).map(ResourceLocation::tryParse).map(BuiltInRegistries.ITEM::get).collect(Collectors.toCollection(HashSet::new));
+        this.interestItems = nbt.getList("Bukkit.InterestList", 8).stream().map(Tag::getAsString).map(ResourceLocation::tryParse).map(BuiltInRegistries.ITEM::get).collect(Collectors.toCollection(HashSet::new));
+        // CraftBukkit end
     }
 
     @VisibleForDebug
@@ -153,10 +136,15 @@
     @Override
     protected void dropCustomDeathLoot(ServerLevel world, DamageSource source, boolean causedByPlayer) {
         super.dropCustomDeathLoot(world, source, causedByPlayer);
-        if (source.getEntity() instanceof Creeper creeper && creeper.canDropMobsSkull()) {
-            ItemStack itemStack = new ItemStack(Items.PIGLIN_HEAD);
-            creeper.increaseDroppedSkulls();
-            this.spawnAtLocation(itemStack);
+        Entity entity = source.getEntity();
+
+        if (entity instanceof Creeper entitycreeper) {
+            if (entitycreeper.canDropMobsSkull()) {
+                ItemStack itemstack = new ItemStack(Items.PIGLIN_HEAD);
+
+                entitycreeper.increaseDroppedSkulls();
+                this.spawnAtLocation(itemstack);
+            }
         }
 
         this.inventory.removeAllItems().forEach(this::spawnAtLocation);
@@ -173,21 +161,22 @@
     @Override
     protected void defineSynchedData(SynchedEntityData.Builder builder) {
         super.defineSynchedData(builder);
-        builder.define(DATA_BABY_ID, false);
-        builder.define(DATA_IS_CHARGING_CROSSBOW, false);
-        builder.define(DATA_IS_DANCING, false);
+        builder.define(Piglin.DATA_BABY_ID, false);
+        builder.define(Piglin.DATA_IS_CHARGING_CROSSBOW, false);
+        builder.define(Piglin.DATA_IS_DANCING, false);
     }
 
     @Override
     public void onSyncedDataUpdated(EntityDataAccessor<?> data) {
         super.onSyncedDataUpdated(data);
-        if (DATA_BABY_ID.equals(data)) {
+        if (Piglin.DATA_BABY_ID.equals(data)) {
             this.refreshDimensions();
         }
+
     }
 
     public static AttributeSupplier.Builder createAttributes() {
-        return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 16.0).add(Attributes.MOVEMENT_SPEED, 0.35F).add(Attributes.ATTACK_DAMAGE, 5.0);
+        return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 16.0D).add(Attributes.MOVEMENT_SPEED, 0.3499999940395355D).add(Attributes.ATTACK_DAMAGE, 5.0D);
     }
 
     public static boolean checkPiglinSpawnRules(EntityType<Piglin> type, LevelAccessor world, MobSpawnType spawnReason, BlockPos pos, RandomSource random) {
@@ -197,9 +186,10 @@
     @Nullable
     @Override
     public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, @Nullable SpawnGroupData entityData) {
-        RandomSource randomSource = world.getRandom();
+        RandomSource randomsource = world.getRandom();
+
         if (spawnReason != MobSpawnType.STRUCTURE) {
-            if (randomSource.nextFloat() < 0.2F) {
+            if (randomsource.nextFloat() < 0.2F) {
                 this.setBaby(true);
             } else if (this.isAdult()) {
                 this.setItemSlot(EquipmentSlot.MAINHAND, this.createSpawnWeapon());
@@ -207,8 +197,8 @@
         }
 
         PiglinAi.initMemories(this, world.getRandom());
-        this.populateDefaultEquipmentSlots(randomSource, difficulty);
-        this.populateDefaultEquipmentEnchantments(world, randomSource, difficulty);
+        this.populateDefaultEquipmentSlots(randomsource, difficulty);
+        this.populateDefaultEquipmentEnchantments(world, randomsource, difficulty);
         return super.finalizeSpawn(world, difficulty, spawnReason, entityData);
     }
 
@@ -230,17 +220,19 @@
             this.maybeWearArmor(EquipmentSlot.LEGS, new ItemStack(Items.GOLDEN_LEGGINGS), random);
             this.maybeWearArmor(EquipmentSlot.FEET, new ItemStack(Items.GOLDEN_BOOTS), random);
         }
+
     }
 
     private void maybeWearArmor(EquipmentSlot slot, ItemStack stack, RandomSource random) {
         if (random.nextFloat() < 0.1F) {
             this.setItemSlot(slot, stack);
         }
+
     }
 
     @Override
     protected Brain.Provider<Piglin> brainProvider() {
-        return Brain.provider(MEMORY_TYPES, SENSOR_TYPES);
+        return Brain.provider(Piglin.MEMORY_TYPES, Piglin.SENSOR_TYPES);
     }
 
     @Override
@@ -250,42 +242,46 @@
 
     @Override
     public Brain<Piglin> getBrain() {
-        return (Brain<Piglin>)super.getBrain();
+        return (Brain<Piglin>) super.getBrain(); // CraftBukkit - Decompile error
     }
 
     @Override
     public InteractionResult mobInteract(Player player, InteractionHand hand) {
-        InteractionResult interactionResult = super.mobInteract(player, hand);
-        if (interactionResult.consumesAction()) {
-            return interactionResult;
+        InteractionResult enuminteractionresult = super.mobInteract(player, hand);
+
+        if (enuminteractionresult.consumesAction()) {
+            return enuminteractionresult;
         } else if (!this.level().isClientSide) {
             return PiglinAi.mobInteract(this, player, hand);
         } else {
-            boolean bl = PiglinAi.canAdmire(this, player.getItemInHand(hand)) && this.getArmPose() != PiglinArmPose.ADMIRING_ITEM;
-            return bl ? InteractionResult.SUCCESS : InteractionResult.PASS;
+            boolean flag = PiglinAi.canAdmire(this, player.getItemInHand(hand)) && this.getArmPose() != PiglinArmPose.ADMIRING_ITEM;
+
+            return flag ? InteractionResult.SUCCESS : InteractionResult.PASS;
         }
     }
 
     @Override
     public EntityDimensions getDefaultDimensions(Pose pose) {
-        return this.isBaby() ? BABY_DIMENSIONS : super.getDefaultDimensions(pose);
+        return this.isBaby() ? Piglin.BABY_DIMENSIONS : super.getDefaultDimensions(pose);
     }
 
     @Override
     public void setBaby(boolean baby) {
-        this.getEntityData().set(DATA_BABY_ID, baby);
+        this.getEntityData().set(Piglin.DATA_BABY_ID, baby);
         if (!this.level().isClientSide) {
-            AttributeInstance attributeInstance = this.getAttribute(Attributes.MOVEMENT_SPEED);
-            attributeInstance.removeModifier(SPEED_MODIFIER_BABY.id());
+            AttributeInstance attributemodifiable = this.getAttribute(Attributes.MOVEMENT_SPEED);
+
+            attributemodifiable.removeModifier(Piglin.SPEED_MODIFIER_BABY.id());
             if (baby) {
-                attributeInstance.addTransientModifier(SPEED_MODIFIER_BABY);
+                attributemodifiable.addTransientModifier(Piglin.SPEED_MODIFIER_BABY);
             }
         }
+
     }
 
     @Override
     public boolean isBaby() {
-        return this.getEntityData().get(DATA_BABY_ID);
+        return (Boolean) this.getEntityData().get(Piglin.DATA_BABY_ID);
     }
 
     private void setCannotHunt(boolean cannotHunt) {
@@ -300,7 +296,7 @@
     @Override
     protected void customServerAiStep() {
         this.level().getProfiler().push("piglinBrain");
-        this.getBrain().tick((ServerLevel)this.level(), this);
+        this.getBrain().tick((ServerLevel) this.level(), this);
         this.level().getProfiler().pop();
         PiglinAi.updateActivity(this);
         super.customServerAiStep();
@@ -314,21 +310,23 @@
     @Override
     protected void finishConversion(ServerLevel world) {
         PiglinAi.cancelAdmiring(this);
+        this.forceDrops = true; // Paper - Add missing forceDrop toggles
         this.inventory.removeAllItems().forEach(this::spawnAtLocation);
+        this.forceDrops = false; // Paper - Add missing forceDrop toggles
         super.finishConversion(world);
     }
 
     private ItemStack createSpawnWeapon() {
-        return (double)this.random.nextFloat() < 0.5 ? new ItemStack(Items.CROSSBOW) : new ItemStack(Items.GOLDEN_SWORD);
+        return (double) this.random.nextFloat() < 0.5D ? new ItemStack(Items.CROSSBOW) : new ItemStack(Items.GOLDEN_SWORD);
     }
 
     public boolean isChargingCrossbow() {
-        return this.entityData.get(DATA_IS_CHARGING_CROSSBOW);
+        return (Boolean) this.entityData.get(Piglin.DATA_IS_CHARGING_CROSSBOW);
     }
 
     @Override
     public void setChargingCrossbow(boolean charging) {
-        this.entityData.set(DATA_IS_CHARGING_CROSSBOW, charging);
+        this.entityData.set(Piglin.DATA_IS_CHARGING_CROSSBOW, charging);
     }
 
     @Override
@@ -338,38 +336,29 @@
 
     @Override
     public PiglinArmPose getArmPose() {
-        if (this.isDancing()) {
-            return PiglinArmPose.DANCING;
-        } else if (PiglinAi.isLovedItem(this.getOffhandItem())) {
-            return PiglinArmPose.ADMIRING_ITEM;
-        } else if (this.isAggressive() && this.isHoldingMeleeWeapon()) {
-            return PiglinArmPose.ATTACKING_WITH_MELEE_WEAPON;
-        } else if (this.isChargingCrossbow()) {
-            return PiglinArmPose.CROSSBOW_CHARGE;
-        } else {
-            return this.isAggressive() && this.isHolding(Items.CROSSBOW) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT;
-        }
+        return this.isDancing() ? PiglinArmPose.DANCING : (PiglinAi.isLovedItem(this.getOffhandItem()) ? PiglinArmPose.ADMIRING_ITEM : (this.isAggressive() && this.isHoldingMeleeWeapon() ? PiglinArmPose.ATTACKING_WITH_MELEE_WEAPON : (this.isChargingCrossbow() ? PiglinArmPose.CROSSBOW_CHARGE : (this.isAggressive() && this.isHolding(Items.CROSSBOW) ? PiglinArmPose.CROSSBOW_HOLD : PiglinArmPose.DEFAULT))));
     }
 
     public boolean isDancing() {
-        return this.entityData.get(DATA_IS_DANCING);
+        return (Boolean) this.entityData.get(Piglin.DATA_IS_DANCING);
     }
 
     public void setDancing(boolean dancing) {
-        this.entityData.set(DATA_IS_DANCING, dancing);
+        this.entityData.set(Piglin.DATA_IS_DANCING, dancing);
     }
 
     @Override
     public boolean hurt(DamageSource source, float amount) {
-        boolean bl = super.hurt(source, amount);
+        boolean flag = super.hurt(source, amount);
+
         if (this.level().isClientSide) {
             return false;
         } else {
-            if (bl && source.getEntity() instanceof LivingEntity) {
-                PiglinAi.wasHurtBy(this, (LivingEntity)source.getEntity());
+            if (flag && source.getEntity() instanceof LivingEntity) {
+                PiglinAi.wasHurtBy(this, (LivingEntity) source.getEntity());
             }
 
-            return bl;
+            return flag;
         }
     }
 
@@ -388,12 +377,13 @@
     }
 
     protected void holdInOffHand(ItemStack stack) {
-        if (stack.is(PiglinAi.BARTERING_ITEM)) {
+        if (stack.is(PiglinAi.BARTERING_ITEM) || this.allowedBarterItems.contains(stack.getItem())) { // CraftBukkit - Changes to accept custom payment items
             this.setItemSlot(EquipmentSlot.OFFHAND, stack);
             this.setGuaranteedDrop(EquipmentSlot.OFFHAND);
         } else {
             this.setItemSlotAndDropWhenKilled(EquipmentSlot.OFFHAND, stack);
         }
+
     }
 
     @Override
@@ -402,9 +392,10 @@
     }
 
     protected boolean canReplaceCurrentItem(ItemStack stack) {
-        EquipmentSlot equipmentSlot = this.getEquipmentSlotForItem(stack);
-        ItemStack itemStack = this.getItemBySlot(equipmentSlot);
-        return this.canReplaceCurrentItem(stack, itemStack);
+        EquipmentSlot enumitemslot = this.getEquipmentSlotForItem(stack);
+        ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
+
+        return this.canReplaceCurrentItem(stack, itemstack1);
     }
 
     @Override
@@ -412,18 +403,16 @@
         if (EnchantmentHelper.has(oldStack, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE)) {
             return false;
         } else {
-            boolean bl = PiglinAi.isLovedItem(newStack) || newStack.is(Items.CROSSBOW);
-            boolean bl2 = PiglinAi.isLovedItem(oldStack) || oldStack.is(Items.CROSSBOW);
-            return bl && !bl2
-                || (bl || !bl2)
-                    && (!this.isAdult() || newStack.is(Items.CROSSBOW) || !oldStack.is(Items.CROSSBOW))
-                    && super.canReplaceCurrentItem(newStack, oldStack);
+            boolean flag = PiglinAi.isLovedItem(newStack, this) || newStack.is(Items.CROSSBOW); // CraftBukkit
+            boolean flag1 = PiglinAi.isLovedItem(oldStack, this) || oldStack.is(Items.CROSSBOW); // CraftBukkit
+
+            return flag && !flag1 ? true : (!flag && flag1 ? false : (this.isAdult() && !newStack.is(Items.CROSSBOW) && oldStack.is(Items.CROSSBOW) ? false : super.canReplaceCurrentItem(newStack, oldStack)));
         }
     }
 
     @Override
     protected void pickUpItem(ItemEntity item) {
-        this.onItemPickup(item);
+        // this.onItemPickup(item); // Paper - EntityPickupItemEvent fixes; call in PiglinAi#pickUpItem after EntityPickupItemEvent is fired
         PiglinAi.pickUpItem(this, item);
     }
 
@@ -438,12 +427,13 @@
 
     private Entity getTopPassenger(Entity entity, int maxLevel) {
         List<Entity> list = entity.getPassengers();
-        return maxLevel != 1 && !list.isEmpty() ? this.getTopPassenger(list.get(0), maxLevel - 1) : entity;
+
+        return maxLevel != 1 && !list.isEmpty() ? this.getTopPassenger((Entity) list.get(0), maxLevel - 1) : entity;
     }
 
     @Override
     protected SoundEvent getAmbientSound() {
-        return this.level().isClientSide ? null : PiglinAi.getSoundForCurrentActivity(this).orElse(null);
+        return this.level().isClientSide ? null : (SoundEvent) PiglinAi.getSoundForCurrentActivity(this).orElse(null); // CraftBukkit - Decompile error
     }
 
     @Override
