summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft
diff options
context:
space:
mode:
authorAndrew Ardill <andrew.ardill@gmail.com>2011-01-18 10:48:02 +1100
committerAndrew Ardill <andrew.ardill@gmail.com>2011-01-18 13:49:33 +1100
commitddc30dd6e3da3fa4a5b27b40ba0d15854e6fb12e (patch)
tree1911963a01bb3ed4702a00c66d470316ad2e7a92 /src/main/java/net/minecraft
parent8088a329cd53228bd7f82bc6c03bc0c88be4a3d3 (diff)
downloadcraftbukkit-ddc30dd6e3da3fa4a5b27b40ba0d15854e6fb12e.tar
craftbukkit-ddc30dd6e3da3fa4a5b27b40ba0d15854e6fb12e.tar.gz
craftbukkit-ddc30dd6e3da3fa4a5b27b40ba0d15854e6fb12e.tar.lz
craftbukkit-ddc30dd6e3da3fa4a5b27b40ba0d15854e6fb12e.tar.xz
craftbukkit-ddc30dd6e3da3fa4a5b27b40ba0d15854e6fb12e.zip
Fixing some entity damage events
Diffstat (limited to 'src/main/java/net/minecraft')
-rw-r--r--src/main/java/net/minecraft/server/EntityMobs.java8
-rw-r--r--src/main/java/net/minecraft/server/EntityPlayer.java9
-rw-r--r--src/main/java/net/minecraft/server/Explosion.java34
3 files changed, 35 insertions, 16 deletions
diff --git a/src/main/java/net/minecraft/server/EntityMobs.java b/src/main/java/net/minecraft/server/EntityMobs.java
index 8b1da90e..e55b4882 100644
--- a/src/main/java/net/minecraft/server/EntityMobs.java
+++ b/src/main/java/net/minecraft/server/EntityMobs.java
@@ -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()){
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 39b6eef2..99a18914 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -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()){
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
index d48e3bc3..68879d8a 100644
--- a/src/main/java/net/minecraft/server/Explosion.java
+++ b/src/main/java/net/minecraft/server/Explosion.java
@@ -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());