Events

Introduction

The Event System plays a major role in creating a Feature. If you obtain a Feature object, you can add Event Listeners to it. This includes the Features you create in your Script and the Client's own Features. To subscribe to an Event, do the following:

feature.on("event-name", Priorities.NORMAL, (event) => {
    // Once an event arrives, this function block is called
    // with the event object passed to it.
});

To supply a correct Event Name, you need to take the Event's Class Name (e.g. DeviceButtonDownEvent), lowercase the first letter and remove the Event ending (i.e. deviceButtonDown).

You can cancel some events by invoking the cancel method.

Priorities

You can add Priorities to events to change the order of the event listeners. Event Listeners are sorted by their Priority: higher the number, the higher the listener will be on the execution queue. This only works for Scripts and doesn't override the priorities of Novoline's own modules. A Priority can be any integer number, we've pre-defined some for you already:

PriorityLevel

VERY_LOW

0

LOW

1

NORMAL

2

HIGH

3

VERY_HIGH

4

Events

Some events don't have an event object, thus in the handler function the first argument will be undefined.

EnableEvent

Fired when the Feature is enabled. Not cancellable.

DisableEvent

Fired when the Feature is disabled. Not cancellable.

ToggleEvent

Fired when the Feature is toggled. Not cancellable.

BlockCollisionEvent

Fired when the Player is colliding with a block. Can be cancelled.

TypeNameDescriptionSignature

field

boundingBox

Block's collision box

AxisAlignedBB

field

pos

Colliding block's position

BlockPos

field

state

Colliding block's state

IBlockState

DeviceButtonDownEvent

Fired when a button on the mouse or keyboard is pressed/released. Can be cancelled.

TypeNameDescriptionSignature

field

keyId

Pressed button code

int

field

device

Device type, one of: keyboard, mouse

string

GameEndEvent

Fired when a Hypixel game is over (when the "You won! Want to play again?" message appears). Not cancellable.

TypeNameDescriptionSignature

field

gameType

Game type that was played

string

field

win

Whether the game was won

int

GamemodeUpdateEvent

Fired when a Hypixel game mode has changed, when you switch lobbies, when the game starts, etc. Not cancellable.

TypeNameDescriptionSignature

field

newGamemode

New game mode type

string

GameStartEvent

Fired when a Hypixel game starts. Not cancellable.

TypeNameDescriptionSignature

field

gamemode

Started game mode

string

PacketSendEvent

Fired when a Packet is being sent from the Client to the Server. Can be cancelled.

TypeNameDescriptionSignature

field

packet

Packet being sent

Packet

PacketReceiveEvent

Fired when a Packet is received by the Client. Can be cancelled.

TypeNameDescriptionSignature

field

packet

Packet received

Packet

This event is fired asynchronously. To prevent a potential race condition, any changes you make to the Minecraft object (mc) are ignored, unless you specifically request it. You have to use the following snippet:

// by the time the event has been executed, the 
// values in mc can become outdated, if the game 
// updates the player's position, for example,
// so we have to force an object update:
mc.update();

// changing something in Minecraft here, values
// are up-to-date. For the sake of it, let's use
// the player's Y position
mc.thePlayer.motionY += 0.05;

// remember: changes are ignored; forcing an update
mc.commit();

Code that's run after update() should take as little time as possible. You can perform multiple operations in that "block", just remember that you have < 0.05s in code execution time to make any changes, otherwise the game would continue to its next update, and the values can become outdated again. YMMV.

ParticleSpawnEvent

Fired when a particle is spawned in the World. Not cancellable.

TypeNameDescriptionSignature

field

id

Particle ID

int

PlayerKillEvent

Fired when the Client detects a Player kill. Not cancellable.

TypeNameDescriptionSignature

field

entity

Killed player

EntityPlayer

PlayerMoveEvent

Fired when the Player entity is moved. Can be cancelled.

TypeNameDescriptionSignature

field

x

Player's X position

double

field

y

Player's Y position

double

field

z

Player's Z position

double

function

setSpeed

Sets the player's speed

void(double)

function

setSpeedCustom

Same as setSpeed, but allows to customize yaw/forward/strafe/angle

void(object)

Required properties for setSpeedCustom's argument:

TypeNameDescriptionSignature

field

moveSpeed

Moving speed

double

field

yaw

Yaw rotation

double

field

moveForward

Forward movement input

double

field

moveStrafe

Strafe movement input

double

field

angle

Angle at which the player is moving

double

PreUpdateEvent

Fired before the Player updates are sent to the Server. Can be cancelled.

TypeNameDescriptionSignature

field

posX

Player's X position

double

field

posY

Player's Y position

double

field

posZ

Player's Z position

double

field

motionX

Player's X motion

double

field

motionY

Player's Y motion

double

field

motionZ

Player's Z motion

double

field

rotationYaw

Player's yaw rotation

float

field

rotationPitch

Player's pitch rotation

float

field

onGround

Whether the player is on ground

boolean

RenderBlockEvent

Fired when a Block in the World is rendered. Can be cancelled.

TypeNameDescriptionSignature

field

state

Rendering Block's state

IBlockState

field

pos

Rendering Block's position

BlockPos

field

shouldBlock

Whether the block should be rendered

boolean

RenderScreenEvent

Fired when the Screen Overlay is being rendered. Not cancellable.

TypeNameDescriptionSignature

field

partialTicks

Ticks elapsed since the last render tick

float

field

scaledResolution

Scaled Window resolution

ScaledResolution

RenderWorldEvent

Fired when the World is being rendered. Not cancellable.

TypeNameDescriptionSignature

field

partialTicks

Ticks elapsed since the last render tick

float

ServerConnectEvent

Fired when the User is connecting to a Server. Not cancellable.

TypeNameDescriptionSignature

field

connectingHostname

Server's domain name (e.g. mc.hypixel.net)

string

field

connectingIp

Server's resolved IP

string

ServerDisconnectEvent

Fired when the User gets disconnected from a Server. Not cancellable.

TypeNameDescriptionSignature

field

message

Disconnect reason

IChatComponent

SlowdownEvent

Fired when the Player gets slowed down. Can be cancelled.

TypeNameDescriptionSignature

field

forwardMultiplier

Slowdown forward multiplier, default: 0.2

float

field

strafeMultiplier

Slowdown strafe multiplier, default: 0.2

float

SyncCurrentSlotEvent

Fired when the current Player's item is synced with the Server. Can be cancelled.

TypeNameDescriptionSignature

field

serverSlot

Serverside slot ID

int

field

clientSlot

Clientside slot ID

int

LoadWorldEvent

Fired when the World is changed. Not cancellable.

PlayerJumpEvent

Fired when the Player jumps. Can be cancelled.

PostUpdateEvent

Fired when the Player updates have been sent to the server. Not cancellable.

SafeWalkEvent

Fired when the Player is moving. Can be cancelled. If cancelled, will make the Player not fall of block edges.

StepConfirmEvent

Fired when the Player is stepping up a block. Not cancellable.

TickUpdateEvent

Fired every game tick (0.05s). Not cancellable.

UpdateEvent

Fired when the Player is being updated. Can be cancelled.

Last updated