import { world } from "@minecraft/server";

world.beforeEvents.worldInitialize.subscribe(({ blockComponentRegistry }) => {
    blockComponentRegistry.registerCustomComponent("gs_ce:stairs", {
        beforeOnPlayerPlace: (data) => {
            const { permutationToPlace, block, player, dimension } = data;
            if (block.location.y > player.location.y) {
                data.cancel = true;
                block.setPermutation(permutationToPlace.withState("gs_ce:flipped", true));
                dimension.playSound("dig.wood", block.location);
            }
        },
    });
});
