mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-03 06:40:19 +08:00
68 lines
2.8 KiB
Diff
68 lines
2.8 KiB
Diff
--- a/net/minecraft/server/EntityEnderman.java
|
|
+++ b/net/minecraft/server/EntityEnderman.java
|
|
@@ -4,6 +4,8 @@
|
|
import com.google.common.base.Optional;
|
|
import com.google.common.base.Predicate;
|
|
import com.google.common.collect.Sets;
|
|
+import org.bukkit.event.entity.EntityTargetEvent;
|
|
+
|
|
import java.util.Random;
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
@@ -55,7 +57,18 @@
|
|
}
|
|
|
|
public void setGoalTarget(EntityLiving entityliving) {
|
|
- super.setGoalTarget(entityliving);
|
|
+ // CraftBukkit start - fire event
|
|
+ setGoalTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) {
|
|
+ if (!super.setGoalTarget(entityliving, reason, fireEvent)) {
|
|
+ return false;
|
|
+ }
|
|
+ entityliving = getGoalTarget();
|
|
+ System.out.println(entityliving);
|
|
+ // CraftBukkit end
|
|
AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
|
|
|
|
if (entityliving == null) {
|
|
@@ -69,6 +82,7 @@
|
|
attributeinstance.b(EntityEnderman.b);
|
|
}
|
|
}
|
|
+ return true;
|
|
|
|
}
|
|
|
|
@@ -306,8 +320,12 @@
|
|
boolean flag = movingobjectposition != null && movingobjectposition.a().equals(blockposition);
|
|
|
|
if (EntityEnderman.c.contains(block) && flag) {
|
|
- this.enderman.setCarried(iblockdata);
|
|
- world.setAir(blockposition);
|
|
+ // CraftBukkit start - Pickup event
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, this.enderman.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), org.bukkit.Material.AIR).isCancelled()) {
|
|
+ this.enderman.setCarried(iblockdata);
|
|
+ world.setAir(blockposition);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
}
|
|
@@ -337,8 +355,12 @@
|
|
IBlockData iblockdata2 = this.a.getCarried();
|
|
|
|
if (iblockdata2 != null && this.a(world, blockposition, iblockdata2.getBlock(), iblockdata, iblockdata1)) {
|
|
+ // CraftBukkit start - Place event
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.a.getCarried().getBlock(), this.a.getCarried().getBlock().toLegacyData(this.a.getCarried())).isCancelled()) {
|
|
world.setTypeAndData(blockposition, iblockdata2, 3);
|
|
this.a.setCarried((IBlockData) null);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
}
|