3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

[Bleeding] Fixed potions throwing double events. Fixes BUKKIT-1332

Dieser Commit ist enthalten in:
feildmaster 2012-03-25 04:21:25 -05:00 committet von Warren Loo
Ursprung b45184fdf8
Commit 9d0ea52021
2 geänderte Dateien mit 10 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -1,13 +1,12 @@
package net.minecraft.server;
// CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.craftbukkit.potion.CraftPotionEffectType;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.potion.PotionEffectType;
// CraftBukkit end
public class MobEffectList {
@ -86,7 +85,6 @@ public class MobEffectList {
if (entityliving.getHealth() > 1) {
// CraftBukkit start
EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(null, entityliving, DamageCause.POISON, 1);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getDamage() > 0) {
entityliving.damageEntity(DamageSource.MAGIC, event.getDamage());
@ -99,7 +97,6 @@ public class MobEffectList {
if (this.id == HARM.id && !entityliving.aN() || this.id == HEAL.id && entityliving.aN()) {
// CraftBukkit start
EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(null, entityliving, DamageCause.MAGIC, 6 << i);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getDamage() > 0) {
entityliving.damageEntity(DamageSource.MAGIC, event.getDamage());
@ -124,18 +121,11 @@ public class MobEffectList {
if (this.id == HARM.id && !entityliving1.aN() || this.id == HEAL.id && entityliving1.aN()) {
j = (int) (d0 * (double) (6 << i) + 0.5D);
// CraftBukkit start
EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(potion != null ? potion : entityliving, entityliving1, DamageCause.MAGIC, j);
j = event.getDamage();
if (event.isCancelled() || j == 0) {
return;
}
// CraftBukkit end
if (entityliving == null) {
entityliving1.damageEntity(DamageSource.MAGIC, j);
} else {
entityliving1.damageEntity(DamageSource.b(entityliving1, entityliving), j);
// CraftBukkit - The "damager" needs to be the potion
entityliving1.damageEntity(DamageSource.b(potion != null ? potion : entityliving1, entityliving), j);
}
}
} else {

Datei anzeigen

@ -364,14 +364,17 @@ public class CraftEventFactory {
public static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSource source, int damage) {
Entity damager = source.getEntity();
EntityDamageEvent.DamageCause cause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
DamageCause cause = DamageCause.ENTITY_ATTACK;
if (source instanceof EntityDamageSourceIndirect) {
damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
if (damager.getBukkitEntity() instanceof Projectile) {
cause = EntityDamageEvent.DamageCause.PROJECTILE;
} // Else, magic..?
if (damager.getBukkitEntity() instanceof ThrownPotion) {
cause = DamageCause.MAGIC;
} else if (damager.getBukkitEntity() instanceof Projectile) {
cause = DamageCause.PROJECTILE;
}
}
return callEntityDamageEvent(damager, entity, cause, damage);
}