-
Notifications
You must be signed in to change notification settings - Fork 12
/
patches.js
38 lines (37 loc) · 1.09 KB
/
patches.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class PatchesRegistry {
static patchFns = []
static patchedEventNames = []
static getEventInjectorCode() {
return "globalThis.modapi_specialevents = [" + PatchesRegistry.patchedEventNames.flatMap(x=>`\`${x}\``).join(",") + "];";
}
static patchFile(x) {
var current = x;
PatchesRegistry.patchFns.forEach(fn => {
current = fn(current);
});
return current;
}
static addPatch(fn) {
PatchesRegistry.patchFns.push(fn);
}
static regSpecialEvent(x) {
PatchesRegistry.patchedEventNames.push(x);
}
}
// PatchesRegistry.regSpecialEvent("test");
// PatchesRegistry.addPatch(function (input) {
// var output = input;
// return output;
// })
PatchesRegistry.regSpecialEvent("render");
PatchesRegistry.addPatch(function (input) {
var output = input.replaceAll(
/continue main;\s+?}\s+?if\s?\(!\$this.\$renderHand\)/gm
,
`continue main;
}
ModAPI.events.callEvent("render",{partialTicks:$partialTicks})
if (!$this.$renderHand)`
);
return output;
});