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

import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.tags.Tag;
import net.minecraft.tags.FluidTags;
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 chance;
    
    public Swim(final float float1) {
        super(ImmutableMap.of());
        this.chance = float1;
    }
    
    @Override
    protected boolean checkExtraStartConditions(final ServerLevel zd, final Mob aoz) {
        return (aoz.isInWater() && aoz.getFluidHeight(FluidTags.WATER) > aoz.getFluidJumpThreshold()) || aoz.isInLava();
    }
    
    @Override
    protected boolean canStillUse(final ServerLevel zd, final Mob aoz, final long long3) {
        return this.checkExtraStartConditions(zd, aoz);
    }
    
    @Override
    protected void tick(final ServerLevel zd, final Mob aoz, final long long3) {
        if (aoz.getRandom().nextFloat() < this.chance) {
            aoz.getJumpControl().jump();
        }
    }
}
