mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
121 lines
5.3 KiB
Diff
121 lines
5.3 KiB
Diff
--- a/net/minecraft/server/EntityVillager.java
|
|
+++ b/net/minecraft/server/EntityVillager.java
|
|
@@ -18,6 +18,16 @@
|
|
import java.util.stream.Collectors;
|
|
import javax.annotation.Nullable;
|
|
import org.apache.logging.log4j.Logger;
|
|
+// CraftBukkit start
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.craftbukkit.entity.CraftVillager;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
|
|
+import org.bukkit.entity.Villager;
|
|
+import org.bukkit.event.entity.EntityTransformEvent;
|
|
+import org.bukkit.event.entity.VillagerAcquireTradeEvent;
|
|
+import org.bukkit.event.entity.VillagerReplenishTradeEvent;
|
|
+// CraftBukkit end
|
|
|
|
public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder {
|
|
|
|
@@ -64,7 +74,7 @@
|
|
|
|
@Override
|
|
public BehaviorController<EntityVillager> getBehaviorController() {
|
|
- return super.getBehaviorController();
|
|
+ return (BehaviorController<EntityVillager>) super.getBehaviorController(); // CraftBukkit - decompile error
|
|
}
|
|
|
|
@Override
|
|
@@ -83,7 +93,7 @@
|
|
public void c(WorldServer worldserver) {
|
|
BehaviorController<EntityVillager> behaviorcontroller = this.getBehaviorController();
|
|
|
|
- behaviorcontroller.b(worldserver, (EntityLiving) this);
|
|
+ behaviorcontroller.b(worldserver, this); // CraftBukkit - decompile error
|
|
this.bg = behaviorcontroller.h();
|
|
this.a(this.getBehaviorController());
|
|
}
|
|
@@ -133,7 +143,7 @@
|
|
@Override
|
|
protected void mobTick() {
|
|
this.world.getMethodProfiler().enter("villagerBrain");
|
|
- this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this);
|
|
+ this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error
|
|
this.world.getMethodProfiler().exit();
|
|
if (this.bF) {
|
|
this.bF = false;
|
|
@@ -147,7 +157,7 @@
|
|
this.bu = 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
|
|
}
|
|
}
|
|
|
|
@@ -358,7 +368,14 @@
|
|
while (iterator.hasNext()) {
|
|
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
|
|
|
|
- merchantrecipe.increaseSpecialPrice(-MathHelper.d((float) i * merchantrecipe.getPriceMultiplier()));
|
|
+ // CraftBukkit start
|
|
+ int bonus = -MathHelper.d((float) i * merchantrecipe.getPriceMultiplier());
|
|
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit(), bonus);
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
+ if (!event.isCancelled()) {
|
|
+ merchantrecipe.increaseSpecialPrice(event.getBonus());
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
|
|
@@ -387,7 +404,7 @@
|
|
@Override
|
|
public void saveData(NBTTagCompound nbttagcompound) {
|
|
super.saveData(nbttagcompound);
|
|
- DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData());
|
|
+ DataResult<NBTBase> dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); // CraftBukkit - decompile error
|
|
Logger logger = EntityVillager.LOGGER;
|
|
|
|
logger.getClass();
|
|
@@ -700,7 +717,12 @@
|
|
}
|
|
|
|
entitywitch.setPersistent();
|
|
- worldserver.addAllEntities(entitywitch);
|
|
+ // CraftBukkit start
|
|
+ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ worldserver.addAllEntities(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
|
+ // CraftBukkit end
|
|
this.fq();
|
|
this.die();
|
|
} else {
|
|
@@ -833,7 +855,7 @@
|
|
|
|
if (entityirongolem != null) {
|
|
if (entityirongolem.a((GeneratorAccess) worldserver, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.a((IWorldReader) worldserver)) {
|
|
- worldserver.addAllEntities(entityirongolem);
|
|
+ worldserver.addAllEntities(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit
|
|
return entityirongolem;
|
|
}
|
|
|
|
@@ -911,7 +933,7 @@
|
|
@Override
|
|
public void entitySleep(BlockPosition blockposition) {
|
|
super.entitySleep(blockposition);
|
|
- this.bg.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.world.getTime());
|
|
+ this.bg.setMemory(MemoryModuleType.LAST_SLEPT, this.world.getTime()); // CraftBukkit - decompile error
|
|
this.bg.removeMemory(MemoryModuleType.WALK_TARGET);
|
|
this.bg.removeMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
|
|
}
|
|
@@ -919,7 +941,7 @@
|
|
@Override
|
|
public void entityWakeup() {
|
|
super.entityWakeup();
|
|
- this.bg.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.world.getTime());
|
|
+ this.bg.setMemory(MemoryModuleType.LAST_WOKEN, this.world.getTime()); // CraftBukkit - decompile error
|
|
}
|
|
|
|
private boolean b(long i) {
|