summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/minecraft/server/EntityArrow.java8
-rw-r--r--src/main/java/net/minecraft/server/EntityEgg.java8
-rw-r--r--src/main/java/net/minecraft/server/EntityFireball.java8
-rw-r--r--src/main/java/net/minecraft/server/EntityFish.java8
-rw-r--r--src/main/java/net/minecraft/server/EntityHuman.java21
-rw-r--r--src/main/java/net/minecraft/server/EntitySnowball.java8
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java23
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java3
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java3
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java2
12 files changed, 63 insertions, 33 deletions
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
index 69d40dfe..3e31abd8 100644
--- a/src/main/java/net/minecraft/server/EntityArrow.java
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
@@ -5,7 +5,7 @@ import java.util.List;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.Projectile;
-import org.bukkit.event.entity.EntityDamageByProjectileEvent;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
@@ -179,15 +179,15 @@ public class EntityArrow extends Entity {
Projectile projectile = (Projectile) this.getBukkitEntity();
// TODO deal with arrows being fired from a non-entity
- EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 4);
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 4);
server.getPluginManager().callEvent(event);
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
if (event.isCancelled()) {
- stick = !event.getBounce();
+ stick = !projectile.doesBounce();
} else {
// this function returns if the arrow should stick in or not, i.e. !bounce
- stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage());
+ stick = movingobjectposition.entity.damageEntity(this, event.getDamage());
}
} else {
stick = movingobjectposition.entity.damageEntity(this.shooter, 4);
diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java
index 58a204d7..50441dbb 100644
--- a/src/main/java/net/minecraft/server/EntityEgg.java
+++ b/src/main/java/net/minecraft/server/EntityEgg.java
@@ -6,7 +6,7 @@ import java.util.List;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
-import org.bukkit.event.entity.EntityDamageByProjectileEvent;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
@@ -161,14 +161,14 @@ public class EntityEgg extends Entity {
Projectile projectile = (Projectile) this.getBukkitEntity();
// TODO @see EntityArrow#162
- EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
- stick = !event.getBounce();
+ stick = !projectile.doesBounce();
} else {
// this function returns if the egg should stick in or not, i.e. !bounce
- stick = movingobjectposition.entity.damageEntity(this.thrower, event.getDamage());
+ stick = movingobjectposition.entity.damageEntity(this, event.getDamage());
}
} else {
stick = movingobjectposition.entity.damageEntity(this.thrower, 0);
diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java
index a025cbdb..7b7335b8 100644
--- a/src/main/java/net/minecraft/server/EntityFireball.java
+++ b/src/main/java/net/minecraft/server/EntityFireball.java
@@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.Explosive;
import org.bukkit.entity.Projectile;
-import org.bukkit.event.entity.EntityDamageByProjectileEvent;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
@@ -141,16 +141,16 @@ public class EntityFireball extends Entity {
Projectile projectile = (Projectile) this.getBukkitEntity();
// TODO @see EntityArrow#162
- EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
this.world.getServer().getPluginManager().callEvent(event);
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
if (event.isCancelled()) {
- stick = !event.getBounce();
+ stick = !projectile.doesBounce();
} else {
// this function returns if the fireball should stick in or not, i.e. !bounce
- stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage());
+ stick = movingobjectposition.entity.damageEntity(this, event.getDamage());
}
} else {
stick = movingobjectposition.entity.damageEntity(this.shooter, 0);
diff --git a/src/main/java/net/minecraft/server/EntityFish.java b/src/main/java/net/minecraft/server/EntityFish.java
index ed704a9c..ff63566d 100644
--- a/src/main/java/net/minecraft/server/EntityFish.java
+++ b/src/main/java/net/minecraft/server/EntityFish.java
@@ -4,7 +4,7 @@ import java.util.List;
// CraftBukkit start
import org.bukkit.entity.Projectile;
-import org.bukkit.event.entity.EntityDamageByProjectileEvent;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerFishEvent;
// CraftBukkit end
@@ -197,14 +197,14 @@ public class EntityFish extends Entity {
Projectile projectile = (Projectile) this.getBukkitEntity();
// TODO @see EntityArrow#162
- EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
- stick = !event.getBounce();
+ stick = !projectile.doesBounce();
} else {
// this function returns if the fish should stick in or not, i.e. !bounce
- stick = movingobjectposition.entity.damageEntity(this.owner, event.getDamage());
+ stick = movingobjectposition.entity.damageEntity(this, event.getDamage());
}
} else {
stick = movingobjectposition.entity.damageEntity(this.owner, 0);
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index f8e31db2..d2fa3db1 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -7,6 +7,7 @@ import java.util.List;
import org.bukkit.craftbukkit.entity.CraftItem;
import org.bukkit.craftbukkit.TrigMath;
import org.bukkit.entity.Player;
+import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
@@ -416,17 +417,21 @@ public abstract class EntityHuman extends EntityLiving {
if (object instanceof 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.
- org.bukkit.entity.Entity damager = ((Entity) object).getBukkitEntity();
- org.bukkit.entity.Entity damagee = this.getBukkitEntity();
- EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i);
- this.world.getServer().getPluginManager().callEvent(event);
+ // We handle projectiles in their individual classes!
+ if (!(entity.getBukkitEntity() instanceof Projectile)) {
+ org.bukkit.entity.Entity damager = ((Entity) object).getBukkitEntity();
+ org.bukkit.entity.Entity damagee = this.getBukkitEntity();
- if (event.isCancelled() || event.getDamage() == 0) {
- return false;
- }
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i);
+ this.world.getServer().getPluginManager().callEvent(event);
- i = event.getDamage();
+ if (event.isCancelled() || event.getDamage() == 0) {
+ return false;
+ }
+
+ i = event.getDamage();
+ }
// CraftBukkit end
this.a((EntityLiving) object, false);
diff --git a/src/main/java/net/minecraft/server/EntitySnowball.java b/src/main/java/net/minecraft/server/EntitySnowball.java
index d1e66f8c..d89221a8 100644
--- a/src/main/java/net/minecraft/server/EntitySnowball.java
+++ b/src/main/java/net/minecraft/server/EntitySnowball.java
@@ -5,7 +5,7 @@ import java.util.List;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.Projectile;
-import org.bukkit.event.entity.EntityDamageByProjectileEvent;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
// CraftBukkit end
@@ -159,15 +159,15 @@ public class EntitySnowball extends Entity {
Projectile projectile = (Projectile) this.getBukkitEntity();
// TODO @see EntityArrow#162
- EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
this.world.getServer().getPluginManager().callEvent(event);
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
if (event.isCancelled()) {
- stick = !event.getBounce();
+ stick = !projectile.doesBounce();
} else {
// this function returns if the snowball should stick in or not, i.e. !bounce
- stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage());
+ stick = movingobjectposition.entity.damageEntity(this, event.getDamage());
}
} else {
stick = movingobjectposition.entity.damageEntity(this.shooter, 0);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java
new file mode 100644
index 00000000..7c162551
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java
@@ -0,0 +1,23 @@
+package org.bukkit.craftbukkit.entity;
+
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.entity.Projectile;
+
+public abstract class AbstractProjectile extends CraftEntity implements Projectile {
+
+ private boolean doesBounce;
+
+ public AbstractProjectile(CraftServer server, net.minecraft.server.Entity entity) {
+ super(server, entity);
+ doesBounce = false;
+ }
+
+ public boolean doesBounce() {
+ return doesBounce;
+ }
+
+ public void setBounce(boolean doesBounce) {
+ this.doesBounce = doesBounce;
+ }
+
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
index 84b820c5..b23cdc4a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
@@ -7,7 +7,8 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
-public class CraftArrow extends CraftEntity implements Arrow {
+public class CraftArrow extends AbstractProjectile implements Arrow {
+
public CraftArrow(CraftServer server, EntityArrow entity) {
super(server, entity);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java
index 66e1ad57..215a8f2b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java
@@ -7,7 +7,8 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Egg;
import org.bukkit.entity.LivingEntity;
-public class CraftEgg extends CraftEntity implements Egg {
+public class CraftEgg extends AbstractProjectile implements Egg {
+
public CraftEgg(CraftServer server, EntityEgg entity) {
super(server, entity);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java
index 853ac1ab..cdc8b396 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java
@@ -8,7 +8,7 @@ import org.bukkit.entity.Fireball;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
-public class CraftFireball extends CraftEntity implements Fireball {
+public class CraftFireball extends AbstractProjectile implements Fireball {
public CraftFireball(CraftServer server, EntityFireball entity) {
super(server, entity);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java
index 43ec479d..61ccd0de 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java
@@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Fish;
import org.bukkit.entity.LivingEntity;
-public class CraftFish extends CraftEntity implements Fish {
+public class CraftFish extends AbstractProjectile implements Fish {
public CraftFish(CraftServer server, EntityFish entity) {
super(server, entity);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java
index 488b7869..4120ac40 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java
@@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Snowball;
-public class CraftSnowball extends CraftEntity implements Snowball {
+public class CraftSnowball extends AbstractProjectile implements Snowball {
public CraftSnowball(CraftServer server, EntitySnowball entity) {
super(server, entity);
}