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

world.afterEvents.entityHitEntity.subscribe((event) => {
	let damagingEntity = event.damagingEntity;
	if ((damagingEntity.getComponent('inventory').container.getItem(damagingEntity.selectedSlot).typeId == 'redstone:captain_dagger') == true) {
		const entity = event.hitEntity;
		entity.addEffect("bad_omen", 20000);
		entity.applyImpulse({ x: 0, y: 0.2, z: 0 });
	}
})