package net.minecraft.world.entity.monster.hoglin;

import net.minecraft.world.phys.Vec3;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.LivingEntity;

public interface HoglinBase {
    int getAttackAnimationRemainingTicks();
    
    default boolean hurtAndThrowTarget(final LivingEntity aoy1, final LivingEntity aoy2) {
        final float float4 = (float)aoy1.getAttributeValue(Attributes.ATTACK_DAMAGE);
        float float5;
        if (!aoy1.isBaby() && (int)float4 > 0) {
            float5 = float4 / 2.0f + aoy1.level.random.nextInt((int)float4);
        }
        else {
            float5 = float4;
        }
        final boolean boolean5 = aoy2.hurt(DamageSource.mobAttack(aoy1), float5);
        if (boolean5) {
            aoy1.doEnchantDamageEffects(aoy1, aoy2);
            if (!aoy1.isBaby()) {
                throwTarget(aoy1, aoy2);
            }
        }
        return boolean5;
    }
    
    default void throwTarget(final LivingEntity aoy1, final LivingEntity aoy2) {
        final double double3 = aoy1.getAttributeValue(Attributes.ATTACK_KNOCKBACK);
        final double double4 = aoy2.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
        final double double5 = double3 - double4;
        if (double5 <= 0.0) {
            return;
        }
        final double double6 = aoy2.getX() - aoy1.getX();
        final double double7 = aoy2.getZ() - aoy1.getZ();
        final float float13 = (float)(aoy1.level.random.nextInt(21) - 10);
        final double double8 = double5 * (aoy1.level.random.nextFloat() * 0.5f + 0.2f);
        final Vec3 dem16 = new Vec3(double6, 0.0, double7).normalize().scale(double8).yRot(float13);
        final double double9 = double5 * aoy1.level.random.nextFloat() * 0.5;
        aoy2.push(dem16.x, double9, dem16.z);
        aoy2.hurtMarked = true;
    }
}
