import { world, MinecraftEffectTypes } from "mojang-minecraft";

world.events.itemCompleteCharge.subscribe(data => {
  const { itemStack, source } = data;
  if (source.id == "minecraft:player") {
    if (source.getComponent("minecraft:variant").value == 35 && !source.getComponent("minecraft:is_shaking") && itemStack.id == "minecraft:golden_apple") {
      source.triggerEvent("morph:zombie_villager_cure");
    };
    if (source.getComponent("minecraft:variant").value == 42 && itemStack.id == "minecraft:cookie") {
      source.addEffect(MinecraftEffectTypes.fatalPoison, 1000 * 20, 0);
    };
  };
});