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.world.level.dimension.DimensionType;
import java.util.List;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import net.minecraft.core.GlobalPos;
import net.minecraft.tags.BlockTags;
import com.google.common.collect.Lists;
import net.minecraft.world.entity.Entity;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.LivingEntity;

public class InteractableDoorsSensor extends Sensor<LivingEntity> {
    @Override
    protected void doTick(final ServerLevel xd, final LivingEntity akz) {
        final DimensionType cbi4 = xd.getDimension().getType();
        final BlockPos fk5 = new BlockPos(akz);
        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 fk6 = fk5.offset(integer7, integer8, integer9);
                    if (xd.getBlockState(fk6).is(BlockTags.WOODEN_DOORS)) {
                        list6.add(GlobalPos.of(cbi4, fk6));
                    }
                }
            }
        }
        final Brain<?> alp7 = akz.getBrain();
        if (!list6.isEmpty()) {
            alp7.<List<GlobalPos>>setMemory(MemoryModuleType.INTERACTABLE_DOORS, list6);
        }
        else {
            alp7.<List<GlobalPos>>eraseMemory(MemoryModuleType.INTERACTABLE_DOORS);
        }
    }
    
    @Override
    public Set<MemoryModuleType<?>> requires() {
        return ImmutableSet.of(MemoryModuleType.INTERACTABLE_DOORS);
    }
}
