aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/entity/npc/Villager.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/npc/Villager.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/entity/npc/Villager.java.patch1032
1 files changed, 1032 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/npc/Villager.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/npc/Villager.java.patch
new file mode 100644
index 0000000000..4a2f676dd8
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/npc/Villager.java.patch
@@ -0,0 +1,1032 @@
+--- a/net/minecraft/world/entity/npc/Villager.java
++++ b/net/minecraft/world/entity/npc/Villager.java
+@@ -42,7 +42,7 @@
+ import net.minecraft.util.SpawnUtil;
+ import net.minecraft.world.Difficulty;
+ import net.minecraft.world.DifficultyInstance;
+-import net.minecraft.world.InteractionHand;
++import net.minecraft.world.EnumHand;
+ import net.minecraft.world.InteractionResult;
+ import net.minecraft.world.SimpleContainer;
+ import net.minecraft.world.damagesource.DamageSource;
+@@ -51,13 +51,13 @@
+ import net.minecraft.world.entity.AgeableMob;
+ import net.minecraft.world.entity.Entity;
+ import net.minecraft.world.entity.EntityType;
++import net.minecraft.world.entity.EnumMobSpawn;
+ import net.minecraft.world.entity.ExperienceOrb;
++import net.minecraft.world.entity.GroupDataEntity;
+ import net.minecraft.world.entity.LightningBolt;
+ import net.minecraft.world.entity.LivingEntity;
+ import net.minecraft.world.entity.Mob;
+-import net.minecraft.world.entity.MobSpawnType;
+ import net.minecraft.world.entity.ReputationEventHandler;
+-import net.minecraft.world.entity.SpawnGroupData;
+ import net.minecraft.world.entity.ai.Brain;
+ import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
+ import net.minecraft.world.entity.ai.attributes.Attributes;
+@@ -92,6 +92,13 @@
+ import net.minecraft.world.phys.AABB;
+ import org.slf4j.Logger;
+
++// CraftBukkit start
++import org.bukkit.Bukkit;
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.event.entity.EntityTransformEvent;
++import org.bukkit.event.entity.VillagerReplenishTradeEvent;
++// CraftBukkit end
++
+ public class Villager extends AbstractVillager implements ReputationEventHandler, VillagerDataHolder {
+
+ private static final Logger LOGGER = LogUtils.getLogger();
+@@ -125,85 +132,81 @@
+ private boolean assignProfessionWhenSpawned;
+ private static final ImmutableList<MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.HOME, MemoryModuleType.JOB_SITE, MemoryModuleType.POTENTIAL_JOB_SITE, MemoryModuleType.MEETING_POINT, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.VISIBLE_VILLAGER_BABIES, MemoryModuleType.NEAREST_PLAYERS, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.ITEM_PICKUP_COOLDOWN_TICKS, new MemoryModuleType[]{MemoryModuleType.WALK_TARGET, MemoryModuleType.LOOK_TARGET, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.BREED_TARGET, MemoryModuleType.PATH, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_BED, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.NEAREST_HOSTILE, MemoryModuleType.SECONDARY_JOB_SITE, MemoryModuleType.HIDING_PLACE, MemoryModuleType.HEARD_BELL_TIME, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.LAST_SLEPT, MemoryModuleType.LAST_WOKEN, MemoryModuleType.LAST_WORKED_AT_POI, MemoryModuleType.GOLEM_DETECTED_RECENTLY});
+ private static final ImmutableList<SensorType<? extends Sensor<? super Villager>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.NEAREST_BED, SensorType.HURT_BY, SensorType.VILLAGER_HOSTILES, SensorType.VILLAGER_BABIES, SensorType.SECONDARY_POIS, SensorType.GOLEM_DETECTED);
+- public static final Map<MemoryModuleType<GlobalPos>, BiPredicate<Villager, Holder<PoiType>>> POI_MEMORIES = ImmutableMap.of(MemoryModuleType.HOME, (villager, holder) -> {
++ public static final Map<MemoryModuleType<GlobalPos>, BiPredicate<Villager, Holder<PoiType>>> POI_MEMORIES = ImmutableMap.of(MemoryModuleType.HOME, (entityvillager, holder) -> {
+ return holder.is(PoiTypes.HOME);
+- }, MemoryModuleType.JOB_SITE, (villager, holder) -> {
+- return villager.getVillagerData().getProfession().heldJobSite().test(holder);
+- }, MemoryModuleType.POTENTIAL_JOB_SITE, (villager, holder) -> {
++ }, MemoryModuleType.JOB_SITE, (entityvillager, holder) -> {
++ return entityvillager.getVillagerData().getProfession().heldJobSite().test(holder);
++ }, MemoryModuleType.POTENTIAL_JOB_SITE, (entityvillager, holder) -> {
+ return VillagerProfession.ALL_ACQUIRABLE_JOBS.test(holder);
+- }, MemoryModuleType.MEETING_POINT, (villager, holder) -> {
++ }, MemoryModuleType.MEETING_POINT, (entityvillager, holder) -> {
+ return holder.is(PoiTypes.MEETING);
+ });
+
+- public Villager(EntityType<? extends Villager> entitytype, Level level) {
+- this(entitytype, level, VillagerType.PLAINS);
++ public Villager(EntityType<? extends Villager> entityType, Level level) {
++ this(entityType, level, VillagerType.PLAINS);
+ }
+
+- public Villager(EntityType<? extends Villager> entitytype, Level level, VillagerType villagertype) {
+- super(entitytype, level);
++ public Villager(EntityType<? extends Villager> entityType, Level level, VillagerType villagerType) {
++ super(entityType, level);
+ this.gossips = new GossipContainer();
+ ((GroundPathNavigation) this.getNavigation()).setCanOpenDoors(true);
+ this.getNavigation().setCanFloat(true);
+ this.setCanPickUpLoot(true);
+- this.setVillagerData(this.getVillagerData().setType(villagertype).setProfession(VillagerProfession.NONE));
++ this.setVillagerData(this.getVillagerData().setType(villagerType).setProfession(VillagerProfession.NONE));
+ }
+
+ @Override
+- @Override
+ public Brain<Villager> getBrain() {
+- return super.getBrain();
++ return (Brain<Villager>) super.getBrain(); // CraftBukkit - decompile error
+ }
+
+ @Override
+- @Override
+ protected Brain.Provider<Villager> brainProvider() {
+ return Brain.provider(Villager.MEMORY_TYPES, Villager.SENSOR_TYPES);
+ }
+
+ @Override
+- @Override
+ protected Brain<?> makeBrain(Dynamic<?> dynamic) {
+- Brain<Villager> brain = this.brainProvider().makeBrain(dynamic);
++ Brain<Villager> behaviorcontroller = this.brainProvider().makeBrain(dynamic);
+
+- this.registerBrainGoals(brain);
+- return brain;
++ this.registerBrainGoals(behaviorcontroller);
++ return behaviorcontroller;
+ }
+
+- public void refreshBrain(ServerLevel serverlevel) {
+- Brain<Villager> brain = this.getBrain();
++ public void refreshBrain(ServerLevel serverLevel) {
++ Brain<Villager> behaviorcontroller = this.getBrain();
+
+- brain.stopAll(serverlevel, this);
+- this.brain = brain.copyWithoutBehaviors();
++ behaviorcontroller.stopAll(serverLevel, this);
++ this.brain = behaviorcontroller.copyWithoutBehaviors();
+ this.registerBrainGoals(this.getBrain());
+ }
+
+- private void registerBrainGoals(Brain<Villager> brain) {
++ private void registerBrainGoals(Brain<Villager> villagerBrain) {
+ VillagerProfession villagerprofession = this.getVillagerData().getProfession();
+
+ if (this.isBaby()) {
+- brain.setSchedule(Schedule.VILLAGER_BABY);
+- brain.addActivity(Activity.PLAY, VillagerGoalPackages.getPlayPackage(0.5F));
++ villagerBrain.setSchedule(Schedule.VILLAGER_BABY);
++ villagerBrain.addActivity(Activity.PLAY, VillagerGoalPackages.getPlayPackage(0.5F));
+ } else {
+- brain.setSchedule(Schedule.VILLAGER_DEFAULT);
+- brain.addActivityWithConditions(Activity.WORK, VillagerGoalPackages.getWorkPackage(villagerprofession, 0.5F), ImmutableSet.of(Pair.of(MemoryModuleType.JOB_SITE, MemoryStatus.VALUE_PRESENT)));
++ villagerBrain.setSchedule(Schedule.VILLAGER_DEFAULT);
++ villagerBrain.addActivityWithConditions(Activity.WORK, VillagerGoalPackages.getWorkPackage(villagerprofession, 0.5F), ImmutableSet.of(Pair.of(MemoryModuleType.JOB_SITE, MemoryStatus.VALUE_PRESENT)));
+ }
+
+- brain.addActivity(Activity.CORE, VillagerGoalPackages.getCorePackage(villagerprofession, 0.5F));
+- brain.addActivityWithConditions(Activity.MEET, VillagerGoalPackages.getMeetPackage(villagerprofession, 0.5F), ImmutableSet.of(Pair.of(MemoryModuleType.MEETING_POINT, MemoryStatus.VALUE_PRESENT)));
+- brain.addActivity(Activity.REST, VillagerGoalPackages.getRestPackage(villagerprofession, 0.5F));
+- brain.addActivity(Activity.IDLE, VillagerGoalPackages.getIdlePackage(villagerprofession, 0.5F));
+- brain.addActivity(Activity.PANIC, VillagerGoalPackages.getPanicPackage(villagerprofession, 0.5F));
+- brain.addActivity(Activity.PRE_RAID, VillagerGoalPackages.getPreRaidPackage(villagerprofession, 0.5F));
+- brain.addActivity(Activity.RAID, VillagerGoalPackages.getRaidPackage(villagerprofession, 0.5F));
+- brain.addActivity(Activity.HIDE, VillagerGoalPackages.getHidePackage(villagerprofession, 0.5F));
+- brain.setCoreActivities(ImmutableSet.of(Activity.CORE));
+- brain.setDefaultActivity(Activity.IDLE);
+- brain.setActiveActivityIfPossible(Activity.IDLE);
+- brain.updateActivityFromSchedule(this.level().getDayTime(), this.level().getGameTime());
++ villagerBrain.addActivity(Activity.CORE, VillagerGoalPackages.getCorePackage(villagerprofession, 0.5F));
++ villagerBrain.addActivityWithConditions(Activity.MEET, VillagerGoalPackages.getMeetPackage(villagerprofession, 0.5F), ImmutableSet.of(Pair.of(MemoryModuleType.MEETING_POINT, MemoryStatus.VALUE_PRESENT)));
++ villagerBrain.addActivity(Activity.REST, VillagerGoalPackages.getRestPackage(villagerprofession, 0.5F));
++ villagerBrain.addActivity(Activity.IDLE, VillagerGoalPackages.getIdlePackage(villagerprofession, 0.5F));
++ villagerBrain.addActivity(Activity.PANIC, VillagerGoalPackages.getPanicPackage(villagerprofession, 0.5F));
++ villagerBrain.addActivity(Activity.PRE_RAID, VillagerGoalPackages.getPreRaidPackage(villagerprofession, 0.5F));
++ villagerBrain.addActivity(Activity.RAID, VillagerGoalPackages.getRaidPackage(villagerprofession, 0.5F));
++ villagerBrain.addActivity(Activity.HIDE, VillagerGoalPackages.getHidePackage(villagerprofession, 0.5F));
++ villagerBrain.setCoreActivities(ImmutableSet.of(Activity.CORE));
++ villagerBrain.setDefaultActivity(Activity.IDLE);
++ villagerBrain.setActiveActivityIfPossible(Activity.IDLE);
++ villagerBrain.updateActivityFromSchedule(this.level().getDayTime(), this.level().getGameTime());
+ }
+
+ @Override
+- @Override
+ protected void ageBoundaryReached() {
+ super.ageBoundaryReached();
+ if (this.level() instanceof ServerLevel) {
+@@ -221,7 +224,6 @@
+ }
+
+ @Override
+- @Override
+ protected void customServerAiStep() {
+ this.level().getProfiler().push("villagerBrain");
+ this.getBrain().tick((ServerLevel) this.level(), this);
+@@ -238,7 +240,7 @@
+ this.increaseProfessionLevelOnUpdate = false;
+ }
+
+- this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 200, 0));
++ this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.VILLAGER_TRADE); // CraftBukkit
+ }
+ }
+
+@@ -264,7 +266,6 @@
+ }
+
+ @Override
+- @Override
+ public void tick() {
+ super.tick();
+ if (this.getUnhappyCounter() > 0) {
+@@ -275,9 +276,8 @@
+ }
+
+ @Override
+- @Override
+- public InteractionResult mobInteract(Player player, InteractionHand interactionhand) {
+- ItemStack itemstack = player.getItemInHand(interactionhand);
++ public InteractionResult mobInteract(Player player, EnumHand hand) {
++ ItemStack itemstack = player.getItemInHand(hand);
+
+ if (!itemstack.is(Items.VILLAGER_SPAWN_EGG) && this.isAlive() && !this.isTrading() && !this.isSleeping()) {
+ if (this.isBaby()) {
+@@ -286,7 +286,7 @@
+ } else {
+ boolean flag = this.getOffers().isEmpty();
+
+- if (interactionhand == InteractionHand.MAIN_HAND) {
++ if (hand == EnumHand.MAIN_HAND) {
+ if (flag && !this.level().isClientSide) {
+ this.setUnhappy();
+ }
+@@ -305,11 +305,11 @@
+ }
+ }
+ } else {
+- return super.mobInteract(player, interactionhand);
++ return super.mobInteract(player, hand);
+ }
+ }
+
+- private void setUnhappy() {
++ public void setUnhappy() {
+ this.setUnhappyCounter(40);
+ if (!this.level().isClientSide()) {
+ this.playSound(SoundEvents.VILLAGER_NO, this.getSoundVolume(), this.getVoicePitch());
+@@ -324,7 +324,6 @@
+ }
+
+ @Override
+- @Override
+ public void setTradingPlayer(@Nullable Player player) {
+ boolean flag = this.getTradingPlayer() != null && player == null;
+
+@@ -336,7 +335,6 @@
+ }
+
+ @Override
+- @Override
+ protected void stopTrading() {
+ super.stopTrading();
+ this.resetSpecialPrices();
+@@ -346,21 +344,19 @@
+ Iterator iterator = this.getOffers().iterator();
+
+ while (iterator.hasNext()) {
+- MerchantOffer merchantoffer = (MerchantOffer) iterator.next();
++ MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
+
+- merchantoffer.resetSpecialPriceDiff();
++ merchantrecipe.resetSpecialPriceDiff();
+ }
+
+ }
+
+ @Override
+- @Override
+ public boolean canRestock() {
+ return true;
+ }
+
+ @Override
+- @Override
+ public boolean isClientSide() {
+ return this.level().isClientSide;
+ }
+@@ -370,9 +366,15 @@
+ Iterator iterator = this.getOffers().iterator();
+
+ while (iterator.hasNext()) {
+- MerchantOffer merchantoffer = (MerchantOffer) iterator.next();
++ MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
+
+- merchantoffer.resetUses();
++ // CraftBukkit start
++ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((org.bukkit.entity.Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
++ Bukkit.getPluginManager().callEvent(event);
++ if (!event.isCancelled()) {
++ merchantrecipe.resetUses();
++ }
++ // CraftBukkit end
+ }
+
+ this.resendOffersToTradingPlayer();
+@@ -381,11 +383,11 @@
+ }
+
+ private void resendOffersToTradingPlayer() {
+- MerchantOffers merchantoffers = this.getOffers();
+- Player player = this.getTradingPlayer();
++ MerchantOffers merchantrecipelist = this.getOffers();
++ Player entityhuman = this.getTradingPlayer();
+
+- if (player != null && !merchantoffers.isEmpty()) {
+- player.sendMerchantOffers(player.containerMenu.containerId, merchantoffers, this.getVillagerData().getLevel(), this.getVillagerXp(), this.showProgressBar(), this.canRestock());
++ if (entityhuman != null && !merchantrecipelist.isEmpty()) {
++ entityhuman.sendMerchantOffers(entityhuman.containerMenu.containerId, merchantrecipelist, this.getVillagerData().getLevel(), this.getVillagerXp(), this.showProgressBar(), this.canRestock());
+ }
+
+ }
+@@ -393,15 +395,15 @@
+ private boolean needsToRestock() {
+ Iterator iterator = this.getOffers().iterator();
+
+- MerchantOffer merchantoffer;
++ MerchantOffer merchantrecipe;
+
+ do {
+ if (!iterator.hasNext()) {
+ return false;
+ }
+
+- merchantoffer = (MerchantOffer) iterator.next();
+- } while (!merchantoffer.needsRestock());
++ merchantrecipe = (MerchantOffer) iterator.next();
++ } while (!merchantrecipe.needsRestock());
+
+ return true;
+ }
+@@ -439,9 +441,15 @@
+ Iterator iterator = this.getOffers().iterator();
+
+ while (iterator.hasNext()) {
+- MerchantOffer merchantoffer = (MerchantOffer) iterator.next();
++ MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
+
+- merchantoffer.resetUses();
++ // CraftBukkit start
++ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((org.bukkit.entity.Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
++ Bukkit.getPluginManager().callEvent(event);
++ if (!event.isCancelled()) {
++ merchantrecipe.resetUses();
++ }
++ // CraftBukkit end
+ }
+ }
+
+@@ -456,9 +464,9 @@
+ Iterator iterator = this.getOffers().iterator();
+
+ while (iterator.hasNext()) {
+- MerchantOffer merchantoffer = (MerchantOffer) iterator.next();
++ MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
+
+- merchantoffer.updateDemand();
++ merchantrecipe.updateDemand();
+ }
+
+ }
+@@ -470,157 +478,147 @@
+ Iterator iterator = this.getOffers().iterator();
+
+ while (iterator.hasNext()) {
+- MerchantOffer merchantoffer = (MerchantOffer) iterator.next();
++ MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
+
+- merchantoffer.addToSpecialPriceDiff(-Mth.floor((float) i * merchantoffer.getPriceMultiplier()));
++ merchantrecipe.addToSpecialPriceDiff(-Mth.floor((float) i * merchantrecipe.getPriceMultiplier()));
+ }
+ }
+
+ if (player.hasEffect(MobEffects.HERO_OF_THE_VILLAGE)) {
+- MobEffectInstance mobeffectinstance = player.getEffect(MobEffects.HERO_OF_THE_VILLAGE);
+- int j = mobeffectinstance.getAmplifier();
++ MobEffectInstance mobeffect = player.getEffect(MobEffects.HERO_OF_THE_VILLAGE);
++ int j = mobeffect.getAmplifier();
+ Iterator iterator1 = this.getOffers().iterator();
+
+ while (iterator1.hasNext()) {
+- MerchantOffer merchantoffer1 = (MerchantOffer) iterator1.next();
++ MerchantOffer merchantrecipe1 = (MerchantOffer) iterator1.next();
+ double d0 = 0.3D + 0.0625D * (double) j;
+- int k = (int) Math.floor(d0 * (double) merchantoffer1.getBaseCostA().getCount());
++ int k = (int) Math.floor(d0 * (double) merchantrecipe1.getBaseCostA().getCount());
+
+- merchantoffer1.addToSpecialPriceDiff(-Math.max(k, 1));
++ merchantrecipe1.addToSpecialPriceDiff(-Math.max(k, 1));
+ }
+ }
+
+ }
+
+ @Override
+- @Override
+ protected void defineSynchedData() {
+ super.defineSynchedData();
+ this.entityData.define(Villager.DATA_VILLAGER_DATA, new VillagerData(VillagerType.PLAINS, VillagerProfession.NONE, 1));
+ }
+
+ @Override
+- @Override
+- public void addAdditionalSaveData(CompoundTag compoundtag) {
+- super.addAdditionalSaveData(compoundtag);
+- DataResult dataresult = VillagerData.CODEC.encodeStart(NbtOps.INSTANCE, this.getVillagerData());
++ public void addAdditionalSaveData(CompoundTag compound) {
++ super.addAdditionalSaveData(compound);
++ DataResult<Tag> dataresult = VillagerData.CODEC.encodeStart(NbtOps.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error
+ Logger logger = Villager.LOGGER;
+
+ Objects.requireNonNull(logger);
+- dataresult.resultOrPartial(logger::error).ifPresent((tag) -> {
+- compoundtag.put("VillagerData", tag);
++ dataresult.resultOrPartial(logger::error).ifPresent((nbtbase) -> {
++ compound.put("VillagerData", nbtbase);
+ });
+- compoundtag.putByte("FoodLevel", (byte) this.foodLevel);
+- compoundtag.put("Gossips", (Tag) this.gossips.store(NbtOps.INSTANCE));
+- compoundtag.putInt("Xp", this.villagerXp);
+- compoundtag.putLong("LastRestock", this.lastRestockGameTime);
+- compoundtag.putLong("LastGossipDecay", this.lastGossipDecayTime);
+- compoundtag.putInt("RestocksToday", this.numberOfRestocksToday);
++ compound.putByte("FoodLevel", (byte) this.foodLevel);
++ compound.put("Gossips", (Tag) this.gossips.store(NbtOps.INSTANCE));
++ compound.putInt("Xp", this.villagerXp);
++ compound.putLong("LastRestock", this.lastRestockGameTime);
++ compound.putLong("LastGossipDecay", this.lastGossipDecayTime);
++ compound.putInt("RestocksToday", this.numberOfRestocksToday);
+ if (this.assignProfessionWhenSpawned) {
+- compoundtag.putBoolean("AssignProfessionWhenSpawned", true);
++ compound.putBoolean("AssignProfessionWhenSpawned", true);
+ }
+
+ }
+
+ @Override
+- @Override
+- public void readAdditionalSaveData(CompoundTag compoundtag) {
+- super.readAdditionalSaveData(compoundtag);
+- if (compoundtag.contains("VillagerData", 10)) {
+- DataResult<VillagerData> dataresult = VillagerData.CODEC.parse(new Dynamic(NbtOps.INSTANCE, compoundtag.get("VillagerData")));
++ public void readAdditionalSaveData(CompoundTag compound) {
++ super.readAdditionalSaveData(compound);
++ if (compound.contains("VillagerData", 10)) {
++ DataResult<VillagerData> dataresult = VillagerData.CODEC.parse(new Dynamic(NbtOps.INSTANCE, compound.get("VillagerData")));
+ Logger logger = Villager.LOGGER;
+
+ Objects.requireNonNull(logger);
+ dataresult.resultOrPartial(logger::error).ifPresent(this::setVillagerData);
+ }
+
+- if (compoundtag.contains("Offers", 10)) {
+- this.offers = new MerchantOffers(compoundtag.getCompound("Offers"));
++ if (compound.contains("Offers", 10)) {
++ this.offers = new MerchantOffers(compound.getCompound("Offers"));
+ }
+
+- if (compoundtag.contains("FoodLevel", 1)) {
+- this.foodLevel = compoundtag.getByte("FoodLevel");
++ if (compound.contains("FoodLevel", 1)) {
++ this.foodLevel = compound.getByte("FoodLevel");
+ }
+
+- ListTag listtag = compoundtag.getList("Gossips", 10);
++ ListTag nbttaglist = compound.getList("Gossips", 10);
+
+- this.gossips.update(new Dynamic(NbtOps.INSTANCE, listtag));
+- if (compoundtag.contains("Xp", 3)) {
+- this.villagerXp = compoundtag.getInt("Xp");
++ this.gossips.update(new Dynamic(NbtOps.INSTANCE, nbttaglist));
++ if (compound.contains("Xp", 3)) {
++ this.villagerXp = compound.getInt("Xp");
+ }
+
+- this.lastRestockGameTime = compoundtag.getLong("LastRestock");
+- this.lastGossipDecayTime = compoundtag.getLong("LastGossipDecay");
++ this.lastRestockGameTime = compound.getLong("LastRestock");
++ this.lastGossipDecayTime = compound.getLong("LastGossipDecay");
+ this.setCanPickUpLoot(true);
+ if (this.level() instanceof ServerLevel) {
+ this.refreshBrain((ServerLevel) this.level());
+ }
+
+- this.numberOfRestocksToday = compoundtag.getInt("RestocksToday");
+- if (compoundtag.contains("AssignProfessionWhenSpawned")) {
+- this.assignProfessionWhenSpawned = compoundtag.getBoolean("AssignProfessionWhenSpawned");
++ this.numberOfRestocksToday = compound.getInt("RestocksToday");
++ if (compound.contains("AssignProfessionWhenSpawned")) {
++ this.assignProfessionWhenSpawned = compound.getBoolean("AssignProfessionWhenSpawned");
+ }
+
+ }
+
+ @Override
+- @Override
+- public boolean removeWhenFarAway(double d0) {
++ public boolean removeWhenFarAway(double distanceToClosestPlayer) {
+ return false;
+ }
+
+ @Nullable
+ @Override
+- @Override
+ protected SoundEvent getAmbientSound() {
+ return this.isSleeping() ? null : (this.isTrading() ? SoundEvents.VILLAGER_TRADE : SoundEvents.VILLAGER_AMBIENT);
+ }
+
+ @Override
+- @Override
+- protected SoundEvent getHurtSound(DamageSource damagesource) {
++ protected SoundEvent getHurtSound(DamageSource damageSource) {
+ return SoundEvents.VILLAGER_HURT;
+ }
+
+ @Override
+- @Override
+ protected SoundEvent getDeathSound() {
+ return SoundEvents.VILLAGER_DEATH;
+ }
+
+ public void playWorkSound() {
+- SoundEvent soundevent = this.getVillagerData().getProfession().workSound();
++ SoundEvent soundeffect = this.getVillagerData().getProfession().workSound();
+
+- if (soundevent != null) {
+- this.playSound(soundevent, this.getSoundVolume(), this.getVoicePitch());
++ if (soundeffect != null) {
++ this.playSound(soundeffect, this.getSoundVolume(), this.getVoicePitch());
+ }
+
+ }
+
+ @Override
+- @Override
+- public void setVillagerData(VillagerData villagerdata) {
++ public void setVillagerData(VillagerData data) {
+ VillagerData villagerdata1 = this.getVillagerData();
+
+- if (villagerdata1.getProfession() != villagerdata.getProfession()) {
++ if (villagerdata1.getProfession() != data.getProfession()) {
+ this.offers = null;
+ }
+
+- this.entityData.set(Villager.DATA_VILLAGER_DATA, villagerdata);
++ this.entityData.set(Villager.DATA_VILLAGER_DATA, data);
+ }
+
+ @Override
+- @Override
+ public VillagerData getVillagerData() {
+ return (VillagerData) this.entityData.get(Villager.DATA_VILLAGER_DATA);
+ }
+
+ @Override
+- @Override
+- protected void rewardTradeXp(MerchantOffer merchantoffer) {
++ protected void rewardTradeXp(MerchantOffer offer) {
+ int i = 3 + this.random.nextInt(4);
+
+- this.villagerXp += merchantoffer.getXp();
++ this.villagerXp += offer.getXp();
+ this.lastTradedPlayer = this.getTradingPlayer();
+ if (this.shouldIncreaseLevel()) {
+ this.updateMerchantTimer = 40;
+@@ -628,14 +626,14 @@
+ i += 5;
+ }
+
+- if (merchantoffer.shouldRewardExp()) {
++ if (offer.shouldRewardExp()) {
+ this.level().addFreshEntity(new ExperienceOrb(this.level(), this.getX(), this.getY() + 0.5D, this.getZ(), i));
+ }
+
+ }
+
+- public void setChasing(boolean flag) {
+- this.chasing = flag;
++ public void setChasing(boolean chasing) {
++ this.chasing = chasing;
+ }
+
+ public boolean isChasing() {
+@@ -643,72 +641,70 @@
+ }
+
+ @Override
+- @Override
+- public void setLastHurtByMob(@Nullable LivingEntity livingentity) {
+- if (livingentity != null && this.level() instanceof ServerLevel) {
+- ((ServerLevel) this.level()).onReputationEvent(ReputationEventType.VILLAGER_HURT, livingentity, this);
+- if (this.isAlive() && livingentity instanceof Player) {
++ public void setLastHurtByMob(@Nullable LivingEntity livingBase) {
++ if (livingBase != null && this.level() instanceof ServerLevel) {
++ ((ServerLevel) this.level()).onReputationEvent(ReputationEventType.VILLAGER_HURT, livingBase, this);
++ if (this.isAlive() && livingBase instanceof Player) {
+ this.level().broadcastEntityEvent(this, (byte) 13);
+ }
+ }
+
+- super.setLastHurtByMob(livingentity);
++ super.setLastHurtByMob(livingBase);
+ }
+
+ @Override
+- @Override
+- public void die(DamageSource damagesource) {
+- Villager.LOGGER.info("Villager {} died, message: '{}'", this, damagesource.getLocalizedDeathMessage(this).getString());
+- Entity entity = damagesource.getEntity();
++ public void die(DamageSource cause) {
++ Villager.LOGGER.info("Villager {} died, message: '{}'", this, cause.getLocalizedDeathMessage(this).getString());
++ Entity entity = cause.getEntity();
+
+ if (entity != null) {
+ this.tellWitnessesThatIWasMurdered(entity);
+ }
+
+ this.releaseAllPois();
+- super.die(damagesource);
++ super.die(cause);
+ }
+
+- private void releaseAllPois() {
++ public void releaseAllPois() {
+ this.releasePoi(MemoryModuleType.HOME);
+ this.releasePoi(MemoryModuleType.JOB_SITE);
+ this.releasePoi(MemoryModuleType.POTENTIAL_JOB_SITE);
+ this.releasePoi(MemoryModuleType.MEETING_POINT);
+ }
+
+- private void tellWitnessesThatIWasMurdered(Entity entity) {
+- Level level = this.level();
++ private void tellWitnessesThatIWasMurdered(Entity murderer) {
++ Level world = this.level();
+
+- if (level instanceof ServerLevel) {
+- ServerLevel serverlevel = (ServerLevel) level;
++ if (world instanceof ServerLevel) {
++ ServerLevel worldserver = (ServerLevel) world;
+ Optional optional = this.brain.getMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES);
+
+ if (!optional.isEmpty()) {
+ NearestVisibleLivingEntities nearestvisiblelivingentities = (NearestVisibleLivingEntities) optional.get();
+
+ Objects.requireNonNull(ReputationEventHandler.class);
+- nearestvisiblelivingentities.findAll(ReputationEventHandler.class::isInstance).forEach((livingentity) -> {
+- serverlevel.onReputationEvent(ReputationEventType.VILLAGER_KILLED, entity, (ReputationEventHandler) livingentity);
++ nearestvisiblelivingentities.findAll(ReputationEventHandler.class::isInstance).forEach((entityliving) -> {
++ worldserver.onReputationEvent(ReputationEventType.VILLAGER_KILLED, murderer, (ReputationEventHandler) entityliving);
+ });
+ }
+ }
+ }
+
+- public void releasePoi(MemoryModuleType<GlobalPos> memorymoduletype) {
++ public void releasePoi(MemoryModuleType<GlobalPos> moduleType) {
+ if (this.level() instanceof ServerLevel) {
+ MinecraftServer minecraftserver = ((ServerLevel) this.level()).getServer();
+
+- this.brain.getMemory(memorymoduletype).ifPresent((globalpos) -> {
+- ServerLevel serverlevel = minecraftserver.getLevel(globalpos.dimension());
++ this.brain.getMemory(moduleType).ifPresent((globalpos) -> {
++ ServerLevel worldserver = minecraftserver.getLevel(globalpos.dimension());
+
+- if (serverlevel != null) {
+- PoiManager poimanager = serverlevel.getPoiManager();
+- Optional<Holder<PoiType>> optional = poimanager.getType(globalpos.pos());
+- BiPredicate<Villager, Holder<PoiType>> bipredicate = (BiPredicate) Villager.POI_MEMORIES.get(memorymoduletype);
++ if (worldserver != null) {
++ PoiManager villageplace = worldserver.getPoiManager();
++ Optional<Holder<PoiType>> optional = villageplace.getType(globalpos.pos());
++ BiPredicate<Villager, Holder<PoiType>> bipredicate = (BiPredicate) Villager.POI_MEMORIES.get(moduleType);
+
+ if (optional.isPresent() && bipredicate.test(this, (Holder) optional.get())) {
+- poimanager.release(globalpos.pos());
+- DebugPackets.sendPoiTicketCountPacket(serverlevel, globalpos.pos());
++ villageplace.release(globalpos.pos());
++ DebugPackets.sendPoiTicketCountPacket(worldserver, globalpos.pos());
+ }
+
+ }
+@@ -717,7 +713,6 @@
+ }
+
+ @Override
+- @Override
+ public boolean canBreed() {
+ return this.foodLevel + this.countFoodPointsInInventory() >= 12 && !this.isSleeping() && this.getAge() == 0;
+ }
+@@ -752,13 +747,13 @@
+ }
+
+ public int getPlayerReputation(Player player) {
+- return this.gossips.getReputation(player.getUUID(), (gossiptype) -> {
++ return this.gossips.getReputation(player.getUUID(), (reputationtype) -> {
+ return true;
+ });
+ }
+
+- private void digestFood(int i) {
+- this.foodLevel -= i;
++ private void digestFood(int qty) {
++ this.foodLevel -= qty;
+ }
+
+ public void eatAndDigestFood() {
+@@ -766,8 +761,8 @@
+ this.digestFood(12);
+ }
+
+- public void setOffers(MerchantOffers merchantoffers) {
+- this.offers = merchantoffers;
++ public void setOffers(MerchantOffers offers) {
++ this.offers = offers;
+ }
+
+ private boolean shouldIncreaseLevel() {
+@@ -776,13 +771,12 @@
+ return VillagerData.canLevelUp(i) && this.villagerXp >= VillagerData.getMaxXpPerLevel(i);
+ }
+
+- private void increaseMerchantCareer() {
++ public void increaseMerchantCareer() {
+ this.setVillagerData(this.getVillagerData().setLevel(this.getVillagerData().getLevel() + 1));
+ this.updateTrades();
+ }
+
+ @Override
+- @Override
+ protected Component getTypeName() {
+ String s = this.getType().getDescriptionId();
+
+@@ -790,103 +784,102 @@
+ }
+
+ @Override
+- @Override
+- public void handleEntityEvent(byte b0) {
+- if (b0 == 12) {
++ public void handleEntityEvent(byte id) {
++ if (id == 12) {
+ this.addParticlesAroundSelf(ParticleTypes.HEART);
+- } else if (b0 == 13) {
++ } else if (id == 13) {
+ this.addParticlesAroundSelf(ParticleTypes.ANGRY_VILLAGER);
+- } else if (b0 == 14) {
++ } else if (id == 14) {
+ this.addParticlesAroundSelf(ParticleTypes.HAPPY_VILLAGER);
+- } else if (b0 == 42) {
++ } else if (id == 42) {
+ this.addParticlesAroundSelf(ParticleTypes.SPLASH);
+ } else {
+- super.handleEntityEvent(b0);
++ super.handleEntityEvent(id);
+ }
+
+ }
+
+ @Nullable
+ @Override
+- @Override
+- public SpawnGroupData finalizeSpawn(ServerLevelAccessor serverlevelaccessor, DifficultyInstance difficultyinstance, MobSpawnType mobspawntype, @Nullable SpawnGroupData spawngroupdata, @Nullable CompoundTag compoundtag) {
+- if (mobspawntype == MobSpawnType.BREEDING) {
++ public GroupDataEntity finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, EnumMobSpawn reason, @Nullable GroupDataEntity spawnData, @Nullable CompoundTag dataTag) {
++ if (reason == EnumMobSpawn.BREEDING) {
+ this.setVillagerData(this.getVillagerData().setProfession(VillagerProfession.NONE));
+ }
+
+- if (mobspawntype == MobSpawnType.COMMAND || mobspawntype == MobSpawnType.SPAWN_EGG || MobSpawnType.isSpawner(mobspawntype) || mobspawntype == MobSpawnType.DISPENSER) {
+- this.setVillagerData(this.getVillagerData().setType(VillagerType.byBiome(serverlevelaccessor.getBiome(this.blockPosition()))));
++ if (reason == EnumMobSpawn.COMMAND || reason == EnumMobSpawn.SPAWN_EGG || EnumMobSpawn.isSpawner(reason) || reason == EnumMobSpawn.DISPENSER) {
++ this.setVillagerData(this.getVillagerData().setType(VillagerType.byBiome(level.getBiome(this.blockPosition()))));
+ }
+
+- if (mobspawntype == MobSpawnType.STRUCTURE) {
++ if (reason == EnumMobSpawn.STRUCTURE) {
+ this.assignProfessionWhenSpawned = true;
+ }
+
+- return super.finalizeSpawn(serverlevelaccessor, difficultyinstance, mobspawntype, spawngroupdata, compoundtag);
++ return super.finalizeSpawn(level, difficulty, reason, spawnData, dataTag);
+ }
+
+ @Nullable
+ @Override
+- @Override
+- public Villager getBreedOffspring(ServerLevel serverlevel, AgeableMob ageablemob) {
++ public Villager getBreedOffspring(ServerLevel level, AgeableMob otherParent) {
+ double d0 = this.random.nextDouble();
+ VillagerType villagertype;
+
+ if (d0 < 0.5D) {
+- villagertype = VillagerType.byBiome(serverlevel.getBiome(this.blockPosition()));
++ villagertype = VillagerType.byBiome(level.getBiome(this.blockPosition()));
+ } else if (d0 < 0.75D) {
+ villagertype = this.getVillagerData().getType();
+ } else {
+- villagertype = ((Villager) ageablemob).getVillagerData().getType();
++ villagertype = ((Villager) otherParent).getVillagerData().getType();
+ }
+
+- Villager villager = new Villager(EntityType.VILLAGER, serverlevel, villagertype);
++ Villager entityvillager = new Villager(EntityType.VILLAGER, level, villagertype);
+
+- villager.finalizeSpawn(serverlevel, serverlevel.getCurrentDifficultyAt(villager.blockPosition()), MobSpawnType.BREEDING, (SpawnGroupData) null, (CompoundTag) null);
+- return villager;
++ entityvillager.finalizeSpawn(level, level.getCurrentDifficultyAt(entityvillager.blockPosition()), EnumMobSpawn.BREEDING, (GroupDataEntity) null, (CompoundTag) null);
++ return entityvillager;
+ }
+
+ @Override
+- @Override
+- public void thunderHit(ServerLevel serverlevel, LightningBolt lightningbolt) {
+- if (serverlevel.getDifficulty() != Difficulty.PEACEFUL) {
+- Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightningbolt);
+- Witch witch = (Witch) EntityType.WITCH.create(serverlevel);
++ public void thunderHit(ServerLevel level, LightningBolt lightning) {
++ if (level.getDifficulty() != Difficulty.PEACEFUL) {
++ Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightning);
++ Witch entitywitch = (Witch) EntityType.WITCH.create(level);
+
+- if (witch != null) {
+- witch.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
+- witch.finalizeSpawn(serverlevel, serverlevel.getCurrentDifficultyAt(witch.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData) null, (CompoundTag) null);
+- witch.setNoAi(this.isNoAi());
++ if (entitywitch != null) {
++ entitywitch.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
++ entitywitch.finalizeSpawn(level, level.getCurrentDifficultyAt(entitywitch.blockPosition()), EnumMobSpawn.CONVERSION, (GroupDataEntity) null, (CompoundTag) null);
++ entitywitch.setNoAi(this.isNoAi());
+ if (this.hasCustomName()) {
+- witch.setCustomName(this.getCustomName());
+- witch.setCustomNameVisible(this.isCustomNameVisible());
++ entitywitch.setCustomName(this.getCustomName());
++ entitywitch.setCustomNameVisible(this.isCustomNameVisible());
+ }
+
+- witch.setPersistenceRequired();
+- serverlevel.addFreshEntityWithPassengers(witch);
++ entitywitch.setPersistenceRequired();
++ // CraftBukkit start
++ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
++ return;
++ }
++ level.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
++ // CraftBukkit end
+ this.releaseAllPois();
+ this.discard();
+ } else {
+- super.thunderHit(serverlevel, lightningbolt);
++ super.thunderHit(level, lightning);
+ }
+ } else {
+- super.thunderHit(serverlevel, lightningbolt);
++ super.thunderHit(level, lightning);
+ }
+
+ }
+
+ @Override
+- @Override
+- protected void pickUpItem(ItemEntity itementity) {
+- InventoryCarrier.pickUpItem(this, this, itementity);
++ protected void pickUpItem(ItemEntity itemEntity) {
++ InventoryCarrier.pickUpItem(this, this, itemEntity);
+ }
+
+ @Override
+- @Override
+- public boolean wantsToPickUp(ItemStack itemstack) {
+- Item item = itemstack.getItem();
++ public boolean wantsToPickUp(ItemStack stack) {
++ Item item = stack.getItem();
+
+- return (Villager.WANTED_ITEMS.contains(item) || this.getVillagerData().getProfession().requestedItems().contains(item)) && this.getInventory().canAddItem(itemstack);
++ return (Villager.WANTED_ITEMS.contains(item) || this.getVillagerData().getProfession().requestedItems().contains(item)) && this.getInventory().canAddItem(stack);
+ }
+
+ public boolean hasExcessFood() {
+@@ -898,10 +891,10 @@
+ }
+
+ private int countFoodPointsInInventory() {
+- SimpleContainer simplecontainer = this.getInventory();
++ SimpleContainer inventorysubcontainer = this.getInventory();
+
+ return Villager.FOOD_POINTS.entrySet().stream().mapToInt((entry) -> {
+- return simplecontainer.countItem((Item) entry.getKey()) * (Integer) entry.getValue();
++ return inventorysubcontainer.countItem((Item) entry.getKey()) * (Integer) entry.getValue();
+ }).sum();
+ }
+
+@@ -912,7 +905,6 @@
+ }
+
+ @Override
+- @Override
+ protected void updateTrades() {
+ VillagerData villagerdata = this.getVillagerData();
+ Int2ObjectMap int2objectmap;
+@@ -926,22 +918,22 @@
+ }
+
+ if (int2objectmap != null && !int2objectmap.isEmpty()) {
+- VillagerTrades.ItemListing[] avillagertrades_itemlisting = (VillagerTrades.ItemListing[]) int2objectmap.get(villagerdata.getLevel());
++ VillagerTrades.ItemListing[] avillagertrades_imerchantrecipeoption = (VillagerTrades.ItemListing[]) int2objectmap.get(villagerdata.getLevel());
+
+- if (avillagertrades_itemlisting != null) {
+- MerchantOffers merchantoffers = this.getOffers();
++ if (avillagertrades_imerchantrecipeoption != null) {
++ MerchantOffers merchantrecipelist = this.getOffers();
+
+- this.addOffersFromItemListings(merchantoffers, avillagertrades_itemlisting, 2);
++ this.addOffersFromItemListings(merchantrecipelist, avillagertrades_imerchantrecipeoption, 2);
+ }
+ }
+ }
+
+- public void gossip(ServerLevel serverlevel, Villager villager, long i) {
+- if ((i < this.lastGossipTime || i >= this.lastGossipTime + 1200L) && (i < villager.lastGossipTime || i >= villager.lastGossipTime + 1200L)) {
+- this.gossips.transferFrom(villager.gossips, this.random, 10);
+- this.lastGossipTime = i;
+- villager.lastGossipTime = i;
+- this.spawnGolemIfNeeded(serverlevel, i, 5);
++ public void gossip(ServerLevel serverLevel, Villager target, long gameTime) {
++ if ((gameTime < this.lastGossipTime || gameTime >= this.lastGossipTime + 1200L) && (gameTime < target.lastGossipTime || gameTime >= target.lastGossipTime + 1200L)) {
++ this.gossips.transferFrom(target.gossips, this.random, 10);
++ this.lastGossipTime = gameTime;
++ target.lastGossipTime = gameTime;
++ this.spawnGolemIfNeeded(serverLevel, gameTime, 5);
+ }
+ }
+
+@@ -956,50 +948,48 @@
+ }
+ }
+
+- public void spawnGolemIfNeeded(ServerLevel serverlevel, long i, int j) {
+- if (this.wantsToSpawnGolem(i)) {
+- AABB aabb = this.getBoundingBox().inflate(10.0D, 10.0D, 10.0D);
+- List<Villager> list = serverlevel.getEntitiesOfClass(Villager.class, aabb);
+- List<Villager> list1 = (List) list.stream().filter((villager) -> {
+- return villager.wantsToSpawnGolem(i);
++ public void spawnGolemIfNeeded(ServerLevel serverLevel, long gameTime, int j) {
++ if (this.wantsToSpawnGolem(gameTime)) {
++ AABB axisalignedbb = this.getBoundingBox().inflate(10.0D, 10.0D, 10.0D);
++ List<Villager> list = serverLevel.getEntitiesOfClass(Villager.class, axisalignedbb);
++ List<Villager> list1 = (List) list.stream().filter((entityvillager) -> {
++ return entityvillager.wantsToSpawnGolem(gameTime);
+ }).limit(5L).collect(Collectors.toList());
+
+ if (list1.size() >= j) {
+- if (!SpawnUtil.trySpawnMob(EntityType.IRON_GOLEM, MobSpawnType.MOB_SUMMONED, serverlevel, this.blockPosition(), 10, 8, 6, SpawnUtil.Strategy.LEGACY_IRON_GOLEM).isEmpty()) {
++ if (!SpawnUtil.trySpawnMob(EntityType.IRON_GOLEM, EnumMobSpawn.MOB_SUMMONED, serverLevel, this.blockPosition(), 10, 8, 6, SpawnUtil.Strategy.LEGACY_IRON_GOLEM, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE).isEmpty()) { // CraftBukkit
+ list.forEach(GolemSensor::golemDetected);
+ }
+ }
+ }
+ }
+
+- public boolean wantsToSpawnGolem(long i) {
++ public boolean wantsToSpawnGolem(long gameTime) {
+ return !this.golemSpawnConditionsMet(this.level().getGameTime()) ? false : !this.brain.hasMemoryValue(MemoryModuleType.GOLEM_DETECTED_RECENTLY);
+ }
+
+ @Override
+- @Override
+- public void onReputationEventFrom(ReputationEventType reputationeventtype, Entity entity) {
+- if (reputationeventtype == ReputationEventType.ZOMBIE_VILLAGER_CURED) {
+- this.gossips.add(entity.getUUID(), GossipType.MAJOR_POSITIVE, 20);
+- this.gossips.add(entity.getUUID(), GossipType.MINOR_POSITIVE, 25);
+- } else if (reputationeventtype == ReputationEventType.TRADE) {
+- this.gossips.add(entity.getUUID(), GossipType.TRADING, 2);
+- } else if (reputationeventtype == ReputationEventType.VILLAGER_HURT) {
+- this.gossips.add(entity.getUUID(), GossipType.MINOR_NEGATIVE, 25);
+- } else if (reputationeventtype == ReputationEventType.VILLAGER_KILLED) {
+- this.gossips.add(entity.getUUID(), GossipType.MAJOR_NEGATIVE, 25);
++ public void onReputationEventFrom(ReputationEventType type, Entity target) {
++ if (type == ReputationEventType.ZOMBIE_VILLAGER_CURED) {
++ this.gossips.add(target.getUUID(), GossipType.MAJOR_POSITIVE, 20);
++ this.gossips.add(target.getUUID(), GossipType.MINOR_POSITIVE, 25);
++ } else if (type == ReputationEventType.TRADE) {
++ this.gossips.add(target.getUUID(), GossipType.TRADING, 2);
++ } else if (type == ReputationEventType.VILLAGER_HURT) {
++ this.gossips.add(target.getUUID(), GossipType.MINOR_NEGATIVE, 25);
++ } else if (type == ReputationEventType.VILLAGER_KILLED) {
++ this.gossips.add(target.getUUID(), GossipType.MAJOR_NEGATIVE, 25);
+ }
+
+ }
+
+ @Override
+- @Override
+ public int getVillagerXp() {
+ return this.villagerXp;
+ }
+
+- public void setVillagerXp(int i) {
+- this.villagerXp = i;
++ public void setVillagerXp(int villagerXp) {
++ this.villagerXp = villagerXp;
+ }
+
+ private void resetNumberOfRestocks() {
+@@ -1011,36 +1001,33 @@
+ return this.gossips;
+ }
+
+- public void setGossips(Tag tag) {
+- this.gossips.update(new Dynamic(NbtOps.INSTANCE, tag));
++ public void setGossips(Tag gossip) {
++ this.gossips.update(new Dynamic(NbtOps.INSTANCE, gossip));
+ }
+
+ @Override
+- @Override
+ protected void sendDebugPackets() {
+ super.sendDebugPackets();
+ DebugPackets.sendEntityBrain(this);
+ }
+
+ @Override
+- @Override
+- public void startSleeping(BlockPos blockpos) {
+- super.startSleeping(blockpos);
+- this.brain.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.level().getGameTime());
++ public void startSleeping(BlockPos pos) {
++ super.startSleeping(pos);
++ 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);
+ }
+
+ @Override
+- @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) {
++ private boolean golemSpawnConditionsMet(long gameTime) {
+ Optional<Long> optional = this.brain.getMemory(MemoryModuleType.LAST_SLEPT);
+
+- return optional.isPresent() ? i - (Long) optional.get() < 24000L : false;
++ return optional.isPresent() ? gameTime - (Long) optional.get() < 24000L : false;
+ }
+ }