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

import net.minecraft.world.entity.EntityType;
import net.minecraft.server.level.ServerLevel;
import java.util.Map;
import net.minecraft.world.entity.LivingEntity;
import com.google.common.collect.ImmutableMap;
import net.minecraft.world.entity.ai.memory.MemoryStatus;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import net.minecraft.world.entity.ai.behavior.Behavior;

public class RememberIfHoglinWasKilled<E extends Piglin> extends Behavior<E> {
    public RememberIfHoglinWasKilled() {
        super(ImmutableMap.<MemoryModuleType<LivingEntity>, MemoryStatus>of(MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_PRESENT, (MemoryModuleType<LivingEntity>)MemoryModuleType.HUNTED_RECENTLY, MemoryStatus.REGISTERED));
    }
    
    @Override
    protected void start(final ServerLevel zd, final E bdc, final long long3) {
        if (this.isAttackTargetDeadHoglin(bdc)) {
            PiglinAi.dontKillAnyMoreHoglinsForAWhile(bdc);
        }
    }
    
    private boolean isAttackTargetDeadHoglin(final E bdc) {
        final LivingEntity aoy3 = bdc.getBrain().<LivingEntity>getMemory(MemoryModuleType.ATTACK_TARGET).get();
        return aoy3.getType() == EntityType.HOGLIN && aoy3.isDeadOrDying();
    }
}
