2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityVillager.java
|
|
|
|
+++ b/net/minecraft/server/EntityVillager.java
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -18,6 +18,16 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
import java.util.stream.Collectors;
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
2020-06-25 02:00:00 +02:00
|
|
|
import org.apache.logging.log4j.Logger;
|
2016-05-10 13:47:39 +02:00
|
|
|
+// 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;
|
2018-11-14 04:10:22 +01:00
|
|
|
+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;
|
2018-11-14 04:10:22 +01:00
|
|
|
+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
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -64,7 +74,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
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
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -83,7 +93,7 @@
|
|
|
|
public void b(WorldServer worldserver) {
|
|
|
|
BehaviorController<EntityVillager> behaviorcontroller = this.getBehaviorController();
|
|
|
|
|
|
|
|
- behaviorcontroller.b(worldserver, (EntityLiving) this);
|
|
|
|
+ behaviorcontroller.b(worldserver, this); // CraftBukkit - decompile error
|
|
|
|
this.bn = behaviorcontroller.h();
|
|
|
|
this.a(this.getBehaviorController());
|
|
|
|
}
|
|
|
|
@@ -133,7 +143,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
|
|
|
protected void mobTick() {
|
2020-06-25 02:00:00 +02:00
|
|
|
this.world.getMethodProfiler().enter("villagerBrain");
|
2019-04-23 04:00:00 +02:00
|
|
|
- this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this);
|
|
|
|
+ this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error
|
|
|
|
this.world.getMethodProfiler().exit();
|
2020-06-25 02:00:00 +02:00
|
|
|
if (this.bM) {
|
|
|
|
this.bM = false;
|
|
|
|
@@ -147,7 +157,7 @@
|
|
|
|
this.bB = false;
|
2018-07-20 08:04:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -358,7 +368,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
|
2018-11-14 04:10:22 +01:00
|
|
|
}
|
2019-04-23 04:00:00 +02:00
|
|
|
}
|
2018-11-14 04:10:22 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -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();
|
|
|
|
@@ -695,7 +712,12 @@
|
|
|
|
}
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
entitywitch.setPersistent();
|
|
|
|
- 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();
|
|
|
|
} else {
|
|
|
|
super.onLightningStrike(entitylightning);
|
|
|
|
@@ -812,7 +834,7 @@
|
2019-06-21 12:00:00 +02:00
|
|
|
}
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2019-06-21 12:00:00 +02:00
|
|
|
private void b(long i) {
|
2020-06-25 02:00:00 +02:00
|
|
|
- this.bn.setMemory(MemoryModuleType.GOLEM_LAST_SEEN_TIME, (Object) i);
|
|
|
|
+ this.bn.setMemory(MemoryModuleType.GOLEM_LAST_SEEN_TIME, i); // CraftBukkit - decompile error
|
2019-06-21 12:00:00 +02:00
|
|
|
}
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2019-06-21 12:00:00 +02:00
|
|
|
private boolean c(long i) {
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -845,7 +867,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2019-06-21 12: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;
|
|
|
|
}
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -923,7 +945,7 @@
|
2019-06-21 12:00:00 +02:00
|
|
|
@Override
|
2019-12-10 23:00:00 +01:00
|
|
|
public void entitySleep(BlockPosition blockposition) {
|
|
|
|
super.entitySleep(blockposition);
|
2020-06-25 02:00:00 +02:00
|
|
|
- this.bn.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.world.getTime());
|
|
|
|
+ this.bn.setMemory(MemoryModuleType.LAST_SLEPT, this.world.getTime()); // CraftBukkit - decompile error
|
|
|
|
this.bn.removeMemory(MemoryModuleType.WALK_TARGET);
|
|
|
|
this.bn.removeMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -931,7 +953,7 @@
|
2019-12-10 23:00:00 +01:00
|
|
|
@Override
|
|
|
|
public void entityWakeup() {
|
|
|
|
super.entityWakeup();
|
2020-06-25 02:00:00 +02:00
|
|
|
- this.bn.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.world.getTime());
|
|
|
|
+ this.bn.setMemory(MemoryModuleType.LAST_WOKEN, this.world.getTime()); // CraftBukkit - decompile error
|
2019-04-23 04:00:00 +02:00
|
|
|
}
|
|
|
|
|
2019-06-21 12:00:00 +02:00
|
|
|
private boolean d(long i) {
|