summaryrefslogtreecommitdiffstats
path: root/src/main/java/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net')
-rw-r--r--src/main/java/net/minecraft/server/EntityArrow.java4
-rw-r--r--src/main/java/net/minecraft/server/EntityEgg.java8
-rw-r--r--src/main/java/net/minecraft/server/EntityEnderCrystal.java5
-rw-r--r--src/main/java/net/minecraft/server/EntityFireball.java37
-rw-r--r--src/main/java/net/minecraft/server/EntityFishingHook.java3
-rw-r--r--src/main/java/net/minecraft/server/EntityHuman.java44
-rw-r--r--src/main/java/net/minecraft/server/EntityLiving.java11
-rw-r--r--src/main/java/net/minecraft/server/EntityMonster.java25
-rw-r--r--src/main/java/net/minecraft/server/EntitySmallFireball.java36
-rw-r--r--src/main/java/net/minecraft/server/EntitySnowball.java38
10 files changed, 47 insertions, 164 deletions
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
index d258e0fa..ffc219cb 100644
--- a/src/main/java/net/minecraft/server/EntityArrow.java
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
@@ -221,8 +221,8 @@ public class EntityArrow extends Entity {
}
// CraftBukkit end
}
- // CraftBukkit - entity.damageEntity -> event function
- if (org.bukkit.craftbukkit.event.CraftEventFactory.handleProjectileEvent(projectile, entity, damagesource, l)) {
+
+ if (movingobjectposition.entity.damageEntity(damagesource, l)) {
if (movingobjectposition.entity instanceof EntityLiving) {
++((EntityLiving) movingobjectposition.entity).aI;
if (this.n > 0) {
diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java
index 4b311eb7..167c1e84 100644
--- a/src/main/java/net/minecraft/server/EntityEgg.java
+++ b/src/main/java/net/minecraft/server/EntityEgg.java
@@ -23,13 +23,11 @@ public class EntityEgg extends EntityProjectile {
}
protected void a(MovingObjectPosition movingobjectposition) {
- // CraftBukkit start
- if (movingobjectposition.entity != null) {
- if (org.bukkit.craftbukkit.event.CraftEventFactory.handleProjectileEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), movingobjectposition.entity, DamageSource.projectile(this, this.shooter), 0)) {
- ; // Original code does nothing *yet*
- }
+ if (movingobjectposition.entity != null && movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), 0)) {
+ ;
}
+ // CraftBukkit start
boolean hatching = !this.world.isStatic && this.random.nextInt(8) == 0;
int numHatching = (this.random.nextInt(32) == 0) ? 4 : 1;
if (!hatching) {
diff --git a/src/main/java/net/minecraft/server/EntityEnderCrystal.java b/src/main/java/net/minecraft/server/EntityEnderCrystal.java
index 5079d229..cd48def2 100644
--- a/src/main/java/net/minecraft/server/EntityEnderCrystal.java
+++ b/src/main/java/net/minecraft/server/EntityEnderCrystal.java
@@ -50,6 +50,11 @@ public class EntityEnderCrystal extends Entity {
this.b = 0;
if (this.b <= 0) {
if (!this.world.isStatic) {
+ // CraftBukkit start - All non-living entities need this
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, i)) {
+ return false;
+ }
+ // CraftBukkit end
this.die();
this.world.explode(this, this.locX, this.locY, this.locZ, 6.0F); // CraftBukkit - (Entity) null -> this.
} else {
diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java
index ae7cd6f8..b4616af8 100644
--- a/src/main/java/net/minecraft/server/EntityFireball.java
+++ b/src/main/java/net/minecraft/server/EntityFireball.java
@@ -5,7 +5,6 @@ import java.util.List;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.entity.Explosive;
-import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
// CraftBukkit end
@@ -137,6 +136,12 @@ public class EntityFireball extends Entity {
if (movingobjectposition != null) {
this.a(movingobjectposition);
+ // CraftBukkit start
+ if (this.dead) {
+ ProjectileHitEvent phe = new ProjectileHitEvent((org.bukkit.entity.Projectile) this.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(phe);
+ }
+ // CraftBukkit end
}
this.locX += this.motX;
@@ -189,30 +194,18 @@ public class EntityFireball extends Entity {
protected void a(MovingObjectPosition movingobjectposition) {
if (!this.world.isStatic) {
+ if (movingobjectposition.entity != null && movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 4)) {
+ ;
+ }
// CraftBukkit start
- Projectile projectile = (Projectile) this.getBukkitEntity();
- ProjectileHitEvent phe = new ProjectileHitEvent(projectile);
- this.world.getServer().getPluginManager().callEvent(phe);
- // CraftBukkit end
- if (!this.world.isStatic) {
- // CraftBukkit start
- if (movingobjectposition.entity != null) {
- if (org.bukkit.craftbukkit.event.CraftEventFactory.handleProjectileEvent(projectile, movingobjectposition.entity, DamageSource.projectile(this, this.shooter), 0)) {
- ;
- }
- }
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) CraftEntity.getEntity(this.world.getServer(), this));
+ this.world.getServer().getPluginManager().callEvent(event);
- ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) CraftEntity.getEntity(this.world.getServer(), this));
- this.world.getServer().getPluginManager().callEvent(event);
-
- if (!event.isCancelled()) {
- // give 'this' instead of (Entity) null so we know what causes the damage
- this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
- }
- // CraftBukkit end
+ if (!event.isCancelled()) {
+ // give 'this' instead of (Entity) null so we know what causes the damage
+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
}
-
- // this.world.createExplosion((Entity) null, this.locX, this.locY, this.locZ, 1.0F, true); // CraftBukkit
+ // CraftBukkit end
this.die();
}
}
diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java
index 1c54ec2a..ca0fc835 100644
--- a/src/main/java/net/minecraft/server/EntityFishingHook.java
+++ b/src/main/java/net/minecraft/server/EntityFishingHook.java
@@ -184,8 +184,7 @@ public class EntityFishingHook extends Entity {
if (movingobjectposition != null) {
if (movingobjectposition.entity != null) {
- // CraftBukkit - entity.damageEntity -> event function
- if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleProjectileEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), entity, DamageSource.projectile(this, this.owner), 0)) {
+ if (movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.owner), 0)) {
this.hooked = movingobjectposition.entity;
}
} else {
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index a5da800d..448c4f9f 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -9,15 +9,10 @@ import org.bukkit.craftbukkit.entity.CraftItem;
import org.bukkit.craftbukkit.TrigMath;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
-import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityCombustByEntityEvent;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerBedLeaveEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
-import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
// CraftBukkit end
public abstract class EntityHuman extends EntityLiving {
@@ -309,7 +304,7 @@ public abstract class EntityHuman extends EntityLiving {
if (this.world.difficulty == 0 && this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 * 12 == 0) {
// CraftBukkit - added regain reason of "REGEN" for filtering purposes.
- this.heal(1, RegainReason.REGEN);
+ this.heal(1, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN);
}
this.inventory.i();
@@ -593,27 +588,6 @@ public abstract class EntityHuman extends EntityLiving {
}
if (entity1 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.
-
- // We handle projectiles in their individual classes!
- boolean isProjectile = damagesource instanceof EntityDamageSourceIndirect && ((EntityDamageSourceIndirect) damagesource).getProximateDamageSource().getBukkitEntity() instanceof Projectile;
-
- if (!isProjectile) {
- org.bukkit.entity.Entity damager = ((Entity) entity1).getBukkitEntity();
- org.bukkit.entity.Entity damagee = this.getBukkitEntity();
-
- EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i);
- Bukkit.getPluginManager().callEvent(event);
-
- if (event.isCancelled() || event.getDamage() == 0) {
- return false;
- }
-
- i = event.getDamage();
- }
- // CraftBukkit end
-
this.a((EntityLiving) entity1, false);
}
@@ -771,22 +745,6 @@ public abstract class EntityHuman extends EntityLiving {
i += this.random.nextInt(i / 2 + 2);
}
- // CraftBukkit start - Don't call the event when the entity is human since it will be called with damageEntity
- if ((entity instanceof EntityLiving || entity instanceof EntityComplexPart || entity instanceof EntityEnderCrystal) && !(entity instanceof EntityHuman)) {
- org.bukkit.entity.Entity damager = this.getBukkitEntity();
- org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
-
- EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i);
- Bukkit.getPluginManager().callEvent(event);
-
- if (event.isCancelled() || event.getDamage() == 0) {
- return;
- }
-
- i = event.getDamage();
- }
- // CraftBukkit end
-
i += k;
boolean flag1 = entity.damageEntity(DamageSource.playerAttack(this), i);
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index abf1ec22..22bf409f 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -602,6 +602,16 @@ public abstract class EntityLiving extends Entity {
this.aE = 1.5F;
boolean flag = true;
+ // CraftBukkit start
+ if (damagesource instanceof EntityDamageSource) {
+ org.bukkit.event.entity.EntityDamageEvent event = CraftEventFactory.handleEntityDamageEvent(this, damagesource, i);
+ if (event.isCancelled()) {
+ return false;
+ }
+ i = event.getDamage();
+ }
+ // CraftBukkit end
+
if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
if (i <= this.lastDamage) {
return false;
@@ -829,7 +839,6 @@ public abstract class EntityLiving extends Entity {
this.damageEntity(DamageSource.FALL, i);
}
-
// CraftBukkit end
int j = this.world.getTypeId(MathHelper.floor(this.locX), MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height), MathHelper.floor(this.locZ));
diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java
index 5f6dcf65..170dfcd7 100644
--- a/src/main/java/net/minecraft/server/EntityMonster.java
+++ b/src/main/java/net/minecraft/server/EntityMonster.java
@@ -1,11 +1,6 @@
package net.minecraft.server;
-// CraftBukkit start
-import org.bukkit.Bukkit;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.entity.EntityTargetEvent;
-// CraftBukkit end
+import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
public abstract class EntityMonster extends EntityCreature implements IMonster {
@@ -82,24 +77,6 @@ public abstract class EntityMonster extends EntityCreature implements IMonster {
i -= 2 << this.getEffect(MobEffectList.WEAKNESS).getAmplifier();
}
- // CraftBukkit start - this is still duplicated here and EntityHuman because it's possible for lastDamage EntityMonster
- // to damage another EntityMonster, and we want to catch those events.
- // This does not fire events for slime attacks, av they're not lastDamage EntityMonster.
- if (entity instanceof EntityLiving && !(entity instanceof EntityHuman)) {
- org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
-
- EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(this.getBukkitEntity(), damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, this.damage);
- Bukkit.getPluginManager().callEvent(event);
- i = event.getDamage();
-
- if (!event.isCancelled()) {
- return entity.damageEntity(DamageSource.mobAttack(this), i);
- }
-
- return false;
- }
- // CraftBukkit end
-
return entity.damageEntity(DamageSource.mobAttack(this), i);
}
diff --git a/src/main/java/net/minecraft/server/EntitySmallFireball.java b/src/main/java/net/minecraft/server/EntitySmallFireball.java
index 6f632700..6cd2008c 100644
--- a/src/main/java/net/minecraft/server/EntitySmallFireball.java
+++ b/src/main/java/net/minecraft/server/EntitySmallFireball.java
@@ -1,12 +1,6 @@
package net.minecraft.server;
-// CraftBukkit start
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Projectile;
-import org.bukkit.event.entity.EntityCombustByEntityEvent;
-import org.bukkit.event.entity.ProjectileHitEvent;
-import org.bukkit.plugin.PluginManager;
-// CraftBukkit end
+import org.bukkit.event.entity.EntityCombustByEntityEvent; // CraftBukkit
public class EntitySmallFireball extends EntityFireball {
@@ -27,26 +21,14 @@ public class EntitySmallFireball extends EntityFireball {
protected void a(MovingObjectPosition movingobjectposition) {
if (!this.world.isStatic) {
- // CraftBukkit start - projectile hit event
- Projectile projectile = (Projectile) this.getBukkitEntity();
- ProjectileHitEvent phe = new ProjectileHitEvent(projectile);
- final PluginManager pluginManager = Bukkit.getPluginManager();
- pluginManager.callEvent(phe);
- // CraftBukkit end
- final Entity movingEntity = movingobjectposition.entity;
- if (movingEntity != null) {
- // CraftBukkit start - entity damage by entity event + combust event
- if (!movingEntity.isFireproof()) { // check if not fireproof
- org.bukkit.entity.Entity damagee = movingEntity.getBukkitEntity();
-
- if (org.bukkit.craftbukkit.event.CraftEventFactory.handleProjectileEvent(projectile, movingobjectposition.entity, DamageSource.projectile(this, this.shooter), 0)) {
- // if the fireball 'sticks', ignite the target
- EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(projectile, damagee, 5);
- pluginManager.callEvent(combustEvent);
-
- if (!combustEvent.isCancelled()) {
- movingEntity.setOnFire(combustEvent.getDuration());
- }
+ if (movingobjectposition.entity != null) {
+ if (!movingobjectposition.entity.isFireproof() && movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 5)) {
+ // CraftBukkit start - entity damage by entity event + combust event
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), movingobjectposition.entity.getBukkitEntity(), 5);
+ movingobjectposition.entity.world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ movingobjectposition.entity.setOnFire(event.getDuration());
}
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/EntitySnowball.java b/src/main/java/net/minecraft/server/EntitySnowball.java
deleted file mode 100644
index 3dc5b9ac..00000000
--- a/src/main/java/net/minecraft/server/EntitySnowball.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package net.minecraft.server;
-
-public class EntitySnowball extends EntityProjectile {
-
- public EntitySnowball(World world) {
- super(world);
- }
-
- public EntitySnowball(World world, EntityLiving entityliving) {
- super(world, entityliving);
- }
-
- public EntitySnowball(World world, double d0, double d1, double d2) {
- super(world, d0, d1, d2);
- }
-
- protected void a(MovingObjectPosition movingobjectposition) {
- if (movingobjectposition.entity != null) {
- int b0 = 0; // CraftBukkit - byte -> int
-
- if (movingobjectposition.entity instanceof EntityBlaze) {
- b0 = 3;
- }
- // CraftBukkit - entity.damageEntity -> event function
- if (org.bukkit.craftbukkit.event.CraftEventFactory.handleProjectileEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), movingobjectposition.entity, DamageSource.projectile(this, this.shooter), b0)) {
- ;
- }
- }
-
- for (int i = 0; i < 8; ++i) {
- this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D);
- }
-
- if (!this.world.isStatic) {
- this.die();
- }
- }
-}