import { Block, Dimension, Direction, Player } from "@minecraft/server";

/**
 * Evento onPlayerInteract del componente resourceRecyclerComponent
 * Addon: Electrical Creativity BP
 * @param {{face: Direction, faceLocation: Vector3, player: Player, block: Block, dimension: Dimension}} event
 */
export const resourceRecyclerOnPlayerInteractEvent = ({face, faceLocation, player, block, dimension}) => {
    block.setPermutation(block.permutation.withState("nps_ec:active", block.permutation.getState("nps_ec:active") === 0 ? 1 : 0));
    block.setPermutation(block.permutation.withState("nps_ec:processing", block.permutation.getState("nps_ec:active") === 0 ? false : block.permutation.getState("nps_ec:processing")));
    dimension.runCommand(`playsound random.click @a ${block.location.x} ${block.location.y} ${block.location.z}`);
}