import * as mc from "@minecraft/server";

export class awningSupportManager {
    static beforeplaceSupport(data) {
        const block = data.block;
        const up = block.above();
        const upConnects = up.hasTag("sgs_cake_awning");

        mc.system.runTimeout(() => {
            if (upConnects) up.setPermutation(up.permutation.withState('sgs_cake:support', 1));
        }, 0)
    }

    static destroySupport(data) {
        const block = data.block;
        const up = block.above();
        const upConnects = up.hasTag("sgs_cake_awning");

        mc.system.runTimeout(() => {
            if (upConnects) up.setPermutation(up.permutation.withState('sgs_cake:support', 0));
        }, 0)
    }

    static beforeplace(data) {
        const block = data.block;
        const down = block.below();
        const downConnects = down.hasTag("sgs_cake_awning_support");

        mc.system.runTimeout(() => {
            if (downConnects) block.setPermutation(block.permutation.withState('sgs_cake:support', 1));
        }, 0)
    }
}
