2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/npc/EntityVillager.java
|
|
|
|
+++ b/net/minecraft/world/entity/npc/EntityVillager.java
|
|
|
|
@@ -89,6 +89,14 @@
|
|
|
|
import net.minecraft.world.phys.AxisAlignedBB;
|
2020-06-25 02:00:00 +02:00
|
|
|
import org.apache.logging.log4j.Logger;
|
2021-03-08 22:47:33 +01:00
|
|
|
|
2016-05-10 13:47:39 +02:00
|
|
|
+// CraftBukkit start
|
2016-02-29 22:32:46 +01:00
|
|
|
+import org.bukkit.Bukkit;
|
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.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.VillagerReplenishTradeEvent;
|
2016-05-10 13:47:39 +02:00
|
|
|
+// CraftBukkit end
|
2021-03-08 22:47:33 +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
|
|
|
|
2021-03-08 22:47:33 +01:00
|
|
|
private static final DataWatcherObject<VillagerData> br = DataWatcher.a(EntityVillager.class, DataWatcherRegistry.q);
|
2021-03-15 23:00:00 +01:00
|
|
|
@@ -134,7 +142,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
|
2021-03-15 23:00:00 +01:00
|
|
|
@@ -153,7 +161,7 @@
|
2020-08-11 23:00:00 +02:00
|
|
|
public void c(WorldServer worldserver) {
|
2020-06-25 02:00:00 +02:00
|
|
|
BehaviorController<EntityVillager> behaviorcontroller = this.getBehaviorController();
|
|
|
|
|
|
|
|
- behaviorcontroller.b(worldserver, (EntityLiving) this);
|
|
|
|
+ behaviorcontroller.b(worldserver, this); // CraftBukkit - decompile error
|
2020-08-11 23:00:00 +02:00
|
|
|
this.bg = behaviorcontroller.h();
|
2020-06-25 02:00:00 +02:00
|
|
|
this.a(this.getBehaviorController());
|
|
|
|
}
|
2021-03-15 23:00:00 +01:00
|
|
|
@@ -203,7 +211,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-08-11 23:00:00 +02:00
|
|
|
if (this.bF) {
|
|
|
|
this.bF = false;
|
2021-03-15 23:00:00 +01:00
|
|
|
@@ -217,7 +225,7 @@
|
2020-08-11 23:00:00 +02:00
|
|
|
this.bu = 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-15 23:00:00 +01:00
|
|
|
@@ -428,7 +436,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
|
|
|
|
2021-03-15 23:00:00 +01:00
|
|
|
@@ -457,7 +472,7 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
@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();
|
2021-03-15 23:00:00 +01:00
|
|
|
@@ -770,7 +785,12 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
entitywitch.setPersistent();
|
2020-08-11 23:00:00 +02:00
|
|
|
- worldserver.addAllEntities(entitywitch);
|
2020-06-25 02:00:00 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2020-08-11 23:00:00 +02:00
|
|
|
+ worldserver.addAllEntities(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
2020-06-25 02:00:00 +02:00
|
|
|
+ // CraftBukkit end
|
2020-08-11 23:00:00 +02:00
|
|
|
this.fq();
|
2020-06-25 02:00:00 +02:00
|
|
|
this.die();
|
|
|
|
} else {
|
2021-05-09 08:57:25 +02:00
|
|
|
@@ -791,9 +811,16 @@
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ ItemStack itemstack1 = inventorysubcontainer.a(itemstack);
|
|
|
|
+ if (CraftEventFactory.callEntityPickupItemEvent(this, entityitem, itemstack1.getCount(), false).isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
this.a(entityitem);
|
|
|
|
this.receive(entityitem, itemstack.getCount());
|
|
|
|
- ItemStack itemstack1 = inventorysubcontainer.a(itemstack);
|
|
|
|
+ // ItemStack itemstack1 = inventorysubcontainer.a(itemstack); // CraftBukkit - moved up
|
|
|
|
|
|
|
|
if (itemstack1.isEmpty()) {
|
|
|
|
entityitem.die();
|
|
|
|
@@ -903,7 +930,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2019-06-21 12:00:00 +02:00
|
|
|
if (entityirongolem != null) {
|
2020-08-11 23:00:00 +02:00
|
|
|
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
|
2019-06-21 12:00:00 +02:00
|
|
|
return entityirongolem;
|
|
|
|
}
|
|
|
|
|
2021-05-09 08:57:25 +02:00
|
|
|
@@ -981,7 +1008,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-08-11 23:00:00 +02:00
|
|
|
- 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);
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|
2021-05-09 08:57:25 +02:00
|
|
|
@@ -989,7 +1016,7 @@
|
2019-12-10 23:00:00 +01:00
|
|
|
@Override
|
|
|
|
public void entityWakeup() {
|
|
|
|
super.entityWakeup();
|
2020-08-11 23:00:00 +02:00
|
|
|
- this.bg.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.world.getTime());
|
|
|
|
+ this.bg.setMemory(MemoryModuleType.LAST_WOKEN, this.world.getTime()); // CraftBukkit - decompile error
|
2019-04-23 04:00:00 +02:00
|
|
|
}
|
|
|
|
|
2020-08-11 23:00:00 +02:00
|
|
|
private boolean b(long i) {
|