Skip to content

ModAPI.addEventListener(String eventName, Function callback)

This method is used to add event listeners to the event name specified.

Arguments:

(String) eventName

This argument is used to specify internally which listener array to add the callback to. It has the following valid values:

  • event Called when any event is called. Passes an object with properties:

    • event: String representing the type of event being fired.
    • data: Object representing the original arguments to be passed to the callback.
  • gui Called when the Mod Manager GUI shows up. No arguments passed to callback.

  • load Called when all mods have finished loading.

  • update Called every client tick. No arguments passed to callback.

  • frame Called every frame

  • render Called every time a frame is done rendering. Passes an object with properties: - partialTicks: The partial ticks into the frame. Eg, if the frame was rendered when the in-game clock hit a quarter of a tick, this would be 0.25.

  • sendchatmessage Called just before the player sends a chat message. Passes an object with properties:

    • message: String representing the chat message.
    • preventDefault: Boolean representing whether or not to cancel processing the chat message. Default is false.
  • postmotionupdate Called after player motion is updated. No arguments passed to callback.

  • motionupdate Called on motion update.

    • preventDefault: Boolean representing whether or not to cancel sending motion updates to the server.
  • premotionupdate Called before player motion is updated. Passes an object with properties:

    • yaw: Number representing the player's yaw rotation.
    • pitch: Number representing the player's pitch rotation.
    • onGround: Boolean representing whether the player is on ground or not.
  • key Called when a special keypress is detected. ie: not esc or open chat, like f3 or the letter J. Passes an object with properties:

    • key: Integer representing the LWJGL key code.
    • preventDefault: Boolean representing whether or not to prevent the default action for this key (if any).
  • drawhud Called when the hud is drawing. to make the methods that start with "draw" work you need to run them inside this event. Eg:

ModAPI.addEventListener("drawhud", () => {
    ModAPI.drawStringWithShadow({msg: "your text", x: 0, y: 0, color: -1}) // -1 is white
})

(Function) Callback

The function to call when this event fires.

lwjgl key codes for the key event :

Note: KEY_RETURN is the enter key

CodeKey
0KEY_NONE
1KEY_ESCAPE
2KEY_1
3KEY_2
4KEY_3
5KEY_4
6KEY_5
7KEY_6
8KEY_7
9KEY_8
10KEY_9
11KEY_0
12KEY_MINUS
13KEY_EQUALS
14KEY_BACK
15KEY_TAB
16KEY_Q
17KEY_W
18KEY_E
19KEY_R
20KEY_T
21KEY_Y
22KEY_U
23KEY_I
24KEY_O
25KEY_P
26KEY_LBRACKET
27KEY_RBRACKET
28KEY_RETURN
29KEY_LCONTROL
30KEY_A
31KEY_S
32KEY_D
33KEY_F
34KEY_G
35KEY_H
36KEY_J
37KEY_K
38KEY_L
39KEY_SEMICOLON
40KEY_APOSTROPHE
41KEY_GRAVE
42KEY_LSHIFT
43KEY_BACKSLASH
44KEY_Z
45KEY_X
46KEY_C
47KEY_V
48KEY_B
49KEY_N
50KEY_M
51KEY_COMMA
52KEY_PERIOD
53KEY_SLASH
54KEY_RSHIFT
55KEY_MULTIPLY
56KEY_LMENU
57KEY_SPACE
58KEY_CAPITAL
59KEY_F1
60KEY_F2
61KEY_F3
62KEY_F4
63KEY_F5
64KEY_F6
65KEY_F7
66KEY_F8
67KEY_F9
68KEY_F10
69KEY_NUMLOCK
70KEY_SCROLL
71KEY_NUMPAD7
72KEY_NUMPAD8
73KEY_NUMPAD9
74KEY_SUBTRACT
75KEY_NUMPAD4
76KEY_NUMPAD5
77KEY_NUMPAD6
78KEY_ADD
79KEY_NUMPAD1
80KEY_NUMPAD2
81KEY_NUMPAD3
82KEY_NUMPAD0
83KEY_DECIMAL
84
85
86
87KEY_F11
88KEY_F12
89
90
91
92
93
94
95
96
97
98
99
100KEY_F13
101KEY_F14
102KEY_F15
103KEY_F16
104KEY_F17
105KEY_F18
106
107
108
109
110
111
112KEY_KANA
113KEY_F19
114
115
116
117
118
119
120
121KEY_CONVERT
122
123KEY_NOCONVERT
124
125KEY_YEN
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141KEY_NUMPADEQUALS
142
143
144KEY_CIRCUMFLEX
145KEY_AT
146KEY_COLON
147KEY_UNDERLINE
148KEY_KANJI
149KEY_STOP
150KEY_AX
151KEY_UNLABELED
152
153
154
155
156KEY_NUMPADENTER
157KEY_RCONTROL
158
159
160
161
162
163
164
165
166
167KEY_SECTION
168
169
170
171
172
173
174
175
176
177
178
179KEY_NUMPADCOMMA
180
181KEY_DIVIDE
182
183KEY_SYSRQ
184KEY_RMENU
185
186
187
188
189
190
191
192
193
194
195
196KEY_FUNCTION
197KEY_PAUSE
198
199KEY_HOME
200KEY_UP
201KEY_PRIOR
202
203KEY_LEFT
204
205KEY_RIGHT
206
207KEY_END
208KEY_DOWN
209KEY_NEXT
210KEY_INSERT
211KEY_DELETE
212
213
214
215
216
217
218KEY_CLEAR
219KEY_LMETA
220KEY_RMETA
221KEY_APPS
222KEY_POWER
223KEY_SLEEP