mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 13:07:06 +01:00
Teach EnderDragon how to throw EntityDamage events
Relates to BUKKIT-129
This commit is contained in:
parent
b1a3aa602a
commit
bf60f44013
1 changed files with 17 additions and 1 deletions
|
@ -1,5 +1,9 @@
|
||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -388,8 +392,20 @@ public class EntityEnderDragon extends EntityComplex {
|
||||||
Entity entity = (Entity) list.get(i);
|
Entity entity = (Entity) list.get(i);
|
||||||
|
|
||||||
if (entity instanceof EntityLiving) {
|
if (entity instanceof EntityLiving) {
|
||||||
|
// CraftBukkit start - throw damage events when the dragon attacks
|
||||||
|
// The EntityHuman case is handled in EntityHuman, so don't throw it here
|
||||||
|
if (!(entity instanceof EntityHuman)) {
|
||||||
|
EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, 10);
|
||||||
|
Bukkit.getPluginManager().callEvent(damageEvent);
|
||||||
|
|
||||||
|
if (!damageEvent.isCancelled()) {
|
||||||
|
entity.damageEntity(DamageSource.mobAttack(this), damageEvent.getDamage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
entity.damageEntity(DamageSource.mobAttack(this), 10);
|
entity.damageEntity(DamageSource.mobAttack(this), 10);
|
||||||
}
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue