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

world.afterEvents.itemUseOn.subscribe((event) => {
	if (event.itemStack.typeId == "gojidraw:endless_stone_item") {
		const tag = event.source.name.replaceAll(" ", "") + "_et";
		event.source.addTag(tag);
		event.source.dimension.runCommand(
			`/replaceitem entity @a[tag=${tag}] slot.weapon.mainhand 0 gojidraw:endless_stone_item 1 0`,
		);
		event.source.removeTag(tag);
	}
});
