mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
Add events for EntitySmallFireball
This commit is contained in:
parent
2759809ecb
commit
a1ad0c0103
@ -1,5 +1,14 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
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.ProjectileHitEvent;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
public class EntitySmallFireball extends EntityFireball {
|
public class EntitySmallFireball extends EntityFireball {
|
||||||
|
|
||||||
public EntitySmallFireball(World world) {
|
public EntitySmallFireball(World world) {
|
||||||
@ -14,9 +23,41 @@ public class EntitySmallFireball extends EntityFireball {
|
|||||||
|
|
||||||
protected void a(MovingObjectPosition movingobjectposition) {
|
protected void a(MovingObjectPosition movingobjectposition) {
|
||||||
if (!this.world.isStatic) {
|
if (!this.world.isStatic) {
|
||||||
|
// CraftBukkit start - projectile hit event
|
||||||
|
ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity());
|
||||||
|
final PluginManager pluginManager = this.world.getServer().getPluginManager();
|
||||||
|
pluginManager.callEvent(phe);
|
||||||
|
// CraftBukkit end
|
||||||
if (movingobjectposition.entity != null) {
|
if (movingobjectposition.entity != null) {
|
||||||
if (!movingobjectposition.entity.ax() && movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 5)) {
|
// CraftBukkit start - entity damage by entity event + combust event
|
||||||
movingobjectposition.entity.j(5);
|
if (!movingobjectposition.entity.ax()) { // check if not fireproof
|
||||||
|
boolean stick;
|
||||||
|
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
|
||||||
|
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||||
|
if (movingobjectposition.entity instanceof EntityLiving) {
|
||||||
|
|
||||||
|
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 5);
|
||||||
|
pluginManager.callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
stick = !projectile.doesBounce();
|
||||||
|
} else {
|
||||||
|
// this function returns if the fireball should stick in or not, i.e. !bounce
|
||||||
|
stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), event.getDamage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 5);
|
||||||
|
}
|
||||||
|
if (stick) {
|
||||||
|
// if the fireball 'sticks', ignite the target
|
||||||
|
EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(projectile, damagee, 5);
|
||||||
|
pluginManager.callEvent(combustEvent);
|
||||||
|
|
||||||
|
if (!combustEvent.isCancelled()) {
|
||||||
|
movingobjectposition.entity.j(combustEvent.getDuration());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int i = movingobjectposition.b;
|
int i = movingobjectposition.b;
|
||||||
|
Loading…
Reference in New Issue
Block a user