isaacscript-common 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +1 -1
  2. package/classes/DefaultMap.d.ts +1 -1
  3. package/classes/ModUpgraded.d.ts +8 -2
  4. package/constants.d.ts +5 -5
  5. package/constants.lua +1 -1
  6. package/{constantsMax.d.ts → constantsFirstLast.d.ts} +0 -0
  7. package/{constantsMax.lua → constantsFirstLast.lua} +0 -0
  8. package/enums/HealthType.d.ts +2 -2
  9. package/enums/ModCallbackCustom.d.ts +753 -2
  10. package/features/debugDisplay/exports.d.ts +36 -36
  11. package/features/deployJSONRoom.d.ts +1 -1
  12. package/features/extraConsoleCommands/commandsDisplay.d.ts +18 -18
  13. package/features/extraConsoleCommands/init.d.ts +3 -2
  14. package/features/extraConsoleCommands/init.lua +76 -76
  15. package/features/extraConsoleCommands/{commands.d.ts → listCommands.d.ts} +17 -17
  16. package/features/extraConsoleCommands/{commands.lua → listCommands.lua} +9 -9
  17. package/features/{isPonyActive.d.ts → ponyDetection.d.ts} +0 -0
  18. package/features/{isPonyActive.lua → ponyDetection.lua} +2 -2
  19. package/features/{preventCollectibleRotate.d.ts → preventCollectibleRotation.d.ts} +1 -1
  20. package/features/{preventCollectibleRotate.lua → preventCollectibleRotation.lua} +3 -3
  21. package/features/saveDataManager/exports.d.ts +13 -10
  22. package/features/saveDataManager/load.d.ts +1 -1
  23. package/features/saveDataManager/main.d.ts +1 -1
  24. package/features/saveDataManager/maps.d.ts +1 -1
  25. package/features/saveDataManager/save.d.ts +1 -1
  26. package/functions/cards.lua +5 -5
  27. package/functions/character.lua +2 -2
  28. package/functions/chargeBar.d.ts +1 -1
  29. package/functions/collectibleCacheFlag.d.ts +4 -4
  30. package/functions/collectibleSet.lua +2 -2
  31. package/functions/collectibles.lua +5 -5
  32. package/functions/enums.d.ts +3 -3
  33. package/functions/jsonRoom.d.ts +1 -1
  34. package/functions/pills.lua +9 -9
  35. package/functions/playerDataStructures.d.ts +51 -0
  36. package/functions/playerDataStructures.lua +4 -0
  37. package/functions/playerHealth.d.ts +1 -1
  38. package/functions/pocketItems.d.ts +1 -1
  39. package/functions/run.lua +2 -2
  40. package/functions/spawnCollectible.lua +3 -3
  41. package/functions/trinketGive.d.ts +1 -1
  42. package/functions/trinkets.lua +5 -5
  43. package/functions/utils.d.ts +2 -2
  44. package/index.d.ts +14 -13
  45. package/index.lua +12 -12
  46. package/initFeatures.lua +6 -6
  47. package/{types → interfaces}/AddCallbackParameterCustom.d.ts +0 -0
  48. package/{types → interfaces}/AddCallbackParameterCustom.lua +0 -0
  49. package/{types → interfaces}/ChargeBarSprites.d.ts +0 -0
  50. package/{types → interfaces}/ChargeBarSprites.lua +0 -0
  51. package/{types → interfaces}/JSONDoor.d.ts +1 -0
  52. package/{types → interfaces}/JSONDoor.lua +0 -0
  53. package/{types → interfaces}/JSONEntity.d.ts +1 -0
  54. package/{types → interfaces}/JSONEntity.lua +0 -0
  55. package/{types → interfaces}/JSONRoom.d.ts +1 -5
  56. package/{types → interfaces}/JSONRoom.lua +0 -0
  57. package/{types → interfaces}/JSONRooms.d.ts +0 -0
  58. package/{types → interfaces}/JSONRooms.lua +0 -0
  59. package/{types → interfaces}/JSONSpawn.d.ts +1 -0
  60. package/{types → interfaces}/JSONSpawn.lua +0 -0
  61. package/{types → interfaces}/PlayerHealth.d.ts +1 -0
  62. package/{types → interfaces}/PlayerHealth.lua +0 -0
  63. package/{types → interfaces}/PocketItemDescription.d.ts +1 -0
  64. package/{types → interfaces}/PocketItemDescription.lua +0 -0
  65. package/interfaces/SaveData.d.ts +29 -0
  66. package/{types → interfaces}/SaveData.lua +0 -0
  67. package/{types → interfaces}/TrinketSituation.d.ts +1 -0
  68. package/{types → interfaces}/TrinketSituation.lua +0 -0
  69. package/{types → interfaces}/private/TSTLClassMetatable.d.ts +0 -0
  70. package/{types → interfaces}/private/TSTLClassMetatable.lua +0 -0
  71. package/maps/cardMap.lua +85 -85
  72. package/maps/characterMap.lua +58 -58
  73. package/maps/pillEffectMap.lua +39 -39
  74. package/maps/roomTypeMap.lua +12 -12
  75. package/objects/callbackRegisterFunctions.d.ts +1 -1
  76. package/objects/roomTypeNames.lua +1 -1
  77. package/package.json +1 -1
  78. package/types/PickingUpItem.d.ts +12 -2
  79. package/types/PickingUpItem.lua +3 -0
  80. package/upgradeMod.d.ts +2 -1
  81. package/types/SaveData.d.ts +0 -28
