#1390: Improve internal handling of damage sources
By: Doc <nachito94@msn.com>
This commit is contained in:
parent
f01e218606
commit
066665a979
12 changed files with 72 additions and 48 deletions
|
@ -41,13 +41,13 @@ public class CraftDamageSource implements DamageSource {
|
|||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getCausingEntity() {
|
||||
net.minecraft.world.entity.Entity entity = this.getHandle().getCausingEntity();
|
||||
net.minecraft.world.entity.Entity entity = this.getHandle().getEntity();
|
||||
return (entity != null) ? entity.getBukkitEntity() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getDirectEntity() {
|
||||
net.minecraft.world.entity.Entity entity = this.getHandle().getDirectEntity();
|
||||
net.minecraft.world.entity.Entity entity = this.getHandle().getDamager();
|
||||
return (entity != null) ? entity.getBukkitEntity() : null;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class CraftDamageSource implements DamageSource {
|
|||
|
||||
@Override
|
||||
public boolean isIndirect() {
|
||||
return this.getHandle().getCausingEntity() != this.getHandle().getDirectEntity();
|
||||
return this.getHandle().getEntity() != this.getHandle().getDamager();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -939,7 +939,7 @@ public class CraftEventFactory {
|
|||
|
||||
private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSource source, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled) {
|
||||
CraftDamageSource bukkitDamageSource = new CraftDamageSource(source);
|
||||
Entity damager = (bukkitDamageSource.isIndirect() && source.getDirectEntity() != null) ? source.getDirectEntity() : source.getCausingEntity();
|
||||
Entity damager = (source.getDamager() != null) ? source.getDamager() : source.getEntity();
|
||||
if (source.is(DamageTypeTags.IS_EXPLOSION)) {
|
||||
if (damager == null) {
|
||||
return callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue