package net.minecraft.world.entity.ai.behavior;

import net.minecraft.server.level.ServerLevel;
import java.util.Map;
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.LivingEntity;

public class BecomePassiveIfMemoryPresent extends Behavior<LivingEntity> {
    private final int pacifyDuration;
    
    public BecomePassiveIfMemoryPresent(final MemoryModuleType<?> awp, final int integer) {
        super(ImmutableMap.<MemoryModuleType<LivingEntity>, MemoryStatus>of(MemoryModuleType.ATTACK_TARGET, MemoryStatus.REGISTERED, (MemoryModuleType<LivingEntity>)MemoryModuleType.PACIFIED, MemoryStatus.VALUE_ABSENT, (MemoryModuleType<LivingEntity>)awp, MemoryStatus.VALUE_PRESENT));
        this.pacifyDuration = integer;
    }
    
    @Override
    protected void start(final ServerLevel zd, final LivingEntity aoy, final long long3) {
        aoy.getBrain().<Boolean>setMemoryWithExpiry(MemoryModuleType.PACIFIED, true, this.pacifyDuration);
        aoy.getBrain().<LivingEntity>eraseMemory(MemoryModuleType.ATTACK_TARGET);
    }
}
