isaacscript-common 15.2.0 → 15.3.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 (29) hide show
  1. package/dist/index.d.ts +66 -44
  2. package/dist/isaacscript-common.lua +110 -59
  3. package/dist/src/classes/ModFeature.d.ts +12 -1
  4. package/dist/src/classes/ModFeature.d.ts.map +1 -1
  5. package/dist/src/classes/ModFeature.lua +112 -55
  6. package/dist/src/classes/callbacks/PostNPCInitFilter.d.ts +0 -5
  7. package/dist/src/classes/callbacks/PostNPCInitFilter.d.ts.map +1 -1
  8. package/dist/src/classes/callbacks/PostNPCInitFilter.lua +0 -3
  9. package/dist/src/classes/callbacks/PostNPCUpdateFilter.d.ts +0 -5
  10. package/dist/src/classes/callbacks/PostNPCUpdateFilter.d.ts.map +1 -1
  11. package/dist/src/classes/callbacks/PostNPCUpdateFilter.lua +0 -3
  12. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.d.ts +21 -13
  13. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.d.ts.map +1 -1
  14. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.lua +7 -1
  15. package/dist/src/classes/features/other/CustomPickups.d.ts.map +1 -1
  16. package/dist/src/classes/features/other/DebugDisplay.lua +1 -1
  17. package/dist/src/enums/ModCallbackCustom.d.ts +33 -30
  18. package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
  19. package/package.json +1 -1
  20. package/src/classes/ModFeature.ts +132 -75
  21. package/src/classes/callbacks/PostNPCInitFilter.ts +0 -6
  22. package/src/classes/callbacks/PostNPCUpdateFilter.ts +0 -6
  23. package/src/classes/features/callbackLogic/GameReorderedCallbacks.ts +21 -13
  24. package/src/classes/features/other/CustomPickups.ts +0 -4
  25. package/src/classes/features/other/DebugDisplay.ts +1 -1
  26. package/src/enums/ModCallbackCustom.ts +33 -30
  27. package/dist/src/indexLua.d.ts +0 -171
  28. package/dist/src/indexLua.d.ts.map +0 -1
  29. package/dist/src/indexLua.lua +0 -1042
@@ -1,5 +1,7 @@
1
1
  import { ModCallback } from "isaac-typescript-definitions";
2
2
  import { ModCallbackCustom } from "../enums/ModCallbackCustom";
