import * as mc from "@minecraft/server";
import { NAMESPACE } from "../anvilConstants";
import { endMorphing } from "./morphManager";
import { dinoList } from "../constants";
import { thirdPersonRelative } from "../camera/camera";
export function playerSpawn(eventData) {
    eventData.player.addTag(eventData.player.id.toString());
    if (eventData.player.getProperty(`${NAMESPACE}:morph_name`)) {
        endMorphing(eventData.player);
    }
    if (eventData.initialSpawn && eventData.player.getDynamicProperty(`${NAMESPACE}:dinos_guide`) === undefined) {
        const inventory = eventData.player.getComponent(mc.EntityInventoryComponent.componentId);
        inventory.container?.addItem(new mc.ItemStack(`${NAMESPACE}:dinos_guide`));
        inventory.container?.addItem(new mc.ItemStack(`${NAMESPACE}:wikidino_book`));
        eventData.player.setDynamicProperty(`${NAMESPACE}:dinos_guide`, true);
        eventData.player.sendMessage({ translate: `${NAMESPACE}.dinos_guide` });
    }
}
export function playerCameraOffset(player) {
    const morphedEntity = player.getDynamicProperty(`${NAMESPACE}:morph_name`);
    const offset = dinoList[morphedEntity].offset;
    thirdPersonRelative(player, offset);
}
