mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-18 00:25:39 +01:00
111 lines
4.7 KiB
Diff
111 lines
4.7 KiB
Diff
--- a/net/minecraft/server/EntityVillager.java
|
|
+++ b/net/minecraft/server/EntityVillager.java
|
|
@@ -16,6 +16,16 @@
|
|
import java.util.function.BiPredicate;
|
|
import java.util.stream.Collectors;
|
|
import javax.annotation.Nullable;
|
|
+// 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 {
|
|
|
|
@@ -60,7 +70,7 @@
|
|
|
|
@Override
|
|
public BehaviorController<EntityVillager> getBehaviorController() {
|
|
- return super.getBehaviorController();
|
|
+ return (BehaviorController<EntityVillager>) super.getBehaviorController(); // CraftBukkit - decompile error
|
|
}
|
|
|
|
@Override
|
|
@@ -124,7 +134,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();
|
|
if (!this.et() && this.bB > 0) {
|
|
--this.bB;
|
|
@@ -134,7 +144,7 @@
|
|
this.bC = 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
|
|
}
|
|
}
|
|
|
|
@@ -353,7 +363,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
|
|
}
|
|
}
|
|
|
|
@@ -661,7 +678,12 @@
|
|
entitywitch.setCustomNameVisible(this.getCustomNameVisible());
|
|
}
|
|
|
|
- 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();
|
|
}
|
|
|
|
@@ -811,7 +833,7 @@
|
|
}
|
|
|
|
private void b(long i) {
|
|
- this.bo.setMemory(MemoryModuleType.GOLEM_LAST_SEEN_TIME, (Object) i);
|
|
+ this.bo.setMemory(MemoryModuleType.GOLEM_LAST_SEEN_TIME, i); // CraftBukkit - decompile error
|
|
}
|
|
|
|
private boolean c(long i) {
|
|
@@ -860,7 +882,7 @@
|
|
|
|
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;
|
|
}
|
|
|
|
@@ -922,13 +944,13 @@
|
|
@Override
|
|
public void entitySleep(BlockPosition blockposition) {
|
|
super.entitySleep(blockposition);
|
|
- this.bo.setMemory(MemoryModuleType.LAST_SLEPT, (Object) MinecraftSerializableLong.a(this.world.getTime()));
|
|
+ this.bo.setMemory(MemoryModuleType.LAST_SLEPT, MinecraftSerializableLong.a(this.world.getTime())); // CraftBukkit - decompile error
|
|
}
|
|
|
|
@Override
|
|
public void entityWakeup() {
|
|
super.entityWakeup();
|
|
- this.bo.setMemory(MemoryModuleType.LAST_WOKEN, (Object) MinecraftSerializableLong.a(this.world.getTime()));
|
|
+ this.bo.setMemory(MemoryModuleType.LAST_WOKEN, MinecraftSerializableLong.a(this.world.getTime())); // CraftBukkit - decompile error
|
|
}
|
|
|
|
private boolean d(long i) {
|