// This code is adapted from Kaioga's Block Templates. Thank you!
import { world, system, EffectType } from '@minecraft/server';


world.afterEvents.entityHitEntity.subscribe(data => {
    const player = data.damagingEntity;
    const target = data.hitEntity;
    const equipment = player.getComponent('equippable');
    const selectedItem = equipment.getEquipment('Mainhand');
	
    
    if (selectedItem?.typeId == "alex:primitive_club") {
	    system.run(() => {
            use_durability(player, selectedItem, 1)
            target.addEffect('slowness', 10, {amplifier: 1})
	    });
	}
    
    if (selectedItem?.typeId == "alex:primitive_club") {
	    system.run(() => {
            use_durability(player, selectedItem, 1)
            target.addEffect('slowness', 10, {amplifier: 3})
	    });
	}

	return;
});