3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 21:10:17 +01:00

Clean entity.damage functions. Fixes BUKKIT-1822

Dieser Commit ist enthalten in:
feildmaster 2012-07-01 05:00:48 -05:00
Ursprung ff09ff07f9
Commit 0a0d5ebf20
2 geänderte Dateien mit 7 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -1,11 +1,8 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.DamageSource;
import net.minecraft.server.EntityComplex; import net.minecraft.server.EntityComplex;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.ComplexLivingEntity; import org.bukkit.entity.ComplexLivingEntity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.LivingEntity;
public abstract class CraftComplexLivingEntity extends CraftLivingEntity implements ComplexLivingEntity { public abstract class CraftComplexLivingEntity extends CraftLivingEntity implements ComplexLivingEntity {
public CraftComplexLivingEntity(CraftServer server, EntityComplex entity) { public CraftComplexLivingEntity(CraftServer server, EntityComplex entity) {
@ -21,21 +18,4 @@ public abstract class CraftComplexLivingEntity extends CraftLivingEntity impleme
public String toString() { public String toString() {
return "CraftComplexLivingEntity"; 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);
}
}
} }

Datei anzeigen

@ -8,6 +8,7 @@ import java.util.List;
import net.minecraft.server.DamageSource; import net.minecraft.server.DamageSource;
import net.minecraft.server.EntityArrow; import net.minecraft.server.EntityArrow;
import net.minecraft.server.EntityComplex;
import net.minecraft.server.EntityEgg; import net.minecraft.server.EntityEgg;
import net.minecraft.server.EntityEnderPearl; import net.minecraft.server.EntityEnderPearl;
import net.minecraft.server.EntityFireball; import net.minecraft.server.EntityFireball;
@ -147,7 +148,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} }
public void damage(int amount) { public void damage(int amount) {
entity.damageEntity(DamageSource.GENERIC, amount); damage(amount, null);
} }
public void damage(int amount, org.bukkit.entity.Entity source) { 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()); 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() { public Location getEyeLocation() {