Clean entity.damage functions. Fixes BUKKIT-1822
Dieser Commit ist enthalten in:
Ursprung
ff09ff07f9
Commit
0a0d5ebf20
@ -1,11 +1,8 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.DamageSource;
|
||||
import net.minecraft.server.EntityComplex;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.ComplexLivingEntity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public abstract class CraftComplexLivingEntity extends CraftLivingEntity implements ComplexLivingEntity {
|
||||
public CraftComplexLivingEntity(CraftServer server, EntityComplex entity) {
|
||||
@ -21,21 +18,4 @@ public abstract class CraftComplexLivingEntity extends CraftLivingEntity impleme
|
||||
public String toString() {
|
||||
return "CraftComplexLivingEntity";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(int amount, org.bukkit.entity.Entity source) {
|
||||
DamageSource reason = DamageSource.GENERIC;
|
||||
|
||||
if (source instanceof HumanEntity) {
|
||||
reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
|
||||
} else if (source instanceof LivingEntity) {
|
||||
reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
|
||||
}
|
||||
|
||||
if (entity instanceof EntityComplex) {
|
||||
((EntityComplex) entity).dealDamage(reason, amount);
|
||||
} else {
|
||||
entity.damageEntity(reason, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.server.DamageSource;
|
||||
import net.minecraft.server.EntityArrow;
|
||||
import net.minecraft.server.EntityComplex;
|
||||
import net.minecraft.server.EntityEgg;
|
||||
import net.minecraft.server.EntityEnderPearl;
|
||||
import net.minecraft.server.EntityFireball;
|
||||
@ -147,7 +148,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
public void damage(int amount) {
|
||||
entity.damageEntity(DamageSource.GENERIC, amount);
|
||||
damage(amount, null);
|
||||
}
|
||||
|
||||
public void damage(int amount, org.bukkit.entity.Entity source) {
|
||||
@ -159,7 +160,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
|
||||
}
|
||||
|
||||
entity.damageEntity(reason, amount);
|
||||
if (entity instanceof EntityComplex) {
|
||||
((EntityComplex) entity).dealDamage(reason, amount);
|
||||
} else {
|
||||
entity.damageEntity(reason, amount);
|
||||
}
|
||||
}
|
||||
|
||||
public Location getEyeLocation() {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren