package net.minecraft.world.entity;

import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;

public interface ItemSteerable {
    boolean boost();
    
    void travelWithInput(final Vec3 dem);
    
    float getSteeringSpeed();
    
    default boolean travel(final Mob aoz, final ItemBasedSteering aov, final Vec3 dem) {
        if (!aoz.isAlive()) {
            return false;
        }
        final Entity aom5 = aoz.getPassengers().isEmpty() ? null : aoz.getPassengers().get(0);
        if (!aoz.isVehicle() || !aoz.canBeControlledByRider() || !(aom5 instanceof Player)) {
            aoz.maxUpStep = 0.5f;
            aoz.flyingSpeed = 0.02f;
            this.travelWithInput(dem);
            return false;
        }
        aoz.yRot = aom5.yRot;
        aoz.yRotO = aoz.yRot;
        aoz.xRot = aom5.xRot * 0.5f;
        aoz.setRot(aoz.yRot, aoz.xRot);
        aoz.yBodyRot = aoz.yRot;
        aoz.yHeadRot = aoz.yRot;
        aoz.maxUpStep = 1.0f;
        aoz.flyingSpeed = aoz.getSpeed() * 0.1f;
        if (aov.boosting && aov.boostTime++ > aov.boostTimeTotal) {
            aov.boosting = false;
        }
        if (aoz.isControlledByLocalInstance()) {
            float float6 = this.getSteeringSpeed();
            if (aov.boosting) {
                float6 += float6 * 1.15f * Mth.sin(aov.boostTime / (float)aov.boostTimeTotal * 3.1415927f);
            }
            aoz.setSpeed(float6);
            this.travelWithInput(new Vec3(0.0, 0.0, 1.0));
            aoz.lerpSteps = 0;
        }
        else {
            aoz.calculateEntityAnimation(aoz, false);
            aoz.setDeltaMovement(Vec3.ZERO);
        }
        return true;
    }
}
