Hello, i would like to you to explain and provide the code to make it so when i click the Steeringwheel in a side of it it would smoothly rotate towards that side and when i stop it would smoothly stop like sea of thieves:
package com.fallenreaper.createutilities.content.blocks.steering_wheel;

import com.fallenreaper.createutilities.core.utils.MiscUtil;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class SteeringWheelBlockEntity extends GeneratingKineticTileEntity {
    private static final float TARGET_ROTATION_MAX = (float) Math.PI;
    private static final float ROTATION_SPEED_MAX = (float) Math.PI / 6.0f;
    private static final float ROTATION_PER_TICK_MAX = ROTATION_SPEED_MAX / 20.0f;

    public int inUse;
    public boolean backwards;
    public float independentAngle;
    public float chasingVelocity;
    public float targetRotation = 0;
    public float rotationPerTick = 0;
    public float rotation = 0;

    public SteeringWheelBlockEntity(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
        super(typeIn, pos, state);
    }

    public void turn(boolean back) {
        boolean update = false;

        if (getGeneratedSpeed() == 0 || back != backwards)
            update = true;

        inUse = 10;
        this.backwards = back;

        float targetRotation = backwards ? -TARGET_ROTATION_MAX : TARGET_ROTATION_MAX;
        float rotationPerTick = (backwards ? -1 : 1) * ROTATION_PER_TICK_MAX;



        setTargetRotation(targetRotation, rotationPerTick);

        if (update && !level.isClientSide)
            updateGeneratedRotation();
    }

    public void setTargetRotation(float targetRotation, float rotationPerTick) {
        this.targetRotation = targetRotation;
        this.rotationPerTick = rotationPerTick;
    }

    @Override
    public void tick() {
        super.tick();

        float actualSpeed = getSpeed();

        // Update the chasing velocity to match the actual speed of the wheel.
        chasingVelocity = MiscUtil.approach(chasingVelocity, actualSpeed * 10 / 3f, 0.25f);

        // Update the independent angle of the wheel based on the chasing velocity.
        independentAngle = MiscUtil.wrapDegrees(independentAngle + chasingVelocity);

        // If the wheel is turning, update its rotation.
        if (inUse > 0) {
            inUse--;

            // If the wheel is finished turning, update the generated rotation of the tile entity.
            if (inUse == 0 && !level.isClientSide)
                updateGeneratedRotation();
        }

        // Smoothly rotate the wheel toward the target rotation if it is not already there.
        if (!MiscUtil.approximatelyEquals(rotation, targetRotation, 0.01f)) {
            float delta = targetRotation - rotation;
            float direction = Math.signum(delta);
            float deltaRotation = Math.min(Math.abs(delta), ROTATION_SPEED_MAX) * direction;
            rotation += deltaRotation;
            if (level.isClientSide) {
                setChanged();
            }
        }
    }

    @Override
    public void write(CompoundTag compound, boolean clientPacket) {
        super.write(compound, clientPacket);
        compound.putBoolean("Backwards", backwards);
        compound.putInt("InUse", inUse);
        compound.putFloat("TargetRotation", targetRotation);
        compound.putFloat("RotationPerTick", rotationPerTick);
        compound.putFloat("Rotation", rotation);
        compound.putFloat("IndependentAngle", independentAngle);
        compound.putFloat("ChasingVelocity", chasingVelocity);
    }

    @Override
    public void read(CompoundTag compound) {
        super.read(compound);
        backwards = compound.getBoolean("Backwards");
        inUse = compound.getInt("InUse");
        targetRotation = compound.getFloat("TargetRotation");
        rotationPerTick = compound.getFloat("RotationPerTick");
        rotation = compound.getFloat("Rotation");
        independentAngle = compound.getFloat("IndependentAngle");
        chasingVelocity = compound.getFloat("ChasingVelocity");
    }

    @OnlyIn(Dist.CLIENT)
    public float getRenderAngle(float partialTicks) {
        // Smoothly interpolate between the current rotation and the target rotation for rendering purposes.
        return MiscUtil.interpolate(rotation - rotationPerTick, targetRotation, partialTicks);
    }

    @Override
    public float getGeneratedSpeed() {
        return inUse > 0 ? 20.0f : 0.0f;
    }

    @Override
    public void onSpeedChanged(float prevSpeed) {
        if (getGeneratedSpeed() > 0)
            level.playSound(null, worldPosition, AllSoundEvents.COGS.get(), SoundSource.BLOCKS, 0.25f, 1.0f);
    }

}

  @Override
   public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
           boolean clockwise = false;
           Vec3 offset = hit.getLocation().subtract(pos.getX(), pos.getY(), pos.getZ());

       // Get the direction of the click relative to the block
       Direction clickedDirection = getRayTrace(hit, pos, state);

       // Get the current rotation state of the wheel
       SteeringWheelBlockEntity wheelEntity = getTileEntity(worldIn, pos);
       float currentRotation = wheelEntity.rota;

       // Calculate the target rotation based on the click direction
       float targetRotation = currentRotation + (clickedDirection.getAxisDirection() == Direction.AxisDirection.POSITIVE ? 90 : -90);

       // Wrap the target rotation around if it goes past 360 degrees
       if (targetRotation >= 360) {
           targetRotation -= 360;
       } else if (targetRotation < 0) {
           targetRotation += 360;
       }

       // Calculate the change in rotation per tick required to reach the target rotation in the given time
       float rotationPerTick = (targetRotation - currentRotation) / 20F;

       // Set the wheel's rotation state and the rotation per tick
       wheelEntity.setTargetRotation(targetRotation, rotationPerTick);

       return InteractionResult.SUCCESS;
   }