2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/npc/EntityVillager.java
|
|
|
|
+++ b/net/minecraft/world/entity/npc/EntityVillager.java
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -90,6 +90,14 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.phys.AxisAlignedBB;
|
2022-02-28 16:00:00 +01:00
|
|
|
import org.slf4j.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
|
|
|
|
2022-02-28 16:00:00 +01:00
|
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
|
|
@@ -148,7 +156,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
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -231,7 +239,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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -359,7 +367,13 @@
|
2021-12-25 00:14:17 +01:00
|
|
|
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();
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -417,7 +431,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
|
|
|
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -476,7 +496,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);
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -818,7 +838,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 {
|
2022-06-07 18:00:00 +02:00
|
|
|
@@ -904,7 +929,7 @@
|
|
|
|
}).limit(5L).collect(Collectors.toList());
|
2019-06-21 12:00:00 +02:00
|
|
|
|
2022-06-07 18:00:00 +02:00
|
|
|
if (list1.size() >= j) {
|
|
|
|
- if (SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EnumMobSpawn.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM).isPresent()) {
|
|
|
|
+ if (SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EnumMobSpawn.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE).isPresent()) { // CraftBukkit
|
|
|
|
list.forEach(SensorGolemLastSeen::golemDetected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -961,7 +986,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
|
|
|
}
|
2022-06-07 18:00:00 +02:00
|
|
|
@@ -969,7 +994,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) {
|