3
+ import { isArray } from "../functions/array";
4
+ import { deepCopy } from "../functions/deepCopy";
3
5
  import {
4
6
  getTSTLClassConstructor,
5
7
  getTSTLClassName,
@@ -11,10 +13,14 @@ import { ModUpgradedBase } from "./ModUpgradedBase";
11
13
 
12
14
  export const ADD_CALLBACK_ARGS_KEY = "__addCallbackArgs";
13
15
  export const ADD_CALLBACK_CUSTOM_ARGS_KEY = "__addCallbackCustomArgs";
16
+ const WRAPPED_CALLBACK_METHODS_KEY = "__wrappedCallbackMethods";
17
+ const WRAPPED_CUSTOM_CALLBACK_METHODS_KEY = "__wrappedCustomCallbacksMethods";
14
18
 
15
19
  type ModFeatureConstructor = TSTLClassMetatable["constructor"] & {
16
- [ADD_CALLBACK_ARGS_KEY]: unknown[] | undefined;
17
- [ADD_CALLBACK_CUSTOM_ARGS_KEY]: unknown[] | undefined;
20
+ [ADD_CALLBACK_ARGS_KEY]: unknown | undefined;
21
+ [ADD_CALLBACK_CUSTOM_ARGS_KEY]: unknown | undefined;
22
+ [WRAPPED_CALLBACK_METHODS_KEY]: Map<ModCallback, AnyFunction>;
23
+ [WRAPPED_CUSTOM_CALLBACK_METHODS_KEY]: Map<ModCallbackCustom, AnyFunction>;
18
24
  };
19
25
 
20
26
  /**
@@ -42,86 +48,83 @@ type ModFeatureConstructor = TSTLClassMetatable["constructor"] & {
42
48
  * }
43
49
  * }
44
50
  * ```
51
+ *
52
+ * In almost all cases, you will want the callback functions to be immediately subscribed after
53
+ * instantiating the class. However, if this is not the case, you can pass `false` as the optional
54
+ * second argument to the constructor.
45
55
  */
46
- // eslint-disable-next-line @typescript-eslint/no-extraneous-class
56
+
47
57
  export class ModFeature {
48
- constructor(mod: ModUpgradedBase) {
58
+ private mod: ModUpgradedBase;
59
+
60
+ constructor(mod: ModUpgradedBase, init = true) {
61
+ this.mod = mod;
62
+
63
+ if (init) {
64
+ this.init();
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Runs the `Mod.AddCallback` and `ModUpgraded.AddCallbackCustom` methods for all of the decorated
70
+ * callbacks. Additionally, subscribes the `v` object to the save data manager, if present.
71
+ */
72
+ public init(init = true): void {
49
73
  const constructor = getTSTLClassConstructor(this);
50
74
  if (constructor === undefined) {
51
75
  error("Failed to get the TSTL class constructor for a mod feature.");
52
76
  }
53
77
 
54
- const modFeatureConstructor = constructor as ModFeatureConstructor;
55
- checkAddDecoratedCallbacks(mod, modFeatureConstructor, this);
56
- checkAddDecoratedCallbacksCustom(mod, modFeatureConstructor, this);
57
- checkRegisterSaveDataManager(mod, this);
78
+ const tstlClassName = getTSTLClassName(constructor);
79
+ if (tstlClassName === undefined) {
80
+ error("Failed to get the TSTL class name for a mod feature.");
81
+ }
82
+
83
+ initDecoratedCallbacks(this, constructor, tstlClassName, true, init);
84
+ initDecoratedCallbacks(this, constructor, tstlClassName, false, init);
85
+ initSaveDataManager(this, tstlClassName, init);
86
+ }
87
+
88
+ public uninit(): void {
89
+ this.init(false);
58
90
  }
59
91
  }
60
92
 
61
- function checkAddDecoratedCallbacks(
62
- mod: ModUpgradedBase,
63
- modFeatureConstructor: ModFeatureConstructor,
93
+ function initDecoratedCallbacks(
64
94
  modFeature: ModFeature,
95
+ constructor: TSTLClassMetatable["constructor"],
96
+ tstlClassName: string,
97
+ vanilla: boolean,
98
+ init: boolean,
65
99
  ) {
66
- const addCallbackArgs = modFeatureConstructor[ADD_CALLBACK_ARGS_KEY];
100
+ const modFeatureConstructor = constructor as ModFeatureConstructor;
101
+ const argsKey = vanilla
102
+ ? ADD_CALLBACK_ARGS_KEY
103
+ : ADD_CALLBACK_CUSTOM_ARGS_KEY;
104
+ const addCallbackArgs = modFeatureConstructor[argsKey];
67
105
  if (addCallbackArgs === undefined) {
68
106
  return;
69
107
  }
70
108
 
71
- const tstlClassName = getTSTLClassName(modFeatureConstructor) ?? "Unknown";
109
+ if (!isArray(addCallbackArgs)) {
110
+ error(
111
+ `Failed to initialize/uninitialize the decorated callbacks on a mod feature since the callback arguments on the key of "${argsKey}" was not an array.`,
112
+ );
113
+ }
72
114
 
73
115
  for (const args of addCallbackArgs) {
74
- const parameters = args as unknown[];
75
- const modCallback = parameters.shift() as ModCallback | undefined;
76
- if (modCallback === undefined) {
116
+ if (!isArray(args)) {
77
117
  error(
78
- `Failed to get the ModCallback from the parameters for class: ${tstlClassName}`,
118
+ "Failed to initialize/uninitialize the decorated callbacks on a mod feature since one of the callback arguments was not an array.",
79
119
  );
80
120
  }
81
121
 
82
- const callback = parameters.shift() as
83
- | ((this: void, ...callbackArgs: unknown[]) => void)
84
- | undefined;
85
- if (callback === undefined) {
86
- error(
87
- `Failed to get the callback from the parameters for class: ${tstlClassName}`,
88
- );
89
- }
90
-
91
- /**
92
- * We need to wrap the callback in a new function so that we can explicitly pass the class as
93
- * the first argument. (Otherwise, the method will not be able to properly access `this`.
94
- */
95
- const newCallback = (...callbackArgs: unknown[]) => {
96
- callback(modFeature, ...callbackArgs);
97
- };
98
-
99
- // @ts-expect-error The compiler does not know that the arguments match the method.
100
- mod.AddCallback(modCallback, newCallback, ...parameters);
101
- }
102
- }
103
-
104
- function checkAddDecoratedCallbacksCustom(
105
- mod: ModUpgradedBase,
106
- modFeatureConstructor: ModFeatureConstructor,
107
- modFeature: ModFeature,
108
- ) {
109
- const addCallbackCustomArgs =
110
- modFeatureConstructor[ADD_CALLBACK_CUSTOM_ARGS_KEY];
111
- if (addCallbackCustomArgs === undefined) {
112
- return;
113
- }
122
+ const parameters = deepCopy(args);
114
123
 
115
- const tstlClassName = getTSTLClassName(modFeatureConstructor) ?? "Unknown";
116
-
117
- for (const args of addCallbackCustomArgs) {
118
- const parameters = args as unknown[];
119
- const modCallbackCustom = parameters.shift() as
120
- | ModCallbackCustom
121
- | undefined;
122
- if (modCallbackCustom === undefined) {
124
+ const modCallback = parameters.shift();
125
+ if (modCallback === undefined) {
123
126
  error(
124
- `Failed to get the ModCallbackCustom from the parameters for class: ${tstlClassName}`,
127
+ `Failed to get the callback number from the parameters for class: ${tstlClassName}`,
125
128
  );
126
129
  }
127
130
 
@@ -130,26 +133,66 @@ function checkAddDecoratedCallbacksCustom(
130
133
  | undefined;
131
134
  if (callback === undefined) {
132
135
  error(
133
- `Failed to get the callback from the parameters for class: ${tstlClassName}`,
136
+ `Failed to get the callback function from the parameters for class: ${tstlClassName}`,
134
137
  );
135
138
  }
136
139
 
137
- /**
138
- * We need to wrap the callback in a new function so that we can explicitly pass the class as
139
- * the first argument. (Otherwise, the method will not be able to properly access `this`.
140
- */
141
- const newCallback = (...callbackArgs: unknown[]) => {
142
- callback(modFeature, ...callbackArgs);
143
- };
144
-
145
- // @ts-expect-error The compiler does not know that the arguments match the method.
146
- mod.AddCallbackCustom(modCallbackCustom, newCallback, ...parameters);
140
+ // eslint-disable-next-line prefer-destructuring, @typescript-eslint/dot-notation
141
+ const mod = modFeature["mod"];
142
+
143
+ if (init) {
144
+ // We need to wrap the callback in a new function so that we can explicitly pass the class as
145
+ // the first argument. (Otherwise, the method will not be able to properly access `this`.
146
+ const wrappedCallback = (...callbackArgs: unknown[]) => {
147
+ callback(modFeature, ...callbackArgs);
148
+ };
149
+
150
+ // We need to save the wrapped function for later (so we can unregister them).
151
+ if (vanilla) {
152
+ const modCallbackVanilla = modCallback as ModCallback;
153
+ const wrappedMethodsMap =
154
+ modFeatureConstructor[WRAPPED_CALLBACK_METHODS_KEY];
155
+ wrappedMethodsMap.set(modCallbackVanilla, wrappedCallback);
156
+ } else {
157
+ const modCallbackCustom = modCallback as ModCallbackCustom;
158
+ const wrappedMethodsMap =
159
+ modFeatureConstructor[WRAPPED_CUSTOM_CALLBACK_METHODS_KEY];
160
+ wrappedMethodsMap.set(modCallbackCustom, wrappedCallback);
161
+ }
162
+
163
+ if (vanilla) {
164
+ (mod.AddCallback as AnyFunction)(
165
+ modCallback,
166
+ wrappedCallback,
167
+ ...parameters,
168
+ );
169
+ } else {
170
+ (mod.AddCallbackCustom as AnyFunction)(
171
+ modCallback,
172
+ wrappedCallback,
173
+ ...parameters,
174
+ );
175
+ }
176
+ } else if (vanilla) {
177
+ const modCallbackVanilla = modCallback as ModCallback;
178
+ const wrappedMethodsMap =
179
+ modFeatureConstructor[WRAPPED_CALLBACK_METHODS_KEY];
180
+ const wrappedCallback = wrappedMethodsMap.get(modCallbackVanilla);
181
+ (mod.RemoveCallback as AnyFunction)(modCallback, wrappedCallback);
182
+ } else {
183
+ const modCallbackCustom = modCallback as ModCallbackCustom;
184
+ const wrappedMethodsMap =
185
+ modFeatureConstructor[WRAPPED_CUSTOM_CALLBACK_METHODS_KEY];
186
+ const wrappedCallback = wrappedMethodsMap.get(modCallbackCustom);
187
+ (mod.RemoveCallbackCustom as AnyFunction)(modCallback, wrappedCallback);
188
+ }
147
189
  }
148
190
  }
149
191
 
150
- function checkRegisterSaveDataManager(
151
- mod: ModUpgradedBase,
192
+ function initSaveDataManager(
152
193
  modFeature: ModFeature,
194
+ tstlClassName: string,
195
+ init: boolean,
153
196
  ) {
154
197
  // Do nothing if this class does not have any variables.
155
198
  const { v } = modFeature as unknown as Record<string, unknown>;
@@ -164,13 +207,27 @@ function checkRegisterSaveDataManager(
164
207
  }
165
208
 
166
209
  // Do nothing if we have not enabled the save data manager.
167
- const { saveDataManager } = mod as unknown as Record<string, unknown>;
168
- if (saveDataManager === undefined) {
210
+ // eslint-disable-next-line @typescript-eslint/dot-notation
211
+ const mod = modFeature["mod"] as unknown as Record<string, unknown>;
212
+ const saveDataManagerMethodName = init
213
+ ? "saveDataManager"
214
+ : "saveDataManagerRemove";
215
+ const saveDataManagerMethod = mod[saveDataManagerMethodName];
216
+ if (saveDataManagerMethod === undefined) {
169
217
  error(
170
218
  'Failed to initialize a mod feature class due to having a "v" object and not having the save data manager initialized. You must pass "ISCFeature.SAVE_DATA_MANAGER" to the "upgradeMod" function.',
171
219
  );
172
220
  }
173
221
 
174
- const tstlClassName = getTSTLClassName(modFeature);
175
- (saveDataManager as AnyFunction)(tstlClassName, v);
222
+ if (typeof saveDataManagerMethod !== "function") {
223
+ error(
224
+ `The "${saveDataManagerMethodName}" property of the "ModUpgraded" object was not a function.`,
225
+ );
226
+ }
227
+
228
+ if (init) {
229
+ saveDataManagerMethod(tstlClassName, v);
230
+ } else {
231
+ saveDataManagerMethod(tstlClassName);
232
+ }
176
233
  }
@@ -4,12 +4,6 @@ import { shouldFireNPC } from "../../shouldFire";
4
4
  import { CustomCallback } from "../private/CustomCallback";
5
5
 
6
6
  export class PostNPCInitFilter extends CustomCallback<ModCallbackCustom.POST_NPC_INIT_FILTER> {
7
- public override v = {
8
- room: {
9
- firedSet: new Set<PtrHash>(),
10
- },
11
- };
12
-
13
7
  constructor() {
14
8
  super();
15
9
 
@@ -4,12 +4,6 @@ import { shouldFireNPC } from "../../shouldFire";
4
4
  import { CustomCallback } from "../private/CustomCallback";
5
5
 
6
6
  export class PostNPCUpdateFilter extends CustomCallback<ModCallbackCustom.POST_NPC_UPDATE_FILTER> {
7
- public override v = {
8
- room: {
9
- firedSet: new Set<PtrHash>(),
10
- },
11
- };
12
-
13
7
  constructor() {
14
8
  super();
15
9
 
@@ -19,7 +19,13 @@ import { Feature } from "../../private/Feature";
19
19
  * It is easier to write mod code if the callbacks run in a more logical order:
20
20
  * - `POST_GAME_STARTED` --> `POST_NEW_LEVEL` --> `POST_NEW_ROOM`
21
21
  *
22
- * Manually reorganize the callback execution so that this is the case.
22
+ * `isaacscript-common` provides three new callbacks that change the order to this:
23
+ * - `POST_GAME_STARTED_REORDERED`
24
+ * - `POST_NEW_LEVEL_REORDERED`
25
+ * - `POST_NEW_ROOM_REORDERED`
26
+ *
27
+ * Additionally, there are some helper functions listed below that can deal with some edge cases
28
+ * that you may run into with these callbacks.
23
29
  */
24
30
  export class GameReorderedCallbacks extends Feature {
25
31
  private currentStage: int | null = null;
@@ -140,12 +146,13 @@ export class GameReorderedCallbacks extends Feature {
140
146
  * the next `POST_NEW_LEVEL`.
141
147
  *
142
148
  * If some specific cases, mods can change the current level during run initialization on the 0th
143
- * frame. However, due to how the callback reordering works, the custom `POST_NEW_LEVEL` callback
144
- * will never fire on the 0th frame. To get around this, call this function before changing levels
145
- * to temporarily force the callback to fire.
149
+ * frame. (For example, if you had a mod that made the player start the run in Caves instead of
150
+ * Basement.) However, due to how the callback reordering works, the `POST_NEW_LEVEL_REORDERED`
151
+ * callback will never fire on the 0th frame. To get around this, call this function before
152
+ * changing levels to temporarily force the callback to fire.
146
153
  *
147
154
  * In order to use this function, you must upgrade your mod with
148
- * `ISCFeature.CUSTOM_GRID_ENTITIES`.
155
+ * `ISCFeature.GAME_REORDERED_CALLBACKS`.
149
156
  */
150
157
  @Exported
151
158
  public forceNewLevelCallback(): void {
@@ -157,12 +164,13 @@ export class GameReorderedCallbacks extends Feature {
157
164
  * the next `POST_NEW_ROOM`.
158
165
  *
159
166
  * If some specific cases, mods can change the current room during run initialization on the 0th
160
- * frame. However, due to how the callback reordering works, the custom `POST_NEW_ROOM` callback
161
- * will never fire on the 0th frame. To get around this, call this function before changing rooms
162
- * to temporarily force the callback to fire.
167
+ * frame. (For example, if you had a mod that made the player start the Treasure Room of Basement
168
+ * 1 instead of the normal starting room.) However, due to how the callback reordering works, the
169
+ * `POST_NEW_ROOM_REORDERED` callback will never fire on the 0th frame. To get around this, call
170
+ * this function before changing rooms to temporarily force the callback to fire.
163
171
  *
164
172
  * In order to use this function, you must upgrade your mod with
165
- * `ISCFeature.CUSTOM_GRID_ENTITIES`.
173
+ * `ISCFeature.GAME_REORDERED_CALLBACKS`.
166
174
  */
167
175
  @Exported
168
176
  public forceNewRoomCallback(): void {
@@ -170,14 +178,14 @@ export class GameReorderedCallbacks extends Feature {
170
178
  }
171
179
 
172
180
  /**
173
- * Helper function to manually set the variable that the reordered callback logic uses to track
181
+ * Helper function to manually set the variables that the reordered callback logic uses to track
174
182
  * the current stage and stage type.
175
183
  *
176
- * This is useful because if the stage is changed with the `Game.SetStage` method, the reordered
177
- * callbacks will stop working.
184
+ * This is useful because if the stage is changed with the `Game.SetStage` method (or the
185
+ * `setStage` helper function), the reordered callbacks will stop working.
178
186
  *
179
187
  * In order to use this function, you must upgrade your mod with
180
- * `ISCFeature.CUSTOM_GRID_ENTITIES`.
188
+ * `ISCFeature.GAME_REORDERED_CALLBACKS`.
181
189
  */
182
190
  @Exported
183
191
  public reorderedCallbacksSetStage(
@@ -1,7 +1,3 @@
1
- // One of the functions below causes a false positive for ESLint:
2
- // https://github.com/gajus/eslint-plugin-jsdoc/issues/915
3
- /* eslint-disable jsdoc/check-param-names */
4
-
5
1
  import {
6
2
  EffectVariant,
7
3
  EntityType,
@@ -296,7 +296,7 @@ export class DebugDisplay extends Feature {
296
296
  this.mod.initFeature(feature);
297
297
  }
298
298
 
299
- printEnabled(this.player.initialized, `${featureName} display`);
299
+ printEnabled(feature.initialized, `${featureName} display`);
300
300
  }
301
301
 
302
302
  /**
@@ -552,8 +552,8 @@ export enum ModCallbackCustom {
552
552
  /**
553
553
  * Fires when a new grid entity is initialized. Specifically, this is either:
554
554
  *
555
- * - in the `POST_NEW_ROOM` callback (firing every time a room is entered, even if the entity was
556
- * previously there on a previous room entry)
555
+ * - in the `POST_NEW_ROOM_REORDERED` callback (firing every time a room is entered, even if the
556
+ * entity was previously there on a previous room entry)
557
557
  * - in the `POST_UPDATE` callback (if the entity appeared mid-way through the room, like when the
558
558
  * trapdoor appears after defeating It Lives!)
559
559
  *
@@ -658,8 +658,8 @@ export enum ModCallbackCustom {
658
658
  POST_GRID_ENTITY_UPDATE,
659
659
 
660
660
  /**
661
- * Fires from the `POST_PEFFECT_UPDATE` callback when the player loses a Holy Mantle temporary
662
- * collectible effect.
661
+ * Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when the player loses a Holy Mantle
662
+ * temporary collectible effect.
663
663
  *
664
664
  * This callback is useful because you might want to have code that happens when the player is hit
665
665
  * from an enemy. Normally, you would accomplish this via the `ENTITY_TAKE_DMG` callback, but that
@@ -682,8 +682,8 @@ export enum ModCallbackCustom {
682
682
  POST_HOLY_MANTLE_REMOVED,
683
683
 
684
684
  /**
685
- * Fires from `POST_PEFFECT_UPDATE` callback when the player loses charge on their active
686
- * collectible item, implying that the item was just used.
685
+ * Fires from `POST_PEFFECT_UPDATE_REORDERED` callback when the player loses charge on their
686
+ * active collectible item, implying that the item was just used.
687
687
  *
688
688
  * This callback is useful because the `USE_ITEM` callback does not fire when The Candle, Red
689
689
  * Candle, and Bob's Rotten Brain are discharged.
@@ -706,9 +706,9 @@ export enum ModCallbackCustom {
706
706
  POST_ITEM_DISCHARGE,
707
707
 
708
708
  /**
709
- * Fires from the `POST_PEFFECT_UPDATE` callback when an item is no longer queued (i.e. when the
710
- * animation of the player holding the item above their head is finished and the item is actually
711
- * added to the player's inventory).
709
+ * Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when an item is no longer queued (i.e.
710
+ * when the animation of the player holding the item above their head is finished and the item is
711
+ * actually added to the player's inventory).
712
712
  *
713
713
  * Note that this callback will only fire once per Forgotten/Soul pair.
714
714
  *
@@ -1008,8 +1008,9 @@ export enum ModCallbackCustom {
1008
1008
  POST_PIT_UPDATE,
1009
1009
 
1010
1010
  /**
1011
- * Fires from the `POST_PEFFECT_UPDATE` callback when a player's health (i.e. hearts) is different
1012
- * than what it was on the previous frame. For more information, see the `PlayerHealth` enum.
1011
+ * Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when a player's health (i.e. hearts) is
1012
+ * different than what it was on the previous frame. For more information, see the `PlayerHealth`
1013
+ * enum.
1013
1014
  *
1014
1015
  * When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
1015
1016
  * - You can provide an optional third argument that will make the callback only fire if it
@@ -1030,8 +1031,8 @@ export enum ModCallbackCustom {
1030
1031
  POST_PLAYER_CHANGE_HEALTH,
1031
1032
 
1032
1033
  /**
1033
- * Fires from the `POST_PEFFECT_UPDATE` callback when one of the player's stats change from what
1034
- * they were on the previous frame.
1034
+ * Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when one of the player's stats change
1035
+ * from what they were on the previous frame.
1035
1036
  *
1036
1037
  * The type of `oldValue` and `newValue` will depend on what kind of stat it is. For example,
1037
1038
  * `StatType.FLYING` will be a boolean. (You can use the "Types" helper functions to narrow the
@@ -1061,7 +1062,8 @@ export enum ModCallbackCustom {
1061
1062
  POST_PLAYER_CHANGE_STAT,
1062
1063
 
1063
1064
  /**
1064
- * Fires from the `POST_PEFFECT_UPDATE` callback when a player entity changes its player type
1065
+ * Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when a player entity changes its player
1066
+ * type
1065
1067
  * (i.e. character) from what it was on the previous frame. For example, it will fire after using
1066
1068
  * Clicker, after dying with the Judas' Shadow collectible, etc.
1067
1069
  *
@@ -1084,9 +1086,9 @@ export enum ModCallbackCustom {
1084
1086
  POST_PLAYER_CHANGE_TYPE,
1085
1087
 
1086
1088
  /**
1087
- * Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is higher than
1088
- * what it was on the previous frame, or when the active items change, or when the build is
1089
- * rerolled.
1089
+ * Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when a player's collectible count is
1090
+ * higher than what it was on the previous frame, or when the active items change, or when the
1091
+ * build is rerolled.
1090
1092
  *
1091
1093
  * When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
1092
1094
  * - You can provide an optional third argument that will make the callback only fire if the
@@ -1102,9 +1104,9 @@ export enum ModCallbackCustom {
1102
1104
  POST_PLAYER_COLLECTIBLE_ADDED,
1103
1105
 
1104
1106
  /**
1105
- * Fires from the `POST_PEFFECT_UPDATE` callback when a player's collectible count is lower than
1106
- * what it was on the previous frame, or when the active items change, or when the build is
1107
- * rerolled.
1107
+ * Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when a player's collectible count is
1108
+ * lower than what it was on the previous frame, or when the active items change, or when the
1109
+ * build is rerolled.
1108
1110
  *
1109
1111
  * When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
1110
1112
  * - You can provide an optional third argument that will make the callback only fire if the
@@ -1304,8 +1306,9 @@ export enum ModCallbackCustom {
1304
1306
  POST_PROJECTILE_INIT_LATE,
1305
1307
 
1306
1308
  /**
1307
- * Fires from the `POST_PEFFECT_UPDATE` callback when a player first picks up a new item. The
1308
- * pickup returned in the callback is assumed to be the first pickup that no longer exists.
1309
+ * Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when a player first picks up a new
1310
+ * item. The pickup returned in the callback is assumed to be the first pickup that no longer
1311
+ * exists.
1309
1312
  *
1310
1313
  * When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
1311
1314
  * - You can provide an optional third argument that will make the callback only fire if it
@@ -1442,8 +1445,8 @@ export enum ModCallbackCustom {
1442
1445
  /**
1443
1446
  * Fires when a new slot entity is initialized. Specifically, this is either:
1444
1447
  *
1445
- * - in the `POST_NEW_ROOM` callback (firing every time a room is entered, even if the entity was
1446
- * previously there on a previous room entry)
1448
+ * - in the `POST_NEW_ROOM_REORDERED` callback (firing every time a room is entered, even if the
1449
+ * entity was previously there on a previous room entry)
1447
1450
  * - in the `POST_UPDATE` callback (if the entity appeared mid-way through the room, like when a
1448
1451
  * Wheel of Fortune card is used)
1449
1452
  *
@@ -1579,7 +1582,7 @@ export enum ModCallbackCustom {
1579
1582
  POST_TNT_UPDATE,
1580
1583
 
1581
1584
  /**
1582
- * Fires from the `POST_PEFFECT_UPDATE` callback when a player gains or loses a new
1585
+ * Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when a player gains or loses a new
1583
1586
  * transformation.
1584
1587
  *
1585
1588
  * Note that this callback will only fire once per Forgotten/Soul pair.
@@ -1615,9 +1618,9 @@ export enum ModCallbackCustom {
1615
1618
  POST_TRINKET_BREAK,
1616
1619
 
1617
1620
  /**
1618
- * Fires from the `POST_PEFFECT_UPDATE` callback on the frame before a Berserk effect ends when
1619
- * the player is predicted to die (e.g. they currently have no health left or they took damage in
1620
- * a "Lost" form).
1621
+ * Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback on the frame before a Berserk effect
1622
+ * ends when the player is predicted to die (e.g. they currently have no health left or they took
1623
+ * damage in a "Lost" form).
1621
1624
  *
1622
1625
  * When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
1623
1626
  * - You can provide an optional third argument that will make the callback only fire if it
@@ -1673,8 +1676,8 @@ export enum ModCallbackCustom {
1673
1676
  PRE_GET_PEDESTAL,
1674
1677
 
1675
1678
  /**
1676
- * Fires from the `POST_PEFFECT_UPDATE` callback when an item becomes queued (i.e. when the player
1677
- * begins to hold the item above their head).
1679
+ * Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when an item becomes queued (i.e. when
1680
+ * the player begins to hold the item above their head).
1678
1681
  *
1679
1682
  * Note that this callback will only fire once per Forgotten/Soul pair.
1680
1683
  *