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

import java.util.Random;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.core.Vec3i;
import net.minecraft.server.level.ServerLevel;
import java.util.Map;
import net.minecraft.core.BlockPos;
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.Mob;

public class GoToCelebrateLocation<E extends Mob> extends Behavior<E> {
    private final int closeEnoughDist;
    private final float speedModifier;
    
    public GoToCelebrateLocation(final int integer, final float float2) {
        super(ImmutableMap.<MemoryModuleType<BlockPos>, MemoryStatus>of(MemoryModuleType.CELEBRATE_LOCATION, MemoryStatus.VALUE_PRESENT, (MemoryModuleType<BlockPos>)MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_ABSENT, (MemoryModuleType<BlockPos>)MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT, (MemoryModuleType<BlockPos>)MemoryModuleType.LOOK_TARGET, MemoryStatus.REGISTERED));
        this.closeEnoughDist = integer;
        this.speedModifier = float2;
    }
    
    @Override
    protected void start(final ServerLevel zd, final Mob aoz, final long long3) {
        final BlockPos fu6 = getCelebrateLocation(aoz);
        final boolean boolean7 = fu6.closerThan(aoz.blockPosition(), this.closeEnoughDist);
        if (!boolean7) {
            BehaviorUtils.setWalkAndLookTargetMemories(aoz, getNearbyPos(aoz, fu6), this.speedModifier, this.closeEnoughDist);
        }
    }
    
    private static BlockPos getNearbyPos(final Mob aoz, final BlockPos fu) {
        final Random random3 = aoz.level.random;
        return fu.offset(getRandomOffset(random3), 0, getRandomOffset(random3));
    }
    
    private static int getRandomOffset(final Random random) {
        return random.nextInt(3) - 1;
    }
    
    private static BlockPos getCelebrateLocation(final Mob aoz) {
        return aoz.getBrain().<BlockPos>getMemory(MemoryModuleType.CELEBRATE_LOCATION).get();
    }
}
