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 java.util.function.Predicate;
import net.minecraft.world.entity.LivingEntity;

public class EraseMemoryIf<E extends LivingEntity> extends Behavior<E> {
    private final Predicate<E> predicate;
    private final MemoryModuleType<?> memoryType;
    
    public EraseMemoryIf(final Predicate<E> predicate, final MemoryModuleType<?> awp) {
        super(ImmutableMap.<MemoryModuleType<?>, MemoryStatus>of(awp, MemoryStatus.VALUE_PRESENT));
        this.predicate = predicate;
        this.memoryType = awp;
    }
    
    @Override
    protected boolean checkExtraStartConditions(final ServerLevel zd, final E aoy) {
        return this.predicate.test(aoy);
    }
    
    @Override
    protected void start(final ServerLevel zd, final E aoy, final long long3) {
        aoy.getBrain().eraseMemory(this.memoryType);
    }
}
