mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 11:25:55 +03:00
44 lines
2.0 KiB
Diff
44 lines
2.0 KiB
Diff
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAITempt.java
|
|
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAITempt.java
|
|
@@ -3,7 +3,14 @@
|
|
import com.google.common.collect.Sets;
|
|
import java.util.Set;
|
|
import javax.annotation.Nullable;
|
|
+
|
|
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.event.entity.EntityTargetEvent;
|
|
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
|
+
|
|
import net.minecraft.entity.EntityCreature;
|
|
+import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
@@ -18,7 +25,7 @@
|
|
private double targetZ;
|
|
private double pitch;
|
|
private double yaw;
|
|
- private EntityPlayer temptingPlayer;
|
|
+ private EntityLivingBase temptingPlayer; // CraftBukkit
|
|
private int delayTemptCounter;
|
|
private boolean isRunning;
|
|
private final Set<Item> temptItem;
|
|
@@ -53,7 +60,15 @@
|
|
else
|
|
{
|
|
this.temptingPlayer = this.temptedEntity.worldObj.getClosestPlayerToEntity(this.temptedEntity, 10.0D);
|
|
- return this.temptingPlayer == null ? false : this.isTempting(this.temptingPlayer.getHeldItemMainhand()) || this.isTempting(this.temptingPlayer.getHeldItemOffhand());
|
|
+ boolean tempt = this.temptingPlayer == null ? false : this.isTempting(this.temptingPlayer.getHeldItemMainhand()) || this.isTempting(this.temptingPlayer.getHeldItemOffhand());
|
|
+ if (tempt) {
|
|
+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.temptedEntity, this.temptingPlayer, EntityTargetEvent.TargetReason.TEMPT);
|
|
+ if (event.isCancelled()) {
|
|
+ return false;
|
|
+ }
|
|
+ this.temptingPlayer = (event.getTarget() == null) ? null : ((CraftLivingEntity) event.getTarget()).getHandle();
|
|
+ }
|
|
+ return tempt;
|
|
}
|
|
}
|
|
|