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

import com.google.common.collect.ImmutableSet;
import java.util.Set;
import net.minecraft.world.entity.ai.Brain;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.resources.ResourceKey;
import java.util.List;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import net.minecraft.core.GlobalPos;
import net.minecraft.world.level.block.Block;
import net.minecraft.tags.Tag;
import net.minecraft.tags.BlockTags;
import com.google.common.collect.Lists;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.LivingEntity;

public class InteractableDoorsSensor extends Sensor<LivingEntity> {
    @Override
    protected void doTick(final ServerLevel zd, final LivingEntity aoy) {
        final ResourceKey<Level> ug4 = zd.dimension();
        final BlockPos fu5 = aoy.blockPosition();
        final List<GlobalPos> list6 = Lists.newArrayList();
        for (int integer7 = -1; integer7 <= 1; ++integer7) {
            for (int integer8 = -1; integer8 <= 1; ++integer8) {
                for (int integer9 = -1; integer9 <= 1; ++integer9) {
                    final BlockPos fu6 = fu5.offset(integer7, integer8, integer9);
                    if (zd.getBlockState(fu6).is(BlockTags.WOODEN_DOORS)) {
                        list6.add(GlobalPos.of(ug4, fu6));
                    }
                }
            }
        }
        final Brain<?> apr7 = aoy.getBrain();
        if (!list6.isEmpty()) {
            apr7.<List<GlobalPos>>setMemory(MemoryModuleType.INTERACTABLE_DOORS, list6);
        }
        else {
            apr7.<List<GlobalPos>>eraseMemory(MemoryModuleType.INTERACTABLE_DOORS);
        }
    }
    
    @Override
    public Set<MemoryModuleType<?>> requires() {
        return ImmutableSet.of(MemoryModuleType.INTERACTABLE_DOORS);
    }
}
