mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 02:20:01 +03:00
53 lines
2.2 KiB
Diff
53 lines
2.2 KiB
Diff
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAITempt.java
|
|
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAITempt.java
|
|
@@ -3,10 +3,14 @@
|
|
import com.google.common.collect.Sets;
|
|
import java.util.Set;
|
|
import net.minecraft.entity.EntityCreature;
|
|
-import net.minecraft.entity.player.EntityPlayer;
|
|
+import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.pathfinding.PathNavigateGround;
|
|
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.event.entity.EntityTargetEvent;
|
|
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
|
|
|
public class EntityAITempt extends EntityAIBase
|
|
{
|
|
@@ -17,7 +21,7 @@
|
|
private double targetZ;
|
|
private double pitch;
|
|
private double yaw;
|
|
- private EntityPlayer temptingPlayer;
|
|
+ private EntityLivingBase temptingPlayer;
|
|
private int delayTemptCounter;
|
|
private boolean isRunning;
|
|
private final Set<Item> temptItem;
|
|
@@ -53,6 +57,7 @@
|
|
{
|
|
this.temptingPlayer = this.temptedEntity.world.getClosestPlayerToEntity(this.temptedEntity, 10.0D);
|
|
|
|
+ /*
|
|
if (this.temptingPlayer == null)
|
|
{
|
|
return false;
|
|
@@ -61,6 +66,16 @@
|
|
{
|
|
return 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;
|
|
}
|
|
}
|
|
|