

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

world.events.beforeChat.subscribe(async (eventData) => {
	const player = eventData.sender;
	const m = eventData.message;
	if (m.substring(0, 1) == '!'){
	if (m == '!gmc') {

			eventData.cancel = true;
			await player.runCommandAsync('gamemode c');
			
		} else if (m == '!gms'){

			eventData.cancel = true;
			await player.runCommandAsync('gamemode s');

		} else if (m == '!warpHome'){

			eventData.cancel = true;
			const overworld = world.getDimension('overworld');
			const spawn = player.getSpawnPosition();
			player.teleport(spawn, overworld, 0, 0);

		} else if (m == '!test'){

			eventData.cancel = true;
			const overworld = world.getDimension('overworld');
			const spawn = player.getSpawnPosition();
			player.move(2,2,2);

		} else if (m == '!ownItem') {

			eventData.cancel = true;
			const inventory = player.getComponent('minecraft:inventory').container;
			const item = inventory.getItem(player.selectedSlot);

			const playerName = player.name;

            item.setLore(["Belongs to "+playerName+"..."]);
            
            inventory.setItem(player.selectedSlot, item);

		 } else if (m.slice(0, 9) == '!setLore ') {

			eventData.cancel = true;
			const inventory = player.getComponent('minecraft:inventory').container;
			const item = inventory.getItem(player.selectedSlot);

            item.setLore([(m).slice(9)]);
            
            inventory.setItem(player.selectedSlot, item);
		} else {
			await player.runCommandAsync('say @s Custom Command not recognized');
		}
	}
});

world.events.entityHurt.subscribe( eventData => {

	let deadEntity = eventData.hurtEntity;

	let source = eventData.damageSource.damagingEntity;

	let damageDealt = eventData.damage;

	const inventory = source.getComponent('minecraft:inventory').container;
	const item = inventory.getItem(source.selectedSlot);

	const id = item.typeId;

	if (id == "msls:obsidian_sword"){

	//source.applyKnockback(0, 0, damageDealt * 0.2, damageDealt * 0.2);
	
	deadEntity.applyKnockback(0, 0, damageDealt * 0.2, damageDealt * 0.2);
	}
 
  });

