import { world } from "@minecraft/server";
import FSInventoryManager from "./libs/FSInventoryManager";
import FSDynamicProperty from "./libs/FSDynamicProperty";
import FSUtil from "./FSUtil";
export default class FSWorldHelper {
    static fillBlocks(dimenion, locationFrom, locationTo, block) {
        const command = `/fill ${locationFrom.x} ${locationFrom.y} ${locationFrom.z} ${locationTo.x} ${locationTo.y} ${locationTo.z} ${block}`;
        dimenion.runCommand(command);
    }
    static replaceBlocks(dimenion, locationFrom, locationTo, block, replace) {
        const command = `/fill ${locationFrom.x} ${locationFrom.y} ${locationFrom.z} ${locationTo.x} ${locationTo.y} ${locationTo.z} ${block} [] replace ${replace} []`;
        dimenion.runCommand(command);
    }
    static pointsBetween(pointFrom, pointTo) {
        let points = [];
        if (pointFrom < pointTo) {
            for (let i = pointFrom; i <= pointTo; i++) {
                points.push(i);
            }
        }
        else {
            for (let i = pointFrom; i >= pointTo; i--) {
                points.push(i);
            }
        }
        return points;
    }
    static replaceTablets() {
        const settingKeepTabletOnDeath = FSDynamicProperty.getBoolean(world, FSUtil.namespacedString("keep_tablet_on_death")) || false;
        world.getPlayers().forEach(player => {
            const tablet = FSInventoryManager.hasItem(player, "fs_sbunk:tablet");
            if (tablet) {
                if (settingKeepTabletOnDeath) {
                    const playerTagTabletMode = player.hasTag("fs_sbunk:tablet_keep");
                    if (!playerTagTabletMode) {
                        player.runCommand("clear @s fs_sbunk:tablet");
                        player.runCommand('give @s fs_sbunk:tablet 1 0 {"minecraft:keep_on_death":{},"minecraft:item_lock":{"mode":"lock_in_inventory"}}');
                        player.addTag("fs_sbunk:tablet_keep");
                        player.removeTag("fs_sbunk:tablet_droppable");
                    }
                }
                else {
                    const playerTagTabletDroppable = player.hasTag("fs_sbunk:tablet_droppable");
                    if (!playerTagTabletDroppable) {
                        player.runCommand("clear @s fs_sbunk:tablet");
                        player.runCommand("give @s fs_sbunk:tablet 1 0");
                        player.addTag("fs_sbunk:tablet_droppable");
                        player.removeTag("fs_sbunk:tablet_keep");
                    }
                }
            }
        });
    }
    static getActiveDimensions() {
        let activeDimensions = [];
        const players = world.getPlayers();
        players.forEach(player => {
            const dimension = player.dimension;
            if (!activeDimensions.includes(dimension)) {
                activeDimensions.push(dimension);
            }
        });
        return activeDimensions;
    }
    static getEntitiesInActiveDimensions(entityQueryOptions) {
        let entities = [];
        const activeDimensions = FSWorldHelper.getActiveDimensions();
        activeDimensions.forEach(dimension => {
            const entitiesInDimension = dimension.getEntities(entityQueryOptions);
            entities = entities.concat(entitiesInDimension);
        });
        return entities;
    }
}

//# sourceMappingURL=../../../../_SBUNK_BPDebug/fs_sbunk/fs/FSWorldHelper.js.map
