2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/npc/EntityVillager.java
|
|
|
|
+++ b/net/minecraft/world/entity/npc/EntityVillager.java
|
2021-11-21 23:00:00 +01:00
|
|
|
@@ -89,6 +89,14 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
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-11-21 23:00:00 +01:00
|
|
|
private static final DataWatcherObject<VillagerData> DATA_VILLAGER_DATA = DataWatcher.defineId(EntityVillager.class, DataWatcherRegistry.VILLAGER_DATA);
|
|
|
|
@@ -146,7 +154,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2021-11-21 23:00:00 +01:00
|
|
|
public BehaviorController<EntityVillager> getBrain() {
|
|
|
|
- return super.getBrain();
|
|
|
|
+ return (BehaviorController<EntityVillager>) super.getBrain(); // CraftBukkit - decompile error
|
2019-04-23 04:00:00 +02:00
|
|
|
}
|
2016-02-29 22:32:46 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2021-11-21 23:00:00 +01:00
|
|
|
@@ -229,7 +237,7 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
this.increaseProfessionLevelOnUpdate = 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-12-25 00:14:17 +01:00
|
|
|
@@ -357,7 +365,13 @@
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
|
|
|
|
|
|
|
|
- merchantrecipe.resetUses();
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
|
|
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ merchantrecipe.resetUses();
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
this.lastRestockGameTime = this.level.getGameTime();
|
|
|
|
@@ -415,7 +429,13 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
|
2016-02-29 22:32:46 +01:00
|
|
|
|
2021-12-25 00:14:17 +01:00
|
|
|
- merchantrecipe.resetUses();
|
2019-04-23 04:00:00 +02:00
|
|
|
+ // CraftBukkit start
|
2021-12-25 00:14:17 +01:00
|
|
|
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
|
2019-04-23 04:00:00 +02:00
|
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
|
|
+ if (!event.isCancelled()) {
|
2021-12-25 00:14:17 +01:00
|
|
|
+ merchantrecipe.resetUses();
|
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-12-25 00:14:17 +01:00
|
|
|
@@ -474,7 +494,7 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
@Override
|
2021-11-21 23:00:00 +01:00
|
|
|
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
|
|
|
super.addAdditionalSaveData(nbttagcompound);
|
2021-06-11 07:00:00 +02:00
|
|
|
- DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData());
|
|
|
|
+ DataResult<NBTBase> dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error
|
2020-06-25 02:00:00 +02:00
|
|
|
Logger logger = EntityVillager.LOGGER;
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
Objects.requireNonNull(logger);
|
2021-12-25 00:14:17 +01:00
|
|
|
@@ -816,7 +836,12 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
entitywitch.setPersistenceRequired();
|
|
|
|
- worldserver.addFreshEntityWithPassengers(entitywitch);
|
2020-06-25 02:00:00 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2021-11-21 23:00:00 +01:00
|
|
|
+ worldserver.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
2020-06-25 02:00:00 +02:00
|
|
|
+ // CraftBukkit end
|
2021-11-21 23:00:00 +01:00
|
|
|
this.releaseAllPois();
|
|
|
|
this.discard();
|
2020-06-25 02:00:00 +02:00
|
|
|
} else {
|
2021-12-25 00:14:17 +01:00
|
|
|
@@ -837,6 +862,13 @@
|
2021-05-09 08:57:25 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
2021-11-21 23:00:00 +01:00
|
|
|
+ ItemStack remaining = new InventorySubcontainer(inventorysubcontainer).addItem(itemstack);
|
2021-06-01 10:52:49 +02:00
|
|
|
+ if (CraftEventFactory.callEntityPickupItemEvent(this, entityitem, remaining.getCount(), false).isCancelled()) {
|
2021-05-09 08:57:25 +02:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2021-11-21 23:00:00 +01:00
|
|
|
this.onItemPickup(entityitem);
|
|
|
|
this.take(entityitem, itemstack.getCount());
|
|
|
|
ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack);
|
2021-12-25 00:14:17 +01:00
|
|
|
@@ -949,7 +981,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2019-06-21 12:00:00 +02:00
|
|
|
if (entityirongolem != null) {
|
2021-11-21 23:00:00 +01:00
|
|
|
if (entityirongolem.checkSpawnRules(worldserver, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.checkSpawnObstruction(worldserver)) {
|
|
|
|
- worldserver.addFreshEntityWithPassengers(entityirongolem);
|
|
|
|
+ worldserver.addFreshEntityWithPassengers(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit
|
2019-06-21 12:00:00 +02:00
|
|
|
return entityirongolem;
|
|
|
|
}
|
|
|
|
|
2021-12-25 00:14:17 +01:00
|
|
|
@@ -1027,7 +1059,7 @@
|
2019-06-21 12:00:00 +02:00
|
|
|
@Override
|
2021-11-21 23:00:00 +01:00
|
|
|
public void startSleeping(BlockPosition blockposition) {
|
|
|
|
super.startSleeping(blockposition);
|
|
|
|
- this.brain.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.level.getGameTime());
|
|
|
|
+ this.brain.setMemory(MemoryModuleType.LAST_SLEPT, this.level.getGameTime()); // CraftBukkit - decompile error
|
|
|
|
this.brain.eraseMemory(MemoryModuleType.WALK_TARGET);
|
|
|
|
this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|
2021-12-25 00:14:17 +01:00
|
|
|
@@ -1035,7 +1067,7 @@
|
2019-12-10 23:00:00 +01:00
|
|
|
@Override
|
2021-11-21 23:00:00 +01:00
|
|
|
public void stopSleeping() {
|
|
|
|
super.stopSleeping();
|
|
|
|
- this.brain.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.level.getGameTime());
|
|
|
|
+ this.brain.setMemory(MemoryModuleType.LAST_WOKEN, this.level.getGameTime()); // CraftBukkit - decompile error
|
2019-04-23 04:00:00 +02:00
|
|
|
}
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
private boolean golemSpawnConditionsMet(long i) {
|