Search in sources :

Example 1 with LivingAccessor

use of net.sistr.littlemaidrebirth.util.LivingAccessor in project LittleMaidReBirth-Architectury by SistrScarlet.

the class LittleMaidEntity method damage.

@Override
public boolean damage(DamageSource source, float amount) {
    if (!world.isClient) {
        // 味方のが当たってもちゃんと動くようにフレンド判定より前
        if (amount <= 0 && source.getSource() instanceof SnowballEntity) {
            play(LMSounds.HURT_SNOW);
            return false;
        }
    }
    Entity attacker = source.getAttacker();
    // Friendからの攻撃を除外
    if (attacker instanceof LivingEntity && isFriend((LivingEntity) attacker)) {
        return false;
    }
    boolean isHurtTime = 0 < this.hurtTime;
    boolean result = super.damage(source, amount);
    if (!world.isClient && !isHurtTime) {
        if (!result || amount <= 0F) {
            play(LMSounds.HURT_NO_DAMAGE);
        } else if (amount > 0F && ((LivingAccessor) this).blockedByShield_LM(source)) {
            play(LMSounds.HURT_GUARD);
        } else if (source == DamageSource.FALL) {
            play(LMSounds.HURT_FALL);
        } else if (source.isFire()) {
            play(LMSounds.HURT_FIRE);
        } else {
            play(LMSounds.HURT);
        }
    }
    return result;
}
Also used : CustomPacketEntity(net.sistr.lmml.network.util.CustomPacketEntity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) SnowballEntity(net.minecraft.entity.projectile.thrown.SnowballEntity) LivingAccessor(net.sistr.littlemaidrebirth.util.LivingAccessor) SnowballEntity(net.minecraft.entity.projectile.thrown.SnowballEntity)

Example 2 with LivingAccessor

use of net.sistr.littlemaidrebirth.util.LivingAccessor in project LittleMaidReBirth-Fabric by SistrScarlet.

the class LittleMaidEntity method damage.

@Override
public boolean damage(DamageSource source, float amount) {
    if (!world.isClient) {
        // 味方のが当たってもちゃんと動くようにフレンド判定より前
        if (amount <= 0 && source.getSource() instanceof SnowballEntity) {
            play(LMSounds.HURT_SNOW);
            return false;
        }
    }
    Entity attacker = source.getAttacker();
    // Friendからの攻撃を除外
    if (attacker instanceof LivingEntity && isFriend((LivingEntity) attacker)) {
        return false;
    }
    boolean isHurtTime = 0 < this.hurtTime;
    boolean result = super.damage(source, amount);
    if (!world.isClient && !isHurtTime) {
        if (!result || amount <= 0F) {
            play(LMSounds.HURT_NO_DAMAGE);
        } else if (amount > 0F && ((LivingAccessor) this).blockedByShield_LM(source)) {
            play(LMSounds.HURT_GUARD);
        } else if (source == DamageSource.FALL) {
            play(LMSounds.HURT_FALL);
        } else if (source.isFire()) {
            play(LMSounds.HURT_FIRE);
        } else {
            play(LMSounds.HURT);
        }
    }
    return result;
}
Also used : CustomPacketEntity(net.sistr.lmml.network.util.CustomPacketEntity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) SnowballEntity(net.minecraft.entity.projectile.thrown.SnowballEntity) LivingAccessor(net.sistr.littlemaidrebirth.util.LivingAccessor) SnowballEntity(net.minecraft.entity.projectile.thrown.SnowballEntity)

Aggregations

PassiveEntity (net.minecraft.entity.passive.PassiveEntity)2 TameableEntity (net.minecraft.entity.passive.TameableEntity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 SnowballEntity (net.minecraft.entity.projectile.thrown.SnowballEntity)2 LivingAccessor (net.sistr.littlemaidrebirth.util.LivingAccessor)2 CustomPacketEntity (net.sistr.lmml.network.util.CustomPacketEntity)2