mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
Fixing some entity damage events
This commit is contained in:
parent
8088a329cd
commit
73cbfcb6b6
3 changed files with 35 additions and 16 deletions
|
@ -8,9 +8,11 @@ import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
|||
import org.bukkit.craftbukkit.entity.CraftMinecart;
|
||||
import org.bukkit.craftbukkit.entity.CraftMonster;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
//CraftBukkit end
|
||||
|
||||
public class EntityMobs extends EntityCreature implements IMobs {
|
||||
|
@ -73,8 +75,12 @@ public class EntityMobs extends EntityCreature implements IMobs {
|
|||
// CraftBukkit start
|
||||
if(entity instanceof EntityLiving) {
|
||||
CraftServer server = ((WorldServer) l).getServer();
|
||||
org.bukkit.entity.Entity damager = this.getBukkitEntity();
|
||||
org.bukkit.entity.Entity damagee = entity.getBukkitEntity();
|
||||
DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
||||
int damageDone = c;
|
||||
|
||||
EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(entity.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, c);
|
||||
EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
|
||||
server.getPluginManager().callEvent(edbee);
|
||||
|
||||
if (!edbee.isCancelled()){
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
|||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
// CraftBukkit end
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
public abstract class EntityPlayer extends EntityLiving {
|
||||
|
||||
|
@ -340,8 +341,12 @@ public abstract class EntityPlayer extends EntityLiving {
|
|||
// CraftBukkit start
|
||||
if(entity instanceof EntityLiving) {
|
||||
CraftServer server = ((WorldServer) l).getServer();
|
||||
|
||||
EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(entity.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, i);
|
||||
org.bukkit.entity.Entity damager = this.getBukkitEntity();
|
||||
org.bukkit.entity.Entity damagee = entity.getBukkitEntity();
|
||||
DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
||||
int damageDone = i;
|
||||
|
||||
EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
|
||||
server.getPluginManager().callEvent(edbee);
|
||||
|
||||
if (!edbee.isCancelled()){
|
||||
|
|
|
@ -8,9 +8,13 @@ import org.bukkit.craftbukkit.CraftServer;
|
|||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
// CraftBukkit end
|
||||
|
||||
import java.util.*;
|
||||
|
@ -115,32 +119,36 @@ public class Explosion {
|
|||
double d14 = (1.0D - d11) * d13;
|
||||
|
||||
// CraftBukkit start - explosion damage hook
|
||||
int damage = (int) (((d14 * d14 + d14) / 2D) * 8D * (double) f + 1.0D);
|
||||
CraftServer servr = ((WorldServer) i).getServer();
|
||||
CraftEntity damagee = null;
|
||||
if (entity instanceof EntityPlayerMP) {
|
||||
damagee = new CraftPlayer(servr, (EntityPlayerMP) entity);
|
||||
} else if (entity instanceof EntityLiving) {
|
||||
damagee = new CraftLivingEntity(servr, (EntityLiving) entity);
|
||||
CraftServer server = ((WorldServer) i).getServer();
|
||||
org.bukkit.entity.Entity damagee = null;
|
||||
DamageCause damageType;
|
||||
int damageDone = (int) (((d14 * d14 + d14) / 2D) * 8D * (double) f + 1.0D);
|
||||
|
||||
if(entity instanceof EntityLiving) {
|
||||
damagee = entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
if (e == null) { // Block explosion
|
||||
// Craftbukkit TODO: get the x/y/z of the tnt block?
|
||||
EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(null, damagee, EntityDamageEvent.DamageCause.BLOCK_EXPLOSION, damage);
|
||||
servr.getPluginManager().callEvent(edbbe);
|
||||
damageType = EntityDamageEvent.DamageCause.BLOCK_EXPLOSION;
|
||||
EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(null, damagee, damageType, damageDone);
|
||||
server.getPluginManager().callEvent(edbbe);
|
||||
if (!edbbe.isCancelled()) {
|
||||
entity.a(e, edbbe.getDamage());
|
||||
}
|
||||
} else {
|
||||
CraftEntity damager = null;
|
||||
//TODO org.bukkit.entity.Entity damager = e.getBukkitEntity();
|
||||
if (e instanceof EntityPlayerMP) {
|
||||
// not possible in normal operations
|
||||
damager = new CraftPlayer(servr, (EntityPlayerMP) e);
|
||||
damager = new CraftPlayer(server, (EntityPlayerMP) e);
|
||||
} else if (e instanceof EntityLiving) {
|
||||
damager = new CraftLivingEntity(servr, (EntityLiving) e);
|
||||
damager = new CraftLivingEntity(server, (EntityLiving) e);
|
||||
}
|
||||
EntityDamageByEntityEvent edbbe = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_EXPLOSION, damage);
|
||||
servr.getPluginManager().callEvent(edbbe);
|
||||
damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
||||
|
||||
EntityDamageByEntityEvent edbbe = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
|
||||
server.getPluginManager().callEvent(edbbe);
|
||||
|
||||
if (!edbbe.isCancelled()) {
|
||||
entity.a(e, edbbe.getDamage());
|
||||
|
|
Loading…
Reference in a new issue