summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft
diff options
context:
space:
mode:
authorDinnerbone <dinnerbone@dinnerbone.com>2011-02-24 12:49:48 +0000
committerDinnerbone <dinnerbone@dinnerbone.com>2011-02-24 12:49:48 +0000
commitc97fa40d2b8cbd74857c7dd596106771d3156f87 (patch)
tree3e6c334eddc36fc4cb7226b88f7eda26980de450 /src/main/java/net/minecraft
parent51be9e77c6853231d10965d1aa56bf54ca3c189a (diff)
downloadcraftbukkit-c97fa40d2b8cbd74857c7dd596106771d3156f87.tar
craftbukkit-c97fa40d2b8cbd74857c7dd596106771d3156f87.tar.gz
craftbukkit-c97fa40d2b8cbd74857c7dd596106771d3156f87.tar.lz
craftbukkit-c97fa40d2b8cbd74857c7dd596106771d3156f87.tar.xz
craftbukkit-c97fa40d2b8cbd74857c7dd596106771d3156f87.zip
Fixed ENTITY_DAMAGE involving slimes (per DHowet)
Diffstat (limited to 'src/main/java/net/minecraft')
-rw-r--r--src/main/java/net/minecraft/server/EntityHuman.java16
-rw-r--r--src/main/java/net/minecraft/server/EntityMonster.java6
2 files changed, 20 insertions, 2 deletions
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 54a5219e..c509e600 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -357,6 +357,22 @@ public abstract class EntityHuman extends EntityLiving {
}
}
+ // CraftBukkit start - this is here instead of EntityMonster because EntityLiving(s) that aren't monsters
+ // also damage the player in this way. For example, EntitySlime.
+ if (entity instanceof EntityLiving) {
+ CraftServer server = ((WorldServer) this.world).getServer();
+ org.bukkit.entity.Entity damager = entity.getBukkitEntity();
+ org.bukkit.entity.Entity damagee = this.getBukkitEntity();
+ DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, i);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
+ }
+ }
+ // CraftBukkit end
+
return i == 0 ? false : super.a(entity, i);
}
}
diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java
index 9ad79aaf..d06311b3 100644
--- a/src/main/java/net/minecraft/server/EntityMonster.java
+++ b/src/main/java/net/minecraft/server/EntityMonster.java
@@ -79,8 +79,10 @@ public class EntityMonster extends EntityCreature implements IMonster {
protected void a(Entity entity, float f) {
if ((double) f < 1.5D && entity.boundingBox.e > this.boundingBox.b && entity.boundingBox.b < this.boundingBox.e) {
this.attackTicks = 20;
- // CraftBukkit start
- if (entity instanceof EntityLiving) {
+ // CraftBukkit start - this is still duplicated here and EntityHuman because it's possible for an EntityMonster
+ // to damage another EntityMonster, and we want to catch those events.
+ // This does not fire events for slime attacks, as they're not an EntityMonster.
+ if (entity instanceof EntityLiving && !(entity instanceof EntityHuman)) {
CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity damager = this.getBukkitEntity();
org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();