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

import net.minecraft.world.entity.LivingEntity;
import net.minecraft.server.level.ServerLevel;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import net.minecraft.world.entity.Mob;

public class Swim extends Behavior<Mob> {
    private final float height;
    private final float chance;
    
    public Swim(final float float1, final float float2) {
        super(ImmutableMap.of());
        this.height = float1;
        this.chance = float2;
    }
    
    @Override
    protected boolean checkExtraStartConditions(final ServerLevel xd, final Mob ala) {
        return (ala.isInWater() && ala.getWaterHeight() > this.height) || ala.isInLava();
    }
    
    @Override
    protected boolean canStillUse(final ServerLevel xd, final Mob ala, final long long3) {
        return this.checkExtraStartConditions(xd, ala);
    }
    
    @Override
    protected void tick(final ServerLevel xd, final Mob ala, final long long3) {
        if (ala.getRandom().nextFloat() < this.chance) {
            ala.getJumpControl().jump();
        }
    }
}