@@ -1,24 +1,217 @@
1
1
  /**
2
- * These are the custom callbacks available for use once the mod object has been upgraded. Also see
3
- * the `upgradeMod` function.
2
+ * - The Isaac API offers a lot of callbacks, but a lot of times there isn't one for the specific
3
+ * thing that you are looking to do. So, `isaacscript-common` adds a bunch of new callbacks that
4
+ * you can use.
5
+ * - The extra callbacks are efficient such that no code is ran until they have one or more
6
+ * subscriptions.
7
+ * - You must upgrade your mod with the `upgradeMod` helper function before using a custom callback.
4
8
  */
5
9
  export declare enum ModCallbackCustom {
10
+ /**
11
+ * Fires on the first `MC_POST_BOMB_UPDATE` frame for each bomb.
12
+ *
13
+ * This callback is useful because many attributes cannot be set or retrieved properly in the
14
+ * normal `MC_POST_BOMB_INIT` callback.
15
+ *
16
+ * When registering the callback, takes an optional second argument that will make the callback
17
+ * only fire if the bomb variant matches the `BombVariant` provided.
18
+ *
19
+ * ```ts
20
+ * function postBombInitLate(bomb: EntityBomb): void {}
21
+ * ```
22
+ */
6
23
  POST_BOMB_INIT_LATE = 0,
24
+ /**
25
+ * Fires from the `MC_POST_RENDER` callback when one of Forgotten's bone clubs is swung or thrown.
26
+ *
27
+ * ```ts
28
+ * function postBoneSwing(boneClub: EntityKnife): void {}
29
+ * ```
30
+ */
7
31
  POST_BONE_SWING = 1,
32
+ /**
33
+ * Fires from the `MC_POST_PICKUP_INIT` callback on the first time that a player has seen the
34
+ * respective collectible on the run. For more details on how this is calculated, see the
35
+ * documentation for the `getCollectibleIndex` helper function.
36
+ *
37
+ * This callback is useful because collectibles will despawn upon leaving the room and respawn
38
+ * upon re-entering the room. Additionally, when playing as Tainted Isaac, the
39
+ * `MC_POST_PICKUP_INIT` callback will fire every time the item shifts.
40
+ *
41
+ * When registering the callback, takes an optional second argument that will make the callback
42
+ * only fire if the collectible type matches the `CollectibleType` provided.
43
+ *
44
+ * ```ts
45
+ * function postCollectibleInitLate(collectible: EntityPickup): void {}
46
+ * ```
47
+ */
8
48
  POST_COLLECTIBLE_INIT_FIRST = 2,
49
+ /**
50
+ * Fires from the `MC_POST_PLAYER_RENDER` callback on the first frame that the "TeleportUp"
51
+ * animation begins playing after a player triggers a Cursed Eye teleport or a Cursed Skull
52
+ * teleport. (Both of these have the same effect in causing Isaac to be teleported to a random
53
+ * room.)
54
+ *
55
+ * ```ts
56
+ * function postCursedTeleport(player: EntityPlayer): void {}
57
+ * ```
58
+ */
9
59
  POST_CURSED_TELEPORT = 3,
60
+ /**
61
+ * Fires from the `MC_POST_PEFFECT_UPDATE` callback when a player enters the loading zone of a
62
+ * custom door created with the `spawnCustomDoor` helper function.
63
+ *
64
+ * When registering the callback, takes an optional second argument that will make the callback
65
+ * only fire if it matches the `DoorVariant` provided.
66
+ *
67
+ * ```ts
68
+ * function postCustomDoorEnter(
69
+ * player: EntityPlayer,
70
+ * effectVariant: int,
71
+ * doorSlot: DoorSlot,
72
+ * direction: Direction,
73
+ * ): void {}
74
+ * ```
75
+ */
10
76
  POST_CUSTOM_DOOR_ENTER = 4,
77
+ /**
78
+ * Fires from the `MC_POST_PLAYER_UPDATE` callback after the player has finished the death
79
+ * animation, has teleported to the previous room, and is ready to play the animation for the
80
+ * modded revival item. The `revivalType` will match the value returned from the
81
+ * `MC_PRE_CUSTOM_REVIVE` callback.
82
+ *
83
+ * In this callback, you must play an animation with something along the lines of
84
+ * `player.AnimateCollectible(CollectibleTypeCustom.COLLECTIBLE_MY_REVIVAL_ITEM);`, otherwise the
85
+ * animation for a 1-Up will play.
86
+ *
87
+ * When registering the callback, takes an optional second argument that will make the callback
88
+ * only fire if the revival type matches the one provided.
89
+ *
90
+ * ```ts
91
+ * function postCustomRevive(player: EntityPlayer, revivalType: int) {}
92
+ * ```
93
+ */
11
94
  POST_CUSTOM_REVIVE = 5,
12
95
  POST_DOOR_RENDER = 6,
13
96
  POST_DOOR_UPDATE = 7,
97
+ /**
98
+ * Fires on the first `MC_POST_EFFECT_UPDATE` frame for each effect.
99
+ *
100
+ * This callback is useful because many attributes cannot be set or retrieved properly in the
101
+ * normal `MC_POST_EFFECT_INIT` callback.
102
+ *
103
+ * When registering the callback, takes an optional second argument that will make the callback
104
+ * only fire if the effect variant matches the `EffectVariant` provided.
105
+ *
106
+ * ```ts
107
+ * function postEffectInitLate(effect: EntityEffect): void {}
108
+ * ```
109
+ */
14
110
  POST_EFFECT_INIT_LATE = 8,
111
+ /**
112
+ * Fires from the `MC_POST_EFFECT_UPDATE` callback when an effect's state has changed from what it
113
+ * was on the previous frame.
114
+ *
115
+ * When registering the callback, takes an optional second argument that will make the callback
116
+ * only fire if it matches the `EffectVariant` provided.
117
+ *
118
+ * ```ts
119
+ * function postEffectStateChanged(
120
+ * effect: EntityEffect,
121
+ * previousState: int,
122
+ * currentState: int,
123
+ * ): void {}
124
+ * ```
125
+ */
15
126
  POST_EFFECT_STATE_CHANGED = 9,
127
+ /**
128
+ * Fires one `MC_POST_UPDATE` frame after the player has used the Esau Jr. item. (The player is
129
+ * not updated to the new character until a game frame has passed.)
130
+ *
131
+ * ```ts
132
+ * function postEsauJr(player: EntityPlayer): void {}
133
+ * ```
134
+ */
16
135
  POST_ESAU_JR = 10,
136
+ /**
137
+ * Fires on the first `MC_FAMILIAR_UPDATE` frame for each familiar.
138
+ *
139
+ * This callback is useful because many attributes cannot be set or retrieved properly in the
140
+ * normal `MC_POST_TEAR_INIT` callback.
141
+ *
142
+ * When registering the callback, takes an optional second argument that will make the callback
143
+ * only fire if the familiar variant matches the `FamiliarVariant` provided.
144
+ *
145
+ * ```ts
146
+ * function postTearInitLate(familiar: EntityFamiliar): void {}
147
+ * ```
148
+ */
17
149
  POST_FAMILIAR_INIT_LATE = 11,
150
+ /**
151
+ * Fires from the `MC_POST_FAMILIAR_UPDATE` callback when a familiar's state has changed from what
152
+ * it was on the previous frame.
153
+ *
154
+ * When registering the callback, takes an optional second argument that will make the callback
155
+ * only fire if it matches the `FamiliarVariant` provided.
156
+ *
157
+ * ```ts
158
+ * function postFamiliarStateChanged(
159
+ * familiar: EntityFamiliar,
160
+ * previousState: int,
161
+ * currentState: int,
162
+ * ): void {}
163
+ * ```
164
+ */
18
165
  POST_FAMILIAR_STATE_CHANGED = 12,
166
+ /**
167
+ * Fires one `MC_POST_UPDATE` frame after the player has first used the Esau Jr. item. (The player
168
+ * is not updated to the new character until a game frame has passed.)
169
+ *
170
+ * This callback is useful because there is no way to get access to the Esau Jr. character entity
171
+ * before the player has actually used the Esau Jr. item.
172
+ *
173
+ * ```ts
174
+ * function postFirstEsauJr(player: EntityPlayer): void {}
175
+ * ```
176
+ */
19
177
  POST_FIRST_ESAU_JR = 13,
178
+ /**
179
+ * Fires after the player has used the Flip item for the first time. Unlike the vanilla
180
+ * `MC_USE_ITEM` callback, this callback will return the player object for the new Lazarus (not
181
+ * the one who used the Flip item).
182
+ *
183
+ * This callback is useful because there is no way to get access to the "flipped" character entity
184
+ * before the player has actually used the Flip item.
185
+ *
186
+ * ```ts
187
+ * function postFirstFlip(player: EntityPlayer): void {}
188
+ * ```
189
+ */
20
190
  POST_FIRST_FLIP = 14,
191
+ /**
192
+ * Fires after the player has used the Flip item. Unlike the vanilla `MC_USE_ITEM` callback, this
193
+ * callback will return the player object for the new Lazarus (not the one who used the Flip
194
+ * item).
195
+ *
196
+ * This callback is useful because there is no way to get access to the "flipped" character entity
197
+ * before the player has actually used the Flip item.
198
+ *
199
+ * ```ts
200
+ * function postFlip(player: EntityPlayer): void {}
201
+ * ```
202
+ */
21
203
  POST_FLIP = 15,
204
+ /**
205
+ * Similar to the vanilla callback of the same name, but fires in the correct order with respect
206
+ * to the `MC_POST_NEW_LEVEL` and the `MC_POST_NEW_ROOM` callbacks:
207
+ *
208
+ * `MC_POST_GAME_STARTED_REORDERED` --> `MC_POST_NEW_LEVEL_REORDERED` -->
209
+ * `MC_POST_NEW_ROOM_REORDERED`
210
+ *
211
+ * ```ts
212
+ * function postGameStartedReordered(isContinued: boolean): void {}
213
+ * ```
214
+ */
22
215
  POST_GAME_STARTED_REORDERED = 16,
23
216
  /**
24
217
  * Fires from the `POST_UPDATE` callback when the Greed Mode wave increases.
@@ -28,12 +221,89 @@ export declare enum ModCallbackCustom {
28
221
  * ```
29
222
  */
30
223
  POST_GREED_MODE_WAVE = 17,
224
+ /**
225
+ * Fires from the `MC_POST_UPDATE` update when a grid entity changes to a state that corresponds
226
+ * to the broken state for the respective grid entity type.
227
+ *
228
+ * When registering the callback, takes an optional second argument that will make the callback
229
+ * only fire if it matches the `GridEntityType` provided.
230
+ *
231
+ * ```ts
232
+ * function postGridEntityBroken(gridEntity: GridEntity): void {}
233
+ * ```
234
+ */
31
235
  POST_GRID_ENTITY_BROKEN = 18,
236
+ /**
237
+ * Fires from the `MC_POST_UPDATE` callback when a new entity collides with a grid entity.
238
+ *
239
+ * When registering the callback, takes an optional second argument that will make the callback
240
+ * only fire if it matches the `GridEntityType` provided.
241
+ *
242
+ * ```ts
243
+ * function postGridEntityCollision(
244
+ * gridEntity: GridEntity,
245
+ * entity: Entity,
246
+ * ): void {}
247
+ * ```
248
+ */
32
249
  POST_GRID_ENTITY_COLLISION = 19,
250
+ /**
251
+ * Fires when a new grid entity is initialized. Specifically, this is either:
252
+ *
253
+ * - in the `MC_POST_NEW_ROOM` callback (firing every time a room is entered, even if the entity
254
+ * was previously there on a previous room entry)
255
+ * - in the `MC_POST_UPDATE` callback (if the entity appeared mid-way through the room, like when
256
+ * the trapdoor appears after defeating It Lives!)
257
+ *
258
+ * When registering the callback, takes an optional second argument that will make the callback
259
+ * only fire if it matches the `GridEntityType` provided.
260
+ *
261
+ * ```ts
262
+ * function postGridEntityInit(gridEntity: GridEntity): void {}
263
+ * ```
264
+ */
33
265
  POST_GRID_ENTITY_INIT = 20,
266
+ /**
267
+ * Fires from the `MC_POST_UPDATE` callback when a new grid entity is removed. Specifically, this
268
+ * on the frame after it no longer exists (where it did exist a frame ago).
269
+ *
270
+ * When registering the callback, takes an optional second argument that will make the callback
271
+ * only fire if it matches the `GridEntityType` provided.
272
+ *
273
+ * ```ts
274
+ * function postGridEntityRemove(
275
+ * gridIndex: int,
276
+ * gridEntityType: GridEntityType,
277
+ * ): void {}
278
+ * ```
279
+ */
34
280
  POST_GRID_ENTITY_REMOVE = 21,
35
281
  POST_GRID_ENTITY_RENDER = 22,
282
+ /**
283
+ * Fires from the `MC_POST_UPDATE` callback when a grid entity changes its state.
284
+ *
285
+ * When registering the callback, takes an optional second argument that will make the callback
286
+ * only fire if it matches the `GridEntityType` provided.
287
+ *
288
+ * ```ts
289
+ * function postGridEntityStateChanged(
290
+ * gridEntity: GridEntity,
291
+ * oldState: int,
292
+ * newState: int,
293
+ * ): void {}
294
+ * ```
295
+ */
36
296
  POST_GRID_ENTITY_STATE_CHANGED = 23,
297
+ /**
298
+ * Fires from the `MC_POST_UPDATE` callback on every frame that a grid entity exists.
299
+ *
300
+ * When registering the callback, takes an optional second argument that will make the callback
301
+ * only fire if it matches the `GridEntityType` provided.
302
+ *
303
+ * ```ts
304
+ * function postGridEntityUpdate(gridEntity: GridEntity): void {}
305
+ * ```
306
+ */
37
307
  POST_GRID_ENTITY_UPDATE = 24,
38
308
  /**
39
309
  * Fires from the `POST_PEFFECT_UPDATE` callback when the player loses a Holy Mantle temporary
@@ -57,53 +327,534 @@ export declare enum ModCallbackCustom {
57
327
  * ```
58
328
  */
59
329
  POST_HOLY_MANTLE_REMOVED = 25,
330
+ /**
331
+ * Fires from `MC_POST_PEFFECT_UPDATE` callback when the player loses charge on their active
332
+ * collectible item, implying that the item was just used.
333
+ *
334
+ * This callback is useful because the `MC_USE_ITEM` callback does not fire when The Candle, Red
335
+ * Candle, and Bob's Rotten Brain are discharged.
336
+ *
337
+ * Note that this callback will not fire if the active item is both discharged and swapped for
338
+ * another item / discharged on the same frame, like in the case of Alabaster Box.
339
+ *
340
+ * When registering the callback, takes an optional second argument that will make the callback
341
+ * only fire if it matches the `CollectibleType` provided.
342
+ *
343
+ * ```ts
344
+ * function postItemDischarge(
345
+ * player: EntityPlayer,
346
+ * collectibleType: CollectibleType | int,
347
+ * activeSlot: ActiveSlot,
348
+ * ): void {}
349
+ * ```
350
+ */
60
351
  POST_ITEM_DISCHARGE = 26,
352
+ /**
353
+ * Fires from the `MC_POST_PEFFECT_UPDATE` callback when an item is no longer queued (i.e. when
354
+ * the animation of the player holding the item above their head is finished and the item is
355
+ * actually added to the player's inventory).
356
+ *
357
+ * Note that this callback will only fire once per Forgotten/Soul pair.
358
+ *
359
+ * - When registering the callback, takes an optional second argument that will make the callback
360
+ * only fire if it matches the `ItemType` provided.
361
+ * - When registering the callback, takes an optional third argument that will make the callback
362
+ * only fire if the `CollectibleType` or the `TrinketType` matches the ID provided.
363
+ *
364
+ * ```ts
365
+ * function postItemPickup(
366
+ * player: EntityPlayer,
367
+ * pickingUpItem: PickingUpItem,
368
+ * ): void {}
369
+ * ```
370
+ */
61
371
  POST_ITEM_PICKUP = 27,
372
+ /**
373
+ * Fires on the first `MC_POST_KNIFE_UPDATE` frame for each knife.
374
+ *
375
+ * This callback is useful because many attributes cannot be set or retrieved properly in the
376
+ * normal `MC_POST_KNIFE_INIT` callback.
377
+ *
378
+ * When registering the callback, takes an optional second argument that will make the callback
379
+ * only fire if the knife variant matches the `KnifeVariant` provided.
380
+ *
381
+ * ```ts
382
+ * function postKnifeInitLate(knife: EntityKnife): void {}
383
+ * ```
384
+ */
62
385
  POST_KNIFE_INIT_LATE = 28,
386
+ /**
387
+ * Fires on the first `MC_POST_LASER_UPDATE` frame for each laser.
388
+ *
389
+ * This callback is useful because many attributes cannot be set or retrieved properly in the
390
+ * normal `MC_POST_LASER_INIT` callback.
391
+ *
392
+ * When registering the callback, takes an optional second argument that will make the callback
393
+ * only fire if the laser variant matches the `LaserVariant` provided.
394
+ *
395
+ * ```ts
396
+ * function postLaserInitLate(laser: EntityLaser): void {}
397
+ * ```
398
+ */
63
399
  POST_LASER_INIT_LATE = 29,
400
+ /**
401
+ * The same as the vanilla callback of the same name, but fires in the correct order with respect
402
+ * to the `MC_POST_GAME_STARTED` and the `MC_POST_NEW_ROOM` callbacks:
403
+ *
404
+ * `MC_POST_GAME_STARTED_REORDERED` --> `MC_POST_NEW_LEVEL_REORDERED` -->
405
+ * `MC_POST_NEW_ROOM_REORDERED`
406
+ *
407
+ * If some specific cases, mods can change the current level during run initialization (on the 0th
408
+ * frame). However, due to how the callback reordering works, the custom
409
+ * `MC_POST_NEW_LEVEL_REORDERED` callback will never fire on the 0th frame. To get around this,
410
+ * call the `forceNewLevelCallback()` function before changing levels to temporarily force the
411
+ * callback to fire.
412
+ *
413
+ * ```ts
414
+ * function postNewLevelReordered(): void {}
415
+ * ```
416
+ */
64
417
  POST_NEW_LEVEL_REORDERED = 30,
418
+ /**
419
+ * Fires on the first `MC_POST_NEW_ROOM` or `MC_PRE_ENTITY_SPAWN` callback where being in a new
420
+ * room is detected. This is useful because the vanilla `MC_POST_NEW_ROOM` callback fires only
421
+ * after entities in the room have been initialized and updated once, which means that it is
422
+ * possible for entity-related code to run before room-related-initialization has been performed.
423
+ *
424
+ * ```ts
425
+ * function postNewRoomEarly(): void {}
426
+ * ```
427
+ */
65
428
  POST_NEW_ROOM_EARLY = 31,
429
+ /**
430
+ * The same as the vanilla callback of the same name, but fires in the correct order with respect
431
+ * to the `MC_POST_GAME_STARTED` and the `MC_POST_NEW_LEVEL` callbacks:
432
+ *
433
+ * `MC_POST_GAME_STARTED_REORDERED` --> `MC_POST_NEW_LEVEL_REORDERED` -->
434
+ * `MC_POST_NEW_ROOM_REORDERED`
435
+ *
436
+ * If some specific cases, mods can change the current room during run initialization (on the 0th
437
+ * frame). However, due to how the callback reordering works, the custom
438
+ * `MC_POST_NEW_ROOM_REORDERED` callback will never fire on the 0th frame. To get around this,
439
+ * call the `forceNewRoomCallback()` function before changing levels to temporarily force the
440
+ * callback to fire.
441
+ *
442
+ * ```ts
443
+ * function postNewRoomReordered(): void {}
444
+ * ```
445
+ */
66
446
  POST_NEW_ROOM_REORDERED = 32,
447
+ /**
448
+ * Fires on the first `MC_NPC_UPDATE` frame for each NPC.
449
+ *
450
+ * This callback is useful because many attributes cannot be set or retrieved properly in the
451
+ * normal `MC_POST_NPC_INIT` callback.
452
+ *
453
+ * When registering the callback, takes an optional second argument that will make the callback
454
+ * only fire if the NPC's entity type matches the entity type provided.
455
+ *
456
+ * ```ts
457
+ * function postNPCInitLate(npc: EntityNPC): void {}
458
+ * ```
459
+ */
67
460
  POST_NPC_INIT_LATE = 33,
461
+ /**
462
+ * Fires from the `MC_POST_NPC_UPDATE` callback when an NPC's state has changed from what it was
463
+ * on the previous frame.
464
+ *
465
+ * - When registering the callback, takes an optional second argument that will make the callback
466
+ * only fire if it matches the `EntityType` provided.
467
+ * - When registering the callback, takes an optional third argument that will make the callback
468
+ * only fire if it matches the variant provided.
469
+ *
470
+ * ```ts
471
+ * function postNPCStateChanged(
472
+ * npc: EntityNPC,
473
+ * previousState: int,
474
+ * currentState: int,
475
+ * ): void {}
476
+ * ```
477
+ */
68
478
  POST_NPC_STATE_CHANGED = 34,
69
479
  POST_PEFFECT_UPDATE_REORDERED = 35,
480
+ /**
481
+ * Fires on the first `MC_POST_RENDER` frame that a pickup plays the "Collect" animation.
482
+ *
483
+ * Use this callback to know when a pickup is added to the player's inventory or health.
484
+ *
485
+ * When registering the callback, takes an optional second argument that will make the callback
486
+ * only fire if the pickup variant matches the `PickupVariant` provided.
487
+ *
488
+ * ```ts
489
+ * function postPickupCollect(pickup: EntityPickup, player: EntityPlayer): void {}
490
+ * ```
491
+ */
70
492
  POST_PICKUP_COLLECT = 36,
493
+ /**
494
+ * Fires on the first `MC_POST_PICKUP_UPDATE` frame for each pickup.
495
+ *
496
+ * This callback is useful because many attributes cannot be set or retrieved properly in the
497
+ * normal `MC_POST_PICKUP_INIT` callback.
498
+ *
499
+ * When registering the callback, takes an optional second argument that will make the callback
500
+ * only fire if the pickup variant matches the `PickupVariant` provided.
501
+ *
502
+ * ```ts
503
+ * function postPickupInitLate(pickup: EntityPickup): void {}
504
+ * ```
505
+ */
71
506
  POST_PICKUP_INIT_LATE = 37,
507
+ /**
508
+ * Fires from the `MC_POST_PICKUP_UPDATE` callback when a pickup's state has changed from what it
509
+ * was on the previous frame.
510
+ *
511
+ * When registering the callback, takes an optional second argument that will make the callback
512
+ * only fire if it matches the `PickupVariant` provided.
513
+ *
514
+ * ```ts
515
+ * function postPickupStateChanged(
516
+ * pickup: EntityPickup,
517
+ * previousState: int,
518
+ * currentState: int,
519
+ * ): void {}
520
+ * ```
521
+ */
72
522
  POST_PICKUP_STATE_CHANGED = 38,
73
523
  POST_PIT_RENDER = 39,
74
524
  POST_PIT_UPDATE = 40,
525
+ /**
526
+ * Fires from the `MC_POST_PEFFECT_UPDATE` callback when a player entity gains or loses any health
527
+ * (i.e. hearts). For more information, see the `PlayerHealth` enum.
528
+ *
529
+ * When registering the callback, takes an optional second argument that will make the callback
530
+ * only fire if it matches the `PlayerVariant` provided.
531
+ *
532
+ * ```ts
533
+ * function postPlayerChangeHealth(
534
+ * player: EntityPlayer,
535
+ * healthType: HealthType,
536
+ * amount: int,
537
+ * ) {}
538
+ * ```
539
+ */
75
540
  POST_PLAYER_CHANGE_HEALTH = 41,
541
+ /**
542
+ * Fires from the `MC_POST_PEFFECT_UPDATE` callback when a player entity changes its player type
543
+ * (i.e. character). For example, it will fire after using Clicker, after dying with the Judas'
544
+ * Shadow collectible, etc.
545
+ *
546
+ * Notably, it does not fire after the player uses the Flip item or the Esau Jr. item, because
547
+ * those items cause separate player entities to be created. Use the `MC_POST_FLIP` and
548
+ * `MC_POST_ESAU_JR` callbacks to handle those situations.
549
+ *
550
+ * ```ts
551
+ * function postPlayerChangeType(
552
+ * player: EntityPlayer,
553
+ * oldCharacter: PlayerType | int,
554
+ * newCharacter: PlayerType | int,
555
+ * ) {}
556
+ * ```
557
+ */
76
558
  POST_PLAYER_CHANGE_TYPE = 42,
559
+ /**
560
+ * Fires from the `MC_ENTITY_TAKE_DMG` callback when a player takes fatal damage. Return false to
561
+ * prevent the fatal damage.
562
+ *
563
+ * Note that:
564
+ *
565
+ * - This function does properly take into account Guppy's Collar, Broken Ankh, Spirit Shackles,
566
+ * and Mysterious Paper.
567
+ *
568
+ * When registering the callback, takes an optional second argument that will make the callback
569
+ * only fire if it matches the `PlayerVariant` provided.
570
+ *
571
+ * ```ts
572
+ * function postPlayerFatalDamage(player: EntityPlayer) {}
573
+ * ```
574
+ */
77
575
  POST_PLAYER_FATAL_DAMAGE = 43,
576
+ /**
577
+ * Fires on the first `MC_POST_PLAYER_UPDATE` frame for each player.
578
+ *
579
+ * This callback is useful because many attributes cannot be set or retrieved properly in the
580
+ * normal `MC_POST_PLAYER_INIT` callback.
581
+ *
582
+ * When registering the callback, takes an optional second argument that will make the callback
583
+ * only fire if the player variant matches the `PlayerVariant` provided.
584
+ *
585
+ * ```ts
586
+ * function postPlayerInitLate(pickup: EntityPickup): void {}
587
+ * ```
588
+ */
78
589
  POST_PLAYER_INIT_LATE = 44,
590
+ /**
591
+ * Similar to the vanilla callback of the same name, but fires after the `MC_POST_GAME_STARTED`
592
+ * callback fires (if the player is spawning on the 0th game frame of the run).
593
+ *
594
+ * This callback is useful for two reasons:
595
+ *
596
+ * 1. Normally, `MC_POST_PLAYER_UPDATE` fires before `MC_POST_GAME_STARTED`. Since mod variables
597
+ * are often initialized at the beginning of the `MC_POST_GAME_STARTED` callback, this can
598
+ * cause problems.
599
+ * 1. Some functions do not work (or crash the game) when called before the `MC_POST_NEW_ROOM`
600
+ * callback. For example, since the level is not generated yet, you will not be able to access
601
+ * any rooms.
602
+ *
603
+ * When registering the callback, takes an optional second argument that will make the callback
604
+ * only fire if the player matches the `PlayerVariant` provided.
605
+ *
606
+ * ```ts
607
+ * function postPlayerInitReordered(player: EntityPlayer): void {}
608
+ * ```
609
+ */
79
610
  POST_PLAYER_INIT_REORDERED = 45,
80
611
  POST_PLAYER_RENDER_REORDERED = 46,
612
+ /**
613
+ * Similar to the vanilla callback of the same name, but fires after the `MC_POST_GAME_STARTED`
614
+ * callback fires (if the player is being updated on the 0th game frame of the run).
615
+ *
616
+ * This callback is useful for two reasons:
617
+ *
618
+ * 1. Normally, PostPlayerUpdate fires before `MC_POST_GAME_STARTED`. Since mod variables are
619
+ * often initialized at the beginning of the `MC_POST_GAME_STARTED` callback, this can cause
620
+ * problems.
621
+ * 1. Some functions do not work (or crash the game) when called before the `MC_POST_NEW_ROOM`
622
+ * callback. For example, since the level is not generated yet, you will not be able to access
623
+ * any rooms.
624
+ *
625
+ * When registering the callback, takes an optional second argument that will make the callback
626
+ * only fire if the player matches the `PlayerVariant` provided.
627
+ *
628
+ * ```ts
629
+ * function postPlayerUpdateReordered(player: EntityPlayer): void {}
630
+ * ```
631
+ */
81
632
  POST_PLAYER_UPDATE_REORDERED = 47,
82
633
  POST_POOP_RENDER = 48,
83
634
  POST_POOP_UPDATE = 49,
84
635
  POST_PRESSURE_PLATE_RENDER = 50,
85
636
  POST_PRESSURE_PLATE_UPDATE = 51,
637
+ /**
638
+ * Fires on the first `MC_POST_PROJECTILE_UPDATE` frame for each projectile.
639
+ *
640
+ * This callback is useful because many attributes cannot be set or retrieved properly in the
641
+ * normal `MC_POST_PROJECTILE_INIT` callback.
642
+ *
643
+ * When registering the callback, takes an optional second argument that will make the callback
644
+ * only fire if the projectile variant matches the `ProjectileVariant` provided.
645
+ *
646
+ * ```ts
647
+ * function postProjectileInitLate(projectile: EntityProjectile): void {}
648
+ * ```
649
+ */
86
650
  POST_PROJECTILE_INIT_LATE = 52,
651
+ /**
652
+ * Fires from the `MC_POST_PEFFECT_UPDATE` callback when a player first picks up a new item. The
653
+ * pickup returned in the callback is assumed to be the first pickup that no longer exists.
654
+ *
655
+ * - When registering the callback, takes an optional second argument that will make the callback
656
+ * only fire if it matches the `PickupVariant` provided.
657
+ * - When registering the callback, takes an optional third argument that will make the callback
658
+ * only fire if it matches the sub-type provided.
659
+ *
660
+ * ```ts
661
+ * function postPurchase(player: EntityPlayer, pickup: EntityPickup): void {}
662
+ * ```
663
+ */
87
664
  POST_PURCHASE = 53,
88
665
  POST_ROCK_RENDER = 54,
89
666
  POST_ROCK_UPDATE = 55,
90
667
  POST_ROOM_CLEAR_CHANGED = 56,
668
+ /**
669
+ * Fires from the `MC_ENTITY_TAKE_DMG` callback when a player takes damage from spikes in a
670
+ * Sacrifice Room.
671
+ *
672
+ * ```ts
673
+ * function postSacrifice(player: EntityPlayer, numSacrifices: int): void {}
674
+ * ```
675
+ */
91
676
  POST_SACRIFICE = 57,
677
+ /**
678
+ * Fires from the `MC_POST_RENDER` callback when a slot entity's animation changes.
679
+ *
680
+ * When registering the callback, takes an optional second argument that will make the callback
681
+ * only fire if it matches the `SlotVariant` provided.
682
+ *
683
+ * ```ts
684
+ * function postSlotAnimationChanged(slot: Entity): void {}
685
+ * ```
686
+ */
92
687
  POST_SLOT_ANIMATION_CHANGED = 58,
688
+ /**
689
+ * Fires from the `MC_POST_RENDER` callback when a slot plays the animation that indicates that it
690
+ * has broken.
691
+ *
692
+ * When registering the callback, takes an optional second argument that will make the callback
693
+ * only fire if it matches the `SlotVariant` provided.
694
+ *
695
+ * ```ts
696
+ * function postSlotDestroyed(slot: Entity): void {}
697
+ * ```
698
+ */
93
699
  POST_SLOT_DESTROYED = 59,
700
+ /**
701
+ * Fires when a new slot entity is initialized. Specifically, this is either:
702
+ *
703
+ * - in the `MC_POST_NEW_ROOM` callback (firing every time a room is entered, even if the entity
704
+ * was previously there on a previous room entry)
705
+ * - in the `MC_POST_UPDATE` callback (if the entity appeared mid-way through the room, like when
706
+ * a Wheel of Fortune card is used)
707
+ *
708
+ * When registering the callback, takes an optional second argument that will make the callback
709
+ * only fire if it matches the `SlotVariant` provided.
710
+ *
711
+ * ```ts
712
+ * function postSlotInit(slot: Entity): void {}
713
+ * ```
714
+ */
94
715
  POST_SLOT_INIT = 60,
716
+ /**
717
+ * Fires from the `MC_POST_RENDER` callback on every frame that a slot entity exists.
718
+ *
719
+ * When registering the callback, takes an optional second argument that will make the callback
720
+ * only fire if it matches the `SlotVariant` provided.
721
+ *
722
+ * ```ts
723
+ * function postSlotRender(slot: Entity): void {}
724
+ * ```
725
+ */
95
726
  POST_SLOT_RENDER = 61,
727
+ /**
728
+ * Fires from the `MC_POST_UPDATE` callback on every frame that a slot entity exists.
729
+ *
730
+ * When registering the callback, takes an optional second argument that will make the callback
731
+ * only fire if it matches the `SlotVariant` provided.
732
+ *
733
+ * ```ts
734
+ * function postSlotUpdate(slot: Entity): void {}
735
+ * ```
736
+ */
96
737
  POST_SLOT_UPDATE = 62,
97
738
  POST_SPIKES_RENDER = 63,
98
739
  POST_SPIKES_UPDATE = 64,
740
+ /**
741
+ * Fires on the first `MC_POST_TEAR_UPDATE` frame for each tear.
742
+ *
743
+ * This callback is useful because many attributes cannot be set or retrieved properly in the
744
+ * normal `MC_POST_TEAR_INIT` callback.
745
+ *
746
+ * When registering the callback, takes an optional second argument that will make the callback
747
+ * only fire if the tear variant matches the `TearVariant` provided.
748
+ *
749
+ * ```ts
750
+ * function postTearInitLate(tear: EntityTear): void {}
751
+ * ```
752
+ */
99
753
  POST_TEAR_INIT_LATE = 65,
754
+ /**
755
+ * Fires on the second `MC_POST_TEAR_UPDATE` frame for each tear (i.e. frame 1).
756
+ *
757
+ * This callback is useful because Incubus tears are not distinguishable until the second frame.
758
+ *
759
+ * When registering the callback, takes an optional second argument that will make the callback
760
+ * only fire if the tear variant matches the `TearVariant` provided.
761
+ *
762
+ * ```ts
763
+ * function postTearInitVeryLate(tear: EntityTear): void {}
764
+ * ```
765
+ */
100
766
  POST_TEAR_INIT_VERY_LATE = 66,
101
767
  POST_TNT_RENDER = 67,
102
768
  POST_TNT_UPDATE = 68,
769
+ /**
770
+ * Fires from the `MC_POST_PEFFECT_UPDATE` callback when a player gains or loses a new
771
+ * transformation.
772
+ *
773
+ * Note that this callback will only fire once per Forgotten/Soul pair.
774
+ *
775
+ * When registering the callback, takes an optional second argument that will make the callback
776
+ * only fire if it matches the `PlayerForm` provided.
777
+ *
778
+ * ```ts
779
+ * function postTransformation(
780
+ * player: EntityPlayer,
781
+ * playerForm: PlayerForm,
782
+ * hasForm: boolean,
783
+ * ): void {}
784
+ * ```
785
+ */
103
786
  POST_TRANSFORMATION = 69,
787
+ /**
788
+ * Fires from `MC_ENTITY_TAKE_DMG` callback when a Wishbone or a Walnut breaks.
789
+ *
790
+ * When registering the callback, takes an optional second argument that will make the callback
791
+ * only fire if it matches the `TrinketType` provided.
792
+ *
793
+ * ```ts
794
+ * function postTrinketBreak(
795
+ * player: EntityPlayer,
796
+ * trinketType: TrinketType | int,
797
+ * ): void {}
798
+ * ```
799
+ */
104
800
  POST_TRINKET_BREAK = 70,
801
+ /**
802
+ * Fires from the `MC_POST_PEFFECT_UPDATE` callback on the frame before a Berserk! effect ends
803
+ * when the player is predicted to die (e.g. they currently have no health left or they took
804
+ * damage in a "Lost" form).
805
+ *
806
+ * When registering the callback, takes an optional second argument that will make the callback
807
+ * only fire if it matches the `PlayerVariant` provided.
808
+ *
809
+ * ```ts
810
+ * function preBerserkDeath(player: EntityPlayer) {}
811
+ * ```
812
+ */
105
813
  PRE_BERSERK_DEATH = 71,
814
+ /**
815
+ * Fires from the `MC_POST_PLAYER_FATAL_DAMAGE` callback when a player is about to die. If you
816
+ * want to initiate a custom revival, return an integer that corresponds to the item or type of
817
+ * revival that you are doing. Otherwise, return undefined to continue the fatal damage.
818
+ *
819
+ * This callback is useful because reviving the player after the game things that player should
820
+ * have died will result in the save data for the run getting deleted.
821
+ *
822
+ * ```ts
823
+ * function preCustomRevive(player: EntityPlayer) {}
824
+ * ```
825
+ */
106
826
  PRE_CUSTOM_REVIVE = 72,
827
+ /**
828
+ * Fires from the `MC_POST_PEFFECT_UPDATE` callback when an item becomes queued (i.e. when the
829
+ * player begins to hold the item above their head).
830
+ *
831
+ * Note that this callback will only fire once per Forgotten/Soul pair.
832
+ *
833
+ * - When registering the callback, takes an optional second argument that will make the callback
834
+ * only fire if it matches the `ItemType` provided.
835
+ * - When registering the callback, takes an optional third argument that will make the callback
836
+ * only fire if the `CollectibleType` or the `TrinketType` matches the ID provided.
837
+ *
838
+ * ```ts
839
+ * function preItemPickup(
840
+ * player: EntityPlayer,
841
+ * pickingUpItem: PickingUpItem,
842
+ * ): void {}
843
+ * ```
844
+ */
107
845
  PRE_ITEM_PICKUP = 73,
846
+ /**
847
+ * Fires on the `MC_POST_RENDER` frame before the player is taken to a new floor. Only fires when
848
+ * a player jumps into a trapdoor or enters a heaven door (beam of light). Does not fire on the
849
+ * first floor of the run. Does not fire when the player reloads/reseeds the current floor (i.e.
850
+ * Forget Me Now, 5-pip dice room).
851
+ *
852
+ * This callback passes the `EntityPlayer` object for the player who jumped into the trapdoor or
853
+ * entered the heaven door, if needed.
854
+ *
855
+ * ```ts
856
+ * function preNewLevel(player: EntityPlayer): void {}
857
+ * ```
858
+ */
108
859
  PRE_NEW_LEVEL = 74
109
860
  }