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

import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.ai.Brain;
import net.minecraft.core.Direction;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BellBlock;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.Vec3i;
import net.minecraft.world.entity.Entity;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import java.util.Map;
import net.minecraft.core.GlobalPos;
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 RingBell extends Behavior<LivingEntity> {
    public RingBell() {
        super(ImmutableMap.<MemoryModuleType<GlobalPos>, MemoryStatus>of(MemoryModuleType.MEETING_POINT, MemoryStatus.VALUE_PRESENT));
    }
    
    @Override
    protected boolean checkExtraStartConditions(final ServerLevel xd, final LivingEntity akz) {
        return xd.random.nextFloat() > 0.95f;
    }
    
    @Override
    protected void start(final ServerLevel xd, final LivingEntity akz, final long long3) {
        final Brain<?> alp6 = akz.getBrain();
        final BlockPos fk7 = alp6.<GlobalPos>getMemory(MemoryModuleType.MEETING_POINT).get().pos();
        if (fk7.closerThan(new BlockPos(akz), 3.0)) {
            final BlockState byj8 = xd.getBlockState(fk7);
            if (byj8.getBlock() == Blocks.BELL) {
                final BellBlock bpf9 = (BellBlock)byj8.getBlock();
                bpf9.attemptToRing(xd, fk7, null);
            }
        }
    }
}
