pinv = player.getInventory();
var entities = player.getEntitiesWithinRange(2);
for (var i = 0; i < entities.length; i++) {
    var ent = entities[i];
    if (ent.getClassType() == "Arrow") {
        if (typeof newVelX != 'undefined') {
            var oldVelX = newVelX;
            var oldVelY = newVelY;
            var oldVelZ = newVelZ;
        }
        else {
            var oldVelX = 0;
            var oldVelY = 0;
            var oldVelZ = 0;
        }
        var newVelX = ent.getVelocity().x;
        var newVelY = ent.getVelocity().y;
        var newVelZ = ent.getVelocity().z;
        if (oldVelX == newVelX && oldVelY == newVelY && oldVelZ == newVelZ) {
            ent.setDead();
            pinv.addItem(Item(262));
}   }   }