/*
██╗  ██╗ █████╗ ██╗   ██╗███████╗███╗   ██╗    ███╗   ███╗ ██████╗ ██████╗ ██████╗  █████╗  ██████╗██╗  ██╗███████╗
██║  ██║██╔══██╗██║   ██║██╔════╝████╗  ██║    ████╗ ████║██╔═══██╗██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ ██╔╝██╔════╝
███████║███████║██║   ██║█████╗  ██╔██╗ ██║    ██╔████╔██║██║   ██║██║  ██║██████╔╝███████║██║     █████╔╝ ███████╗
██╔══██║██╔══██║╚██╗ ██╔╝██╔══╝  ██║╚██╗██║    ██║╚██╔╝██║██║   ██║██║  ██║██╔═══╝ ██╔══██║██║     ██╔═██╗ ╚════██║
██║  ██║██║  ██║ ╚████╔╝ ███████╗██║ ╚████║    ██║ ╚═╝ ██║╚██████╔╝██████╔╝██║     ██║  ██║╚██████╗██║  ██╗███████║
╚═╝  ╚═╝╚═╝  ╚═╝  ╚═══╝  ╚══════╝╚═╝  ╚═══╝    ╚═╝     ╚═╝ ╚═════╝ ╚═════╝ ╚═╝     ╚═╝  ╚═╝ ╚═════╝╚═╝  ╚═╝╚══════╝
*/
Ponder.registry((event) => {
    event.create([
        'mekanism:induction_casing',
        'mekanism:induction_port'
    ])
    .scene('mekanism_induction_matrix', 'Building an Induction Matrix', 'kubejs:mekanism_induction_matrix', (scene, util) => {
        scene.world.showSection([0, 0, 0, 4, 4, 4], Facing.DOWN);
        scene.idle(15);

        scene.overlay.showText(85).text("The Induction Matrix stores vast amounts of power.").placeNearTarget().attachKeyFrame();
        scene.idle(90);

        scene.world.hideSection([0, 0, 0, 4, 4, 4], Facing.UP);
        scene.idle(15);

        scene.world.showSection([4, 0, 4], Facing.DOWN);
        scene.idle(10);

        [1, 2, 3, 4].forEach(num => {
            scene.world.showSection([4, num, 4], Facing.DOWN);
            scene.world.showSection([4, 0, 4 - num], Facing.DOWN);
            scene.world.showSection([4 - num, 0, 4], Facing.DOWN);
            scene.idle(10);
        });

        [1, 2, 3].forEach(num => {
            scene.world.showSection([4, 4, 4 - num], Facing.DOWN);
            scene.world.showSection([4 - num, 4, 4], Facing.DOWN);
            scene.world.showSection([0, 0, 4 - num], Facing.DOWN);
            scene.world.showSection([4 - num, 0, 0], Facing.DOWN);
            scene.world.showSection([0, num, 4], Facing.DOWN);
            scene.world.showSection([4, num, 0], Facing.DOWN);
            scene.idle(10);
        });

        scene.overlay.showText(85).text("The edges must be constructed with casings.").placeNearTarget().attachKeyFrame();
        scene.idle(10);

        scene.world.showSection([4, 4, 0], Facing.DOWN);
        scene.world.showSection([0, 4, 4], Facing.DOWN);
        scene.world.showSection([0, 0, 0], Facing.DOWN);
        scene.idle(10);

        [1, 2, 3].forEach(num => {
            scene.world.showSection([0, num, 0], Facing.DOWN);
            scene.world.showSection([0, 4, 4 - num], Facing.DOWN);
            scene.world.showSection([4 - num, 4, 0], Facing.DOWN);
            scene.idle(10);
        });

        scene.world.showSection([0, 4, 0], Facing.DOWN);
        scene.idle(65);

        scene.overlay.showText(85).text("The faces can be casings or structural glass.").placeNearTarget().attachKeyFrame();

        scene.world.showSection([1, 4, 1, 3, 4, 3], Facing.DOWN);
        scene.idle(10);

        scene.world.showSection([1, 0, 1, 3, 0, 3], Facing.UP);
        scene.idle(10);

        scene.world.showSection([1, 1, 0, 3, 3, 0], Facing.SOUTH);
        scene.idle(10);

        scene.world.showSection([1, 1, 4, 3, 3, 4], Facing.NORTH);
        scene.idle(10);

        scene.world.showSection([0, 1, 1, 0, 3, 3], Facing.EAST);
        scene.idle(10);

        scene.world.showSection([4, 1, 1, 4, 3, 3], Facing.WEST);
        scene.idle(85);

        scene.overlay.showText(65).text("Ports are used to transfer power.").placeNearTarget().attachKeyFrame();
        scene.idle(85);

        scene.overlay.showText(85).text("Use a Configurator to change port settings.").placeNearTarget().attachKeyFrame();
        scene.showControls(85, [1.5, 2.5, 0], 'down').rightClick().withItem('mekanism:configurator').whileSneaking();
        scene.world.modifyBlock([1, 1, 0], (curState) => curState.with("active", "false"), true);
        scene.idle(25);
        scene.world.modifyBlock([1, 1, 0], (curState) => curState.with("active", "true"), true);
        scene.idle(65);

        scene.world.hideSection([0, 1, 0, 3, 4, 0], Facing.UP);
        scene.world.hideSection([0, 1, 0, 0, 4, 3], Facing.UP);
        scene.world.hideSection([1, 4, 1, 3, 4, 3], Facing.UP);
        scene.idle(25);

        scene.overlay.showText(65).text("Induction Cells increase power storage capacity.").placeNearTarget().attachKeyFrame();
        scene.world.setBlock([2, 1, 2], 'mekanism:basic_induction_cell', false);
        scene.world.showSection([2, 1, 2], Facing.DOWN);
        scene.idle(70);

        scene.overlay.showText(65).text("Induction Providers enhance power transfer rate.").placeNearTarget().attachKeyFrame();
        scene.world.setBlock([2, 2, 2], 'mekanism:basic_induction_provider', false);
        scene.world.showSection([2, 2, 2], Facing.DOWN);
        scene.idle(70);

        scene.overlay.showText(65).text("The Matrix must have at least one Cell and one Provider.").placeNearTarget().attachKeyFrame();
        scene.idle(70);

        scene.world.showSection([0, 1, 0, 3, 4, 0], Facing.UP);
        scene.world.showSection([0, 1, 0, 0, 4, 3], Facing.UP);
        scene.world.showSection([1, 4, 1, 3, 4, 3], Facing.UP);
        scene.idle(15);
    });
});
