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

world.afterEvents.itemCompleteUse.subscribe(event => {
  const { itemStack, source } = event;
  if (itemStack.typeId === "xaierg:antibiotico" && source.typeId === "minecraft:player") {
    source.runCommand(`/effect @s clear wither`);
    
  }
  
			if (itemStack.typeId === "xaierg:adrenalina") {
				source.runCommand('effect @s speed 15 2 false');
				source.runCommand('effect @s resistance 15 2 false');
				source.runCommand('effect @s strength 15 2 false');
			}

			if (itemStack.typeId === "xaierg:cigarrillo") {
				source.runCommand('effect @s nausea 15 0 false');
				source.runCommand('effect @s jump_boost 10 1 false');
			}
			if (itemStack.typeId === "xaierg:alcohol") {
				source.runCommand('effect @s nausea 10 0 false');
				source.runCommand('effect @s jump_boost 15 2 false');
				source.runCommand('effect @s slow_falling 15 0 false');
			}
			if (itemStack.typeId === "xaierg:curita") {
				source.runCommand('effect @s nausea 10 0 false');
				source.runCommand('effect @s regeneration 5 1 false');
				source.runCommand('effect @s slow_falling 15 0 false');
			}
			if (itemStack.typeId === "xaierg:venda") {
				source.runCommand('effect @s regeneration 3 255 false');
				source.runCommand('effect @s e 15 1 false');
				source.runCommand('effect @s e 15 0 false');
			}
			if (itemStack.typeId === "xaierg:paracetamol") {
				source.runCommand('effect @s nausea 5 0 false');
				source.runCommand('effect @s regeneration 20 2 false');
				source.runCommand('effect @s resistance 15 0 false');
			}

			if (itemStack.typeId === "xaierg:lata_cafe_abierta") {
				source.runCommand('effect @s speed 25 2 false');
			}

			if (itemStack.typeId === "xaierg:sobre_cafe") {
				source.runCommand('effect @s speed 15 2 false');
			}
});

world.beforeEvents.worldInitialize.subscribe(({ itemComponentRegistry }) => {
	itemComponentRegistry.registerCustomComponent('xaierg:medicamentos', {
		onConsume: e => {
			const player = e.source;
			const item = e.itemStack;


		}
	});
});
    	