import { Block, Dimension, Player } from "@minecraft/server";
import { teleportTo } from "../../views/blocks/teleportViews";

/**
* Evento del componente teleportCheckpointComponent
* @param {{player: Player, block: Block, dimension: Dimension}} event 
*/
export const teleportEvent = ({ player, block, dimension }) => {
    if (player.getComponent('minecraft:inventory') == undefined) return;
    const item = player.getComponent('minecraft:inventory').container.getItem(player.selectedSlotIndex);
    if(!item) return;
    if(item.typeId !== 'nps_ec:teleport_point') return;
    teleportTo(player, item);
}