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

import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
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.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 zd, final LivingEntity aoy) {
        return zd.random.nextFloat() > 0.95f;
    }
    
    @Override
    protected void start(final ServerLevel zd, final LivingEntity aoy, final long long3) {
        final Brain<?> apr6 = aoy.getBrain();
        final BlockPos fu7 = apr6.<GlobalPos>getMemory(MemoryModuleType.MEETING_POINT).get().pos();
        if (fu7.closerThan(aoy.blockPosition(), 3.0)) {
            final BlockState cfj8 = zd.getBlockState(fu7);
            if (cfj8.is(Blocks.BELL)) {
                final BellBlock bvp9 = (BellBlock)cfj8.getBlock();
                bvp9.attemptToRing(zd, fu7, null);
            }
        }
    }
}
