Blink

A simple blink module

/*
name: Blink
author: surge
*/

import { DoubleSetting, breeze, mc, Timer } from '../breeze_defs';

var packets = [];
var timer = new Timer();

function sendPackets() {
    if (packets.length > 0) {
        for (var i = 0; i < packets.length; i++) {
            breeze.sendPacket(packets[i], false);
        }

        packets = [];
    }
}

breeze.registerModule('Blink', 'Cancels the sending of packets for a length of time', {

    'delay': new DoubleSetting('Delay', 'The time between sending packets', 4.0, 0.1, 10.0),

    'disable': function() {
        sendPackets();
    },

    'tick': function(event) {
        if (timer.hasPassed(this.delay.getValue() * 1000)) {
            timer.reset();
            sendPackets();
        }
    },

    'packetSend': function(event) {
        if (!(event.getPacket() instanceof C03PacketPlayer || event.getPacket() instanceof C04PacketPlayerPosition || event.getPacket() instanceof C05PacketPlayerLook || event.getPacket() instanceof C06PacketPlayerPosLook)) {
            return;
        }

        event.cancel();
        packets.push(event.getPacket());
    }

});

Last updated