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.item.ItemEntity;
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 StartAdmiringItemIfSeen<E extends Piglin> extends Behavior<E> {
    private final int admireDuration;
    
    public StartAdmiringItemIfSeen(final int integer) {
        super(ImmutableMap.<MemoryModuleType<ItemEntity>, MemoryStatus>of(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryStatus.VALUE_PRESENT, (MemoryModuleType<ItemEntity>)MemoryModuleType.ADMIRING_ITEM, MemoryStatus.VALUE_ABSENT, (MemoryModuleType<ItemEntity>)MemoryModuleType.ADMIRING_DISABLED, MemoryStatus.VALUE_ABSENT));
        this.admireDuration = integer;
    }
    
    @Override
    protected boolean checkExtraStartConditions(final ServerLevel zd, final E bdc) {
        final ItemEntity bbg4 = bdc.getBrain().<ItemEntity>getMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM).get();
        return PiglinAi.isLovedItem(bbg4.getItem().getItem());
    }
    
    @Override
    protected void start(final ServerLevel zd, final E bdc, final long long3) {
        bdc.getBrain().<Boolean>setMemoryWithExpiry(MemoryModuleType.ADMIRING_ITEM, true, this.admireDuration);
    }
}
