--- a/net/minecraft/world/entity/npc/EntityVillager.java
+++ b/net/minecraft/world/entity/npc/EntityVillager.java
@@ -93,6 +93,15 @@
 import net.minecraft.world.phys.AxisAlignedBB;
 import org.slf4j.Logger;
 
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Villager;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.EntityTransformEvent;
+import org.bukkit.event.entity.VillagerReplenishTradeEvent;
+// CraftBukkit end
+
 public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder {
 
     private static final Logger LOGGER = LogUtils.getLogger();
@@ -133,6 +142,9 @@
     }, MemoryModuleType.MEETING_POINT, (entityvillager, holder) -> {
         return holder.is(PoiTypes.MEETING);
     });
+    // CraftBukkit start
+    public long gossipDecayInterval = GOSSIP_DECAY_INTERVAL;
+    // CraftBukkit end
 
     public EntityVillager(EntityTypes<? extends EntityVillager> entitytypes, World world) {
         this(entitytypes, world, VillagerType.PLAINS);
@@ -140,7 +152,9 @@
 
     public EntityVillager(EntityTypes<? extends EntityVillager> entitytypes, World world, VillagerType villagertype) {
         super(entitytypes, world);
-        this.gossips = new Reputation();
+        // CraftBukkit start - add constructor parameter in Reputation
+        this.gossips = new Reputation(this);
+        // CraftBukkit end
         ((Navigation) this.getNavigation()).setCanOpenDoors(true);
         this.getNavigation().setCanFloat(true);
         this.getNavigation().setRequiredPathLength(48.0F);
@@ -150,7 +164,7 @@
 
     @Override
     public BehaviorController<EntityVillager> getBrain() {
-        return super.getBrain();
+        return (BehaviorController<EntityVillager>) super.getBrain(); // CraftBukkit - decompile error
     }
 
     @Override
@@ -235,7 +249,7 @@
                     this.increaseProfessionLevelOnUpdate = false;
                 }
 
-                this.addEffect(new MobEffect(MobEffects.REGENERATION, 200, 0));
+                this.addEffect(new MobEffect(MobEffects.REGENERATION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.VILLAGER_TRADE); // CraftBukkit
             }
         }
 
@@ -360,7 +374,13 @@
         while (iterator.hasNext()) {
             MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
 
-            merchantrecipe.resetUses();
+            // CraftBukkit start
+            VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
+            Bukkit.getPluginManager().callEvent(event);
+            if (!event.isCancelled()) {
+                merchantrecipe.resetUses();
+            }
+            // CraftBukkit end
         }
 
         this.resendOffersToTradingPlayer();
@@ -429,7 +449,13 @@
             while (iterator.hasNext()) {
                 MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
 
-                merchantrecipe.resetUses();
+                // CraftBukkit start
+                VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
+                Bukkit.getPluginManager().callEvent(event);
+                if (!event.isCancelled()) {
+                    merchantrecipe.resetUses();
+                }
+                // CraftBukkit end
             }
         }
 
@@ -489,7 +515,7 @@
     @Override
     public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
         super.addAdditionalSaveData(nbttagcompound);
-        DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData());
+        DataResult<NBTBase> dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error
         Logger logger = EntityVillager.LOGGER;
 
         Objects.requireNonNull(logger);
@@ -512,7 +538,7 @@
     public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
         super.readAdditionalSaveData(nbttagcompound);
         if (nbttagcompound.contains("VillagerData", 10)) {
-            DataResult dataresult = VillagerData.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("VillagerData"));
+            DataResult<VillagerData> dataresult = VillagerData.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("VillagerData")));
             Logger logger = EntityVillager.LOGGER;
 
             Objects.requireNonNull(logger);
@@ -808,7 +834,7 @@
                 entitywitch1.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entitywitch1.blockPosition()), EntitySpawnReason.CONVERSION, (GroupDataEntity) null);
                 entitywitch1.setPersistenceRequired();
                 this.releaseAllPois();
-            });
+            }, EntityTransformEvent.TransformReason.LIGHTNING, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit
 
             if (entitywitch == null) {
                 super.thunderHit(worldserver, entitylightning);
@@ -891,7 +917,7 @@
 
         if (this.lastGossipDecayTime == 0L) {
             this.lastGossipDecayTime = i;
-        } else if (i >= this.lastGossipDecayTime + 24000L) {
+        } else if (i >= this.lastGossipDecayTime + gossipDecayInterval) { // CraftBukkit - use variable for decay interval
             this.gossips.decay();
             this.lastGossipDecayTime = i;
         }
@@ -906,7 +932,7 @@
             }).limit(5L).toList();
 
             if (list1.size() >= j) {
-                if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, false).isEmpty()) {
+                if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE).isEmpty()) { // CraftBukkit
                     list.forEach(SensorGolemLastSeen::golemDetected);
                 }
             }
@@ -919,15 +945,18 @@
 
     @Override
     public void onReputationEventFrom(ReputationEvent reputationevent, Entity entity) {
+        Villager.ReputationEvent bukkitReputationEvent = org.bukkit.craftbukkit.entity.CraftVillager.CraftReputationEvent.minecraftToBukkit(reputationevent); // CraftBukkit - convert event to bukkit
         if (reputationevent == ReputationEvent.ZOMBIE_VILLAGER_CURED) {
-            this.gossips.add(entity.getUUID(), ReputationType.MAJOR_POSITIVE, 20);
-            this.gossips.add(entity.getUUID(), ReputationType.MINOR_POSITIVE, 25);
+            // CraftBukkit start - add change reason parameter
+            this.gossips.add(entity.getUUID(), ReputationType.MAJOR_POSITIVE, 20, bukkitReputationEvent);
+            this.gossips.add(entity.getUUID(), ReputationType.MINOR_POSITIVE, 25, bukkitReputationEvent);
+            // CraftBukkit end
         } else if (reputationevent == ReputationEvent.TRADE) {
-            this.gossips.add(entity.getUUID(), ReputationType.TRADING, 2);
+            this.gossips.add(entity.getUUID(), ReputationType.TRADING, 2, bukkitReputationEvent); // CraftBukkit - add change reason parameter
         } else if (reputationevent == ReputationEvent.VILLAGER_HURT) {
-            this.gossips.add(entity.getUUID(), ReputationType.MINOR_NEGATIVE, 25);
+            this.gossips.add(entity.getUUID(), ReputationType.MINOR_NEGATIVE, 25, bukkitReputationEvent); // CraftBukkit - add change reason parameter
         } else if (reputationevent == ReputationEvent.VILLAGER_KILLED) {
-            this.gossips.add(entity.getUUID(), ReputationType.MAJOR_NEGATIVE, 25);
+            this.gossips.add(entity.getUUID(), ReputationType.MAJOR_NEGATIVE, 25, bukkitReputationEvent); // CraftBukkit - add change reason parameter
         }
 
     }
@@ -963,7 +992,7 @@
     @Override
     public void startSleeping(BlockPosition blockposition) {
         super.startSleeping(blockposition);
-        this.brain.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.level().getGameTime());
+        this.brain.setMemory(MemoryModuleType.LAST_SLEPT, this.level().getGameTime()); // CraftBukkit - decompile error
         this.brain.eraseMemory(MemoryModuleType.WALK_TARGET);
         this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
     }
@@ -971,7 +1000,7 @@
     @Override
     public void stopSleeping() {
         super.stopSleeping();
-        this.brain.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.level().getGameTime());
+        this.brain.setMemory(MemoryModuleType.LAST_WOKEN, this.level().getGameTime()); // CraftBukkit - decompile error
     }
 
     private boolean golemSpawnConditionsMet(long i) {
