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

world.beforeEvents.explosion.subscribe((data) => {
	const source = data.source;
	const { x, y, z } = source.location;
	const dim = data.dimension;
	system.run(() => {
		if (source?.typeId === "manalabs_opw:spell_skull") {
			dim.spawnParticle("manalabs_opw:explosion_core_0", {
				x,
				y,
				z,
			});
			dim.spawnParticle("manalabs_opw:explosion_core_1", {
				x,
				y,
				z,
			});
			dim.spawnParticle("manalabs_opw:explosion_core_2", {
				x,
				y,
				z,
			});
			dim.spawnParticle("manalabs_opw:explosion_dust_0", {
				x,
				y,
				z,
			});
			dim.spawnParticle("manalabs_opw:explosion_dust_1", {
				x,
				y,
				z,
			});
			dim.spawnParticle("manalabs_opw:explosion_dust_1", {
				x,
				y,
				z,
			});
		}
	});
});
