Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 12
Module Events
SenkJu edited this page Sep 3, 2019
·
3 revisions
Code in event functions is executed everytime their associated condition is met.
this.onEnable=function(){// Code in here will be executed directly after the module has been enabled by the user };this.onDisable=function(){// Code in here will be executed directly after the module has been disabled by the user };this.onUpdate=function(){// Code in here is being executed every tick (~20 times per seconds)};this.onMotion=function(event){// Code in here is being executed everytime the player receives motionvareventState=event.getEventState();eventState.getStateName();// PRE or POST };this.onRender2D=function(event){// Code in here will be executed when the client draws its 2D elementsvarpartialTicks=event.getPartialTicks();// Used to render FPS independent animations};this.onRender3D=function(event){// Code in here will be executed when the client draws its 3D elementsvarpartialTicks=event.getPartialTicks();// Used to render FPS independent animations};this.onAttack=function(event){// Code in here will be executed when an entity is being attackedvartargetEntity=event.getTargetEntity();};this.onJump=function(event){// Code in here will be executed when the player jumpsevent.cancelEvent()// Cancels the eventevent.isCancelled()// Whether the event has been cancelledvarmotion=event.getMotion();event.setMotion(0.42);};this.onPacket=function(event){// Code in here will be executed when the client handles a packetevent.cancelEvent()// Cancels the eventevent.isCancelled()// Whether the event has been cancelledvarpacket=event.getPacket();};this.onKey=function(event){// Code in here will be executed when a key is pressedvarpressedKey=event.getKey();// ID of the pressed key (https://minecraft.gamepedia.com/Key_codes)};this.onMove=function(event){// Code in here will be executed when the player movedvarx=event.getX();// Returns x-position of movevary=event.getY();// Returns y-position of movevarz=event.getZ();// Returns z-position of movevarisSafeWalk=event.isSafeWalk();// Whether SafeWalk is enabled for this eventevent.setX(100);// Sets x-position of move to 100event.setY(100);// Sets y-position of move to 100event.setZ(100);// Sets z-position of move to 100event.setSafeWalk(true);// Prevents player from falling off the edge of blocks};