mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-25 09:34:44 +01:00
9ee989ea81
By: md_5 <git@md-5.net>
129 lines
5.6 KiB
Diff
129 lines
5.6 KiB
Diff
--- a/net/minecraft/world/entity/npc/EntityVillager.java
|
|
+++ b/net/minecraft/world/entity/npc/EntityVillager.java
|
|
@@ -90,6 +90,14 @@
|
|
import net.minecraft.world.phys.AxisAlignedBB;
|
|
import org.slf4j.Logger;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.entity.Villager;
|
|
+import org.bukkit.event.entity.EntityTransformEvent;
|
|
+import org.bukkit.event.entity.VillagerReplenishTradeEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder {
|
|
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
@@ -148,7 +156,7 @@
|
|
|
|
@Override
|
|
public BehaviorController<EntityVillager> getBrain() {
|
|
- return super.getBrain();
|
|
+ return (BehaviorController<EntityVillager>) super.getBrain(); // CraftBukkit - decompile error
|
|
}
|
|
|
|
@Override
|
|
@@ -231,7 +239,7 @@
|
|
this.increaseProfessionLevelOnUpdate = 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
|
|
}
|
|
}
|
|
|
|
@@ -359,7 +367,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();
|
|
@@ -417,7 +431,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
|
|
}
|
|
}
|
|
|
|
@@ -476,7 +496,7 @@
|
|
@Override
|
|
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
|
super.addAdditionalSaveData(nbttagcompound);
|
|
- DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData());
|
|
+ DataResult<NBTBase> dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error
|
|
Logger logger = EntityVillager.LOGGER;
|
|
|
|
Objects.requireNonNull(logger);
|
|
@@ -818,7 +838,12 @@
|
|
}
|
|
|
|
entitywitch.setPersistenceRequired();
|
|
- worldserver.addFreshEntityWithPassengers(entitywitch);
|
|
+ // CraftBukkit start
|
|
+ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ worldserver.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
|
+ // CraftBukkit end
|
|
this.releaseAllPois();
|
|
this.discard();
|
|
} else {
|
|
@@ -839,6 +864,13 @@
|
|
return;
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ ItemStack remaining = new InventorySubcontainer(inventorysubcontainer).addItem(itemstack);
|
|
+ if (CraftEventFactory.callEntityPickupItemEvent(this, entityitem, remaining.getCount(), false).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
this.onItemPickup(entityitem);
|
|
this.take(entityitem, itemstack.getCount());
|
|
ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack);
|
|
@@ -951,7 +983,7 @@
|
|
|
|
if (entityirongolem != null) {
|
|
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
|
|
return entityirongolem;
|
|
}
|
|
|
|
@@ -1029,7 +1061,7 @@
|
|
@Override
|
|
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);
|
|
}
|
|
@@ -1037,7 +1069,7 @@
|
|
@Override
|
|
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
|
|
}
|
|
|
|
private boolean golemSpawnConditionsMet(long i) {
|