import { system, world, Entity, Player } from '@minecraft/server'

world.afterEvents.entityHurtAfterEvent.subscribe((event) => {
	const hurtEntity = event.hurtEntity
	if ((hurtEntity.typeId == 'minecraft:player' && hurtEntity.getComponent('inventory').container.getItem(player.selectedSlot).typeId == 'redstone:broadblade') == true) {
		hurtEntity.runCommandAsync('effect @s absorbtion 2 4 true');
	}
})