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

export class trapdoorManager {
    static interact(data) {
        const block = data.block;

        const currentState = block.permutation.getState('sgs_farm:open');
        const newOpenState = !currentState;
        const sound = newOpenState ? 'open.wooden_trapdoor' : 'close.wooden_trapdoor';

        const newPermutation = mc.BlockPermutation.resolve(block.typeId, {
            ...block.permutation.getAllStates(),
            'sgs_farm:open': newOpenState
        });

        block.setPermutation(newPermutation);
        block.dimension.playSound(sound, block.location);
    }
}