import { world } from "@minecraft/server";

world.afterEvents.itemCompleteUse.subscribe(eventData => {
  const player = eventData.source;
  const itemUsed = eventData.itemStack;
	const customFoods = [
    "nicothekid:moss_berry_cookie",
    "nicothekid:moss_berry_pie",
    "nicothekid:mosshroom_stew"
  ]
	if (customFoods.includes(itemUsed.typeId)) {
    if (itemUsed.typeId === "nicothekid:moss_berry_cookie") {
      player.addEffect("regeneration", 200, {amplifier: 0, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:moss_berry_pie") {
      player.addEffect("regeneration", 400, {amplifier: 0, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:mosshroom_stew") {
      player.addEffect("regeneration", 300, {amplifier: 0, showParticles: true })
      player.addEffect("mining_fatigue", 300, {amplifier: 0, showParticles: true })
    }
	}
	else return;
});
