// ********************************* //
// import
// ********************************* //
import * as server from "@minecraft/server";
// import * as ui from "@minecraft/server-ui";
// func
// import * as lore from "./func/lore.js"
// import * as score from "./func/score.js"
// import * as status from "./func/status.js"
// list
// import * as l_blocks from './list/blocks.js';
// import * as l_mobs from './list/mobs.js';
// import * as l_players from './list/players.js';
//action
// import * as beam from "./action/beam.js"
import * as btn from "./action/btn.js"
import * as place from "./action/place.js"
import * as push from "./action/push.js"
import * as search from "./action/search.js"
import * as num from "./action/num.js"

// ********************************* //
// event
// ********************************* //

// アイテムの使用 itemUse
// server.world.afterEvents.itemUse.subscribe(event => {
//     let player = event.source;
//     let item = event.itemStack;
//     switch (item.typeId) {
//         case "c:hintbook":
//             break;
//         default:
//             break;
//     }
// });

//interact検知（基本ブロック）
server.world.afterEvents.playerInteractWithBlock.subscribe(event => {
    let player = event.player;
    let block = event.block;
    switch (block.typeId) {
        case "minecraft:":
            break;
        default:
            if (player.isSleeping) {
                player.runCommand("function golem_sleep/sleep/player");
            }
            break;
    }
});

//ワールド参加
server.world.afterEvents.playerSpawn.subscribe(event => {
    const player = event.player;

    //音楽再生
    player.runCommandAsync("function z/story/music");

    // player.inputPermissions.cameraEnabled = true;
    // player.inputPermissions.movementEnabled = true;
    player.runCommand("function z/story/limit_clear_s");
});

// ********************************* //
// log
// ********************************* //
const log_on = false;
function log(log_text) {
    if (log_on) server.world.sendMessage("log: " + String(log_text));
}