import * as mc from "@minecraft/server";
import { endTestInstant } from "./sculptor";
import { startLoop } from "../misc/sculptorMusic";

export function eventBehavior(event) {
  if (event.eventId === "register") {
    // if lowering, directly reset
    const variant = event.entity.getComponent("minecraft:variant");
    if (variant.value === 3) {
      const e = {
        sourceEntity: mc.world.getEntity(event.entity.getDynamicProperty("hf_mzs:sculptor")),
        id: "hf_mzs:end_test_instant",
      };
      endTestInstant(e);
    } else if (variant.value === 2) {
      mc.system.runTimeout(() => {
        startLoop(event.entity);
      }, 80);
    }
    return;
  }
}
