import { world, system } from "@minecraft/server";

export function resetToFirstPerson(player, duration=0, easeType="linear") {
    player.runCommand(`camera @s set minecraft:first_person ease ${duration} ${easeType}`);
    system.waitTicks(duration * 20).then(() => reset(player));
}

export function switchToFirstPerson(player, duration=0, easeType="linear") {
    player.runCommand(`camera @s set minecraft:first_person ease ${duration} ${easeType}`);
}

export function switchToThirdPerson(player, duration=0, easeType="linear") {
    player.runCommand(`camera @s set minecraft:third_person ease ${duration} ${easeType}`);
}

export function switchToPreset(player, preset, duration=0, easeType="linear") {
    player.runCommand(`camera @s set ${preset} ease ${duration} ${easeType}`);
}

export function reset(player) {
    player.runCommand("camera @s clear");
}

export function switchToCustomCamera(player, customParams, duration=0, easeType="linear") {
    player.runCommand(`camera @s set  ${customParams} ease ${duration} ${easeType}`);
}