mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
Improve calling of ProjectileHitEvent. Fixes BUKKIT-3872
This commit is contained in:
parent
45d3e2514d
commit
08f3df82eb
@ -3,9 +3,7 @@ package net.minecraft.server;
|
||||
import java.util.List;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
@ -209,11 +207,7 @@ public class EntityArrow extends Entity implements IProjectile {
|
||||
float f3;
|
||||
|
||||
if (movingobjectposition != null) {
|
||||
// CraftBukkit start
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
ProjectileHitEvent phe = new ProjectileHitEvent(projectile);
|
||||
this.world.getServer().getPluginManager().callEvent(phe);
|
||||
// CraftBukkit end
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // CraftBukkit - Call event
|
||||
|
||||
if (movingobjectposition.entity != null) {
|
||||
f2 = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
|
||||
|
@ -2,8 +2,6 @@ package net.minecraft.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.entity.ProjectileHitEvent; // CraftBukkit
|
||||
|
||||
public abstract class EntityFireball extends Entity {
|
||||
|
||||
private int e = -1;
|
||||
@ -133,8 +131,7 @@ public abstract class EntityFireball extends Entity {
|
||||
|
||||
// CraftBukkit start
|
||||
if (this.dead) {
|
||||
ProjectileHitEvent phe = new ProjectileHitEvent((org.bukkit.entity.Projectile) this.getBukkitEntity());
|
||||
this.world.getServer().getPluginManager().callEvent(phe);
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this);
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
@ -178,6 +178,7 @@ public class EntityFishingHook extends Entity {
|
||||
}
|
||||
|
||||
if (movingobjectposition != null) {
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event
|
||||
if (movingobjectposition.entity != null) {
|
||||
if (movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.owner), 0)) {
|
||||
this.hooked = movingobjectposition.entity;
|
||||
|
@ -2,8 +2,6 @@ package net.minecraft.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.entity.ProjectileHitEvent; // CraftBukkit
|
||||
|
||||
public abstract class EntityProjectile extends Entity implements IProjectile {
|
||||
|
||||
private int blockX = -1;
|
||||
@ -158,8 +156,7 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
|
||||
this.a(movingobjectposition);
|
||||
// CraftBukkit start
|
||||
if (this.dead) {
|
||||
ProjectileHitEvent hitEvent = new ProjectileHitEvent((org.bukkit.entity.Projectile) this.getBukkitEntity());
|
||||
org.bukkit.Bukkit.getPluginManager().callEvent(hitEvent);
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this);
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
@ -532,6 +532,12 @@ public class CraftEventFactory {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static ProjectileHitEvent callProjectileHitEvent(Entity entity) {
|
||||
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity());
|
||||
entity.world.getServer().getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static ExpBottleEvent callExpBottleEvent(Entity entity, int exp) {
|
||||
ThrownExpBottle bottle = (ThrownExpBottle) entity.getBukkitEntity();
|
||||
ExpBottleEvent event = new ExpBottleEvent(bottle, exp);
|
||||
|
Loading…
Reference in New Issue
Block a user