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

import net.minecraft.world.level.material.Fluid;
import net.minecraft.tags.Tag;
import net.minecraft.tags.FluidTags;
import java.util.EnumSet;
import net.minecraft.world.entity.Mob;

public class FloatGoal extends Goal {
    private final Mob mob;
    
    public FloatGoal(final Mob aoz) {
        this.mob = aoz;
        this.setFlags(EnumSet.<Flag>of(Flag.JUMP));
        aoz.getNavigation().setCanFloat(true);
    }
    
    @Override
    public boolean canUse() {
        return (this.mob.isInWater() && this.mob.getFluidHeight(FluidTags.WATER) > this.mob.getFluidJumpThreshold()) || this.mob.isInLava();
    }
    
    @Override
    public void tick() {
        if (this.mob.getRandom().nextFloat() < 0.8f) {
            this.mob.getJumpControl().jump();
        }
    }
}
