diff options
Diffstat (limited to 'patch-remap/og/net/minecraft/world/entity/npc/EntityVillager.patch')
-rw-r--r-- | patch-remap/og/net/minecraft/world/entity/npc/EntityVillager.patch | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/entity/npc/EntityVillager.patch b/patch-remap/og/net/minecraft/world/entity/npc/EntityVillager.patch new file mode 100644 index 0000000000..9e8c71fa85 --- /dev/null +++ b/patch-remap/og/net/minecraft/world/entity/npc/EntityVillager.patch @@ -0,0 +1,115 @@ +--- a/net/minecraft/world/entity/npc/EntityVillager.java ++++ b/net/minecraft/world/entity/npc/EntityVillager.java +@@ -92,6 +92,14 @@ + 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.EntityTransformEvent; ++import org.bukkit.event.entity.VillagerReplenishTradeEvent; ++// CraftBukkit end ++ + public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder { + + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -150,7 +158,7 @@ + + @Override + public BehaviorController<EntityVillager> getBrain() { +- return super.getBrain(); ++ return (BehaviorController<EntityVillager>) super.getBrain(); // CraftBukkit - decompile error + } + + @Override +@@ -233,7 +241,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 + } + } + +@@ -361,7 +369,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(); +@@ -430,7 +444,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 + } + } + +@@ -490,7 +510,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); +@@ -834,7 +854,12 @@ + } + + entitywitch.setPersistenceRequired(); +- worldserver.addFreshEntityWithPassengers(entitywitch); ++ // CraftBukkit start ++ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) { ++ return; ++ } ++ worldserver.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); ++ // CraftBukkit end + this.releaseAllPois(); + this.discard(); + } else { +@@ -933,7 +958,7 @@ + }).limit(5L).collect(Collectors.toList()); + + if (list1.size() >= j) { +- if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EnumMobSpawn.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM).isEmpty()) { ++ if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EnumMobSpawn.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE).isEmpty()) { // CraftBukkit + list.forEach(SensorGolemLastSeen::golemDetected); + } + } +@@ -990,7 +1015,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); + } +@@ -998,7 +1023,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) { |