import { Player, EntityDamageCause } from '@minecraft/server';

const BarbedWire = {
    onTick(event) {

        //Damage any entity that is currently inside this block with 2 damage per tick
        const entities = event.dimension.getEntitiesAtBlockLocation(event.block.location);

        for (const entity of entities) {
            if (entity.hasComponent("minecraft:health")) {
                entity.applyDamage(1, { cause: EntityDamageCause.contact });
            }

            entity.addEffect("slowness", 12, { amplifier: 2, showParticles: false });
            
        }
    }
};

export default BarbedWire;
