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

import net.minecraft.world.entity.LivingEntity;
import net.minecraft.server.level.ServerLevel;
import java.util.Map;
import net.minecraft.world.entity.monster.hoglin.Hoglin;
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 StartHuntingHoglin<E extends Piglin> extends Behavior<E> {
    public StartHuntingHoglin() {
        super(ImmutableMap.<MemoryModuleType<Hoglin>, MemoryStatus>of(MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryStatus.VALUE_PRESENT, (MemoryModuleType<Hoglin>)MemoryModuleType.ANGRY_AT, MemoryStatus.VALUE_ABSENT, (MemoryModuleType<Hoglin>)MemoryModuleType.HUNTED_RECENTLY, MemoryStatus.VALUE_ABSENT, (MemoryModuleType<Hoglin>)MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryStatus.REGISTERED));
    }
    
    @Override
    protected boolean checkExtraStartConditions(final ServerLevel zd, final Piglin bdc) {
        return !bdc.isBaby() && !PiglinAi.hasAnyoneNearbyHuntedRecently(bdc);
    }
    
    @Override
    protected void start(final ServerLevel zd, final E bdc, final long long3) {
        final Hoglin bcx6 = bdc.getBrain().<Hoglin>getMemory(MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN).get();
        PiglinAi.setAngerTarget(bdc, bcx6);
        PiglinAi.dontKillAnyMoreHoglinsForAWhile(bdc);
        PiglinAi.broadcastAngerTarget(bdc, bcx6);
        PiglinAi.broadcastDontKillAnyMoreHoglinsForAWhile(bdc);
    }
}
