Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-20 05:20:07 +01:00
Added EntityTargetEvent for Experience Orbs, happens when it starts moving towards a human entity! Addresses BUKKIT-820
Dieser Commit ist enthalten in:
Ursprung
cd90cec48c
Commit
bf01e93ab6
@ -56,17 +56,23 @@ public class EntityExperienceOrb extends Entity {
|
|||||||
EntityHuman entityhuman = this.world.findNearbyPlayer(this, d0);
|
EntityHuman entityhuman = this.world.findNearbyPlayer(this, d0);
|
||||||
|
|
||||||
if (entityhuman != null) {
|
if (entityhuman != null) {
|
||||||
double d1 = (entityhuman.locX - this.locX) / d0;
|
// CraftBukkit start
|
||||||
double d2 = (entityhuman.locY + (double) entityhuman.y() - this.locY) / d0;
|
org.bukkit.event.entity.EntityTargetEvent event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
|
||||||
double d3 = (entityhuman.locZ - this.locZ) / d0;
|
Entity target = event.getTarget() == null ? null : ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
|
||||||
double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
|
|
||||||
double d5 = 1.0D - d4;
|
|
||||||
|
|
||||||
if (d5 > 0.0D) {
|
if (!event.isCancelled() && target != null) {
|
||||||
d5 *= d5;
|
double d1 = (target.locX - this.locX) / d0;
|
||||||
this.motX += d1 / d4 * d5 * 0.1D;
|
double d2 = (target.locY + (double) target.y() - this.locY) / d0;
|
||||||
this.motY += d2 / d4 * d5 * 0.1D;
|
double d3 = (target.locZ - this.locZ) / d0;
|
||||||
this.motZ += d3 / d4 * d5 * 0.1D;
|
double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
|
||||||
|
double d5 = 1.0D - d4;
|
||||||
|
if (d5 > 0.0D) {
|
||||||
|
d5 *= d5;
|
||||||
|
this.motX += d1 / d4 * d5 * 0.1D;
|
||||||
|
this.motY += d2 / d4 * d5 * 0.1D;
|
||||||
|
this.motZ += d3 / d4 * d5 * 0.1D;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,4 +407,10 @@ public class CraftEventFactory {
|
|||||||
creeper.getBukkitEntity().getServer().getPluginManager().callEvent(event);
|
creeper.getBukkitEntity().getServer().getPluginManager().callEvent(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EntityTargetEvent callEntityTargetEvent(Entity entity, Entity target, EntityTargetEvent.TargetReason reason) {
|
||||||
|
EntityTargetEvent event = new EntityTargetEvent(entity.getBukkitEntity(), target.getBukkitEntity(), reason);
|
||||||
|
entity.getBukkitEntity().getServer().getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren