PaperMC/nms-patches/EntityVillager.patch

95 lines
4.1 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityVillager.java
+++ b/net/minecraft/server/EntityVillager.java
2019-04-23 04:00:00 +02:00
@@ -17,6 +17,16 @@
import java.util.function.BiPredicate;
import java.util.stream.Collectors;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+// CraftBukkit start
2016-02-29 22:32:46 +01:00
+import org.bukkit.Bukkit;
2016-05-10 13:47:39 +02:00
+import org.bukkit.craftbukkit.entity.CraftVillager;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
2016-02-29 22:32:46 +01:00
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
+import org.bukkit.entity.Villager;
+import org.bukkit.event.entity.EntityTransformEvent;
2016-02-29 22:32:46 +01:00
+import org.bukkit.event.entity.VillagerAcquireTradeEvent;
+import org.bukkit.event.entity.VillagerReplenishTradeEvent;
2016-05-10 13:47:39 +02:00
+// CraftBukkit end
2019-04-23 04:00:00 +02:00
public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder {
2019-04-23 04:00:00 +02:00
@@ -62,7 +72,7 @@
2019-04-23 04:00:00 +02:00
@Override
public BehaviorController<EntityVillager> getBehaviorController() {
- return super.getBehaviorController();
+ return (BehaviorController<EntityVillager>) super.getBehaviorController(); // CraftBukkit - decompile error
}
2016-02-29 22:32:46 +01:00
2019-04-23 04:00:00 +02:00
@Override
@@ -126,7 +136,7 @@
@Override
protected void mobTick() {
this.world.getMethodProfiler().enter("brain");
- this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this);
+ this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error
this.world.getMethodProfiler().exit();
2019-05-14 02:00:00 +02:00
if (!this.dY() && this.bE > 0) {
2019-04-23 04:00:00 +02:00
--this.bE;
@@ -136,7 +146,7 @@
this.bF = 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
}
}
2019-05-14 02:00:00 +02:00
@@ -258,7 +268,14 @@
2019-04-23 04:00:00 +02:00
while (iterator.hasNext()) {
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
2016-02-29 22:32:46 +01:00
2019-05-14 02:00:00 +02:00
- merchantrecipe.increaseSpecialPrice(-MathHelper.d((float) i * merchantrecipe.getPriceMultiplier()));
2019-04-23 04:00:00 +02:00
+ // CraftBukkit start
2019-05-14 02:00:00 +02:00
+ int bonus = -MathHelper.d((float) i * merchantrecipe.getPriceMultiplier());
2019-04-23 04:00:00 +02:00
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit(), bonus);
+ Bukkit.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
2019-05-14 02:00:00 +02:00
+ merchantrecipe.increaseSpecialPrice(event.getBonus());
2019-04-23 04:00:00 +02:00
+ }
+ // CraftBukkit end
}
2019-04-23 04:00:00 +02:00
}
2019-05-14 02:00:00 +02:00
@@ -558,7 +575,12 @@
2019-04-23 04:00:00 +02:00
entitywitch.setCustomNameVisible(this.getCustomNameVisible());
}
2019-04-23 04:00:00 +02:00
- this.world.addEntity(entitywitch);
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
+ return;
+ }
+ this.world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
+ // CraftBukkit end
this.die();
}
2019-04-23 04:00:00 +02:00
2019-05-14 02:00:00 +02:00
@@ -730,7 +752,7 @@
2019-04-23 04:00:00 +02:00
if (entityirongolem != null) {
if (entityirongolem.a((GeneratorAccess) this.world, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.a((IWorldReader) this.world)) {
- this.world.addEntity(entityirongolem);
+ this.world.addEntity(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit
return entityirongolem;
}
2019-05-14 02:00:00 +02:00
@@ -780,7 +802,7 @@
EntityVillager.a entityvillager_a = (EntityVillager.a) this.getBehaviorController().getMemory(MemoryModuleType.GOLEM_SPAWN_CONDITIONS).orElseGet(EntityVillager.a::new);
2019-04-23 04:00:00 +02:00
entityvillager_a.b(this.world.getTime());
2019-05-14 02:00:00 +02:00
- this.br.setMemory(MemoryModuleType.GOLEM_SPAWN_CONDITIONS, (Object) entityvillager_a);
+ this.br.setMemory(MemoryModuleType.GOLEM_SPAWN_CONDITIONS, entityvillager_a); // CraftBukkit - decompile error
2019-04-23 04:00:00 +02:00
}
public static final class a {