Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-23 14:50:08 +01:00
Fixing some entity damage events
Dieser Commit ist enthalten in:
Ursprung
8088a329cd
Commit
73cbfcb6b6
@ -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();
|
||||
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(entity.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, 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());
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren