|
1 | 1 | // priority: -100 |
2 | 2 |
|
3 | 3 | (() => { |
4 | | - /** |
5 | | - * @param {"multiblock"} kind |
6 | | - */ |
7 | | - function getGregtechMachines(kind) { |
8 | | - let $MultiblockMachineDefinition = Java.loadClass( |
9 | | - "com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition" |
10 | | - ); |
11 | | - |
12 | | - let isInstance = (clz, obj) => clz.__javaObject__.isInstance(obj); |
13 | | - |
14 | | - let result = []; |
15 | | - if (kind === "multiblock") { |
16 | | - for (let def of GTRegistries.MACHINES) { |
17 | | - if (isInstance($MultiblockMachineDefinition, def)) { |
18 | | - result.push(def.block.idLocation); |
19 | | - } |
20 | | - } |
21 | | - } |
22 | | - |
23 | | - return result; |
24 | | - } |
25 | | - |
26 | | - let gtMachines = getGregtechMachines("multiblock"); //Doesnt Work rn / need to fix @n1xx1 |
27 | | - let stargateBlocks = [ |
28 | | - "sgjourney:classic_stargate", |
29 | | - "sgjourney:classic_stargate_base_block", |
30 | | - "sgjourney:classic_stargate_chevron_block", |
31 | | - "sgjourney:classic_stargate_ring_block", |
32 | | - "sgjourney:crystal_interface", |
33 | | - "sgjourney:classic_dhd", |
34 | | - ]; |
| 4 | + let getInitializationData = lazyGetter(() => { |
| 5 | + return { |
| 6 | + gregtechMultiblocks: getGregtechMachines("multiblock"), |
| 7 | + stargateTravel: [ |
| 8 | + "sgjourney:classic_stargate", |
| 9 | + "sgjourney:classic_stargate_base_block", |
| 10 | + "sgjourney:classic_stargate_chevron_block", |
| 11 | + "sgjourney:classic_stargate_ring_block", |
| 12 | + "sgjourney:crystal_interface", |
| 13 | + "sgjourney:classic_dhd", |
| 14 | + ], |
| 15 | + }; |
| 16 | + }); |
35 | 17 |
|
36 | 18 | Ponder.tags((event) => { |
37 | 19 | event.createTag( |
38 | 20 | "kubejs:gtceu", |
39 | | - "gtceu:electric_blast_furnace", //use? |
| 21 | + "gtceu:electric_blast_furnace", |
40 | 22 | "GregTech Multiblocks", |
41 | 23 | "Informations on how to use GregTech Multiblocks", |
42 | | - gtMachines |
| 24 | + getInitializationData().gregtechMultiblocks, |
43 | 25 | ); |
44 | 26 |
|
45 | 27 | event.createTag( |
46 | 28 | "kubejs:stargate", |
| 29 | + "sgjourney:classic_stargate", |
47 | 30 | "Stargate Travel", |
48 | 31 | "Informations on how to use the Stargates of this modpack", |
49 | | - stargateBlocks |
| 32 | + getInitializationData().stargateTravel, |
50 | 33 | ); |
51 | 34 | }); |
52 | 35 |
|
53 | 36 | Ponder.registry((event) => { |
54 | 37 | event |
55 | | - .create(stargateBlocks) |
| 38 | + .create(getInitializationData().stargateTravel) |
56 | 39 | .scene( |
57 | 40 | "classic_stargate", |
58 | 41 | "Classic Stargate", |
59 | | - ponderScenes["classic_stargate"] |
| 42 | + ponderScenes["classic_stargate"], |
60 | 43 | ); |
61 | 44 |
|
62 | 45 | event |
63 | | - .create(gtMachines) |
| 46 | + .create(getInitializationData().gregtechMultiblocks) |
64 | 47 | .scene( |
65 | 48 | "multiblock_introduction", |
66 | 49 | "Multiblock Introduction", |
67 | | - ponderScenes["multiblock_introduction"] |
| 50 | + ponderScenes["multiblock_introduction"], |
68 | 51 | ) |
69 | 52 | .scene( |
70 | 53 | "multiblock_construction", |
71 | 54 | "Multiblock Construction", |
72 | | - ponderScenes["multiblock_construction"] |
| 55 | + ponderScenes["multiblock_construction"], |
73 | 56 | ) |
74 | 57 | .scene( |
75 | 58 | "multiblock_wallsharing", |
76 | 59 | "Multiblock Wall Sharing", |
77 | | - ponderScenes["multiblock_wallsharing"] |
| 60 | + ponderScenes["multiblock_wallsharing"], |
78 | 61 | ); |
79 | 62 | }); |
| 63 | + |
| 64 | + /** |
| 65 | + * @template T |
| 66 | + * @param {() => T} init |
| 67 | + * @returns {() => T} |
| 68 | + */ |
| 69 | + function lazyGetter(init) { |
| 70 | + let data = null; |
| 71 | + return () => { |
| 72 | + if (!data) data = init(); |
| 73 | + return data; |
| 74 | + }; |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * @param {"multiblock"} kind |
| 79 | + * @returns {string[]} |
| 80 | + */ |
| 81 | + function getGregtechMachines(kind) { |
| 82 | + let $MultiblockMachineDefinition = Java.loadClass( |
| 83 | + "com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition", |
| 84 | + ); |
| 85 | + |
| 86 | + let isInstance = (clz, obj) => clz.__javaObject__.isInstance(obj); |
| 87 | + |
| 88 | + let result = []; |
| 89 | + if (kind === "multiblock") { |
| 90 | + for (let def of GTRegistries.MACHINES) { |
| 91 | + if (isInstance($MultiblockMachineDefinition, def)) { |
| 92 | + result.push(def.block.idLocation); |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + return result; |
| 98 | + } |
80 | 99 | })(); |
0 commit comments