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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
package gtneioreplugin.util;
import static galacticgreg.api.enums.DimensionDef.DimNames.ANUBIS;
import static galacticgreg.api.enums.DimensionDef.DimNames.ASTEROIDS;
import static galacticgreg.api.enums.DimensionDef.DimNames.BARNARDC;
import static galacticgreg.api.enums.DimensionDef.DimNames.BARNARDE;
import static galacticgreg.api.enums.DimensionDef.DimNames.BARNARDF;
import static galacticgreg.api.enums.DimensionDef.DimNames.CALLISTO;
import static galacticgreg.api.enums.DimensionDef.DimNames.CENTAURIA;
import static galacticgreg.api.enums.DimensionDef.DimNames.CERES;
import static galacticgreg.api.enums.DimensionDef.DimNames.DEEPDARK;
import static galacticgreg.api.enums.DimensionDef.DimNames.DEIMOS;
import static galacticgreg.api.enums.DimensionDef.DimNames.ENCELADUS;
import static galacticgreg.api.enums.DimensionDef.DimNames.ENDASTEROIDS;
import static galacticgreg.api.enums.DimensionDef.DimNames.EUROPA;
import static galacticgreg.api.enums.DimensionDef.DimNames.GANYMEDE;
import static galacticgreg.api.enums.DimensionDef.DimNames.HAUMEA;
import static galacticgreg.api.enums.DimensionDef.DimNames.HORUS;
import static galacticgreg.api.enums.DimensionDef.DimNames.IO;
import static galacticgreg.api.enums.DimensionDef.DimNames.KUIPERBELT;
import static galacticgreg.api.enums.DimensionDef.DimNames.MAAHES;
import static galacticgreg.api.enums.DimensionDef.DimNames.MAKEMAKE;
import static galacticgreg.api.enums.DimensionDef.DimNames.MARS;
import static galacticgreg.api.enums.DimensionDef.DimNames.MEHENBELT;
import static galacticgreg.api.enums.DimensionDef.DimNames.MERCURY;
import static galacticgreg.api.enums.DimensionDef.DimNames.MIRANDA;
import static galacticgreg.api.enums.DimensionDef.DimNames.MOON;
import static galacticgreg.api.enums.DimensionDef.DimNames.NEPER;
import static galacticgreg.api.enums.DimensionDef.DimNames.OBERON;
import static galacticgreg.api.enums.DimensionDef.DimNames.PHOBOS;
import static galacticgreg.api.enums.DimensionDef.DimNames.PLUTO;
import static galacticgreg.api.enums.DimensionDef.DimNames.PROTEUS;
import static galacticgreg.api.enums.DimensionDef.DimNames.ROSS128B;
import static galacticgreg.api.enums.DimensionDef.DimNames.ROSS128BA;
import static galacticgreg.api.enums.DimensionDef.DimNames.SETH;
import static galacticgreg.api.enums.DimensionDef.DimNames.TCETIE;
import static galacticgreg.api.enums.DimensionDef.DimNames.TITAN;
import static galacticgreg.api.enums.DimensionDef.DimNames.TRITON;
import static galacticgreg.api.enums.DimensionDef.DimNames.VEGAB;
import static galacticgreg.api.enums.DimensionDef.DimNames.VENUS;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.util.StatCollector;
import gregtech.common.OreMixBuilder;
import gtneioreplugin.Config;
public class DimensionHelper {
public static final String[] DimName = {
// Non GC dimensions in progression order instead of alphabetical
"Overworld", "Nether", "Twilight", "TheEnd", "EndAsteroid",
// T1
"GalacticraftCore_Moon",
// T2
"GalaxySpace_Deimos", "GalacticraftMars_Mars", "GalaxySpace_Phobos",
// T3
"GalacticraftMars_Asteroids", "GalaxySpace_Callisto", "GalaxySpace_Ceres", "GalaxySpace_Europa",
"GalaxySpace_Ganymede", "Ross128b",
// T4
"GalaxySpace_Io", "GalaxySpace_Mercury", "GalaxySpace_Venus",
// T5
"GalaxySpace_Enceladus", "GalaxySpace_Miranda", "GalaxySpace_Oberon", "GalaxySpace_Titan", "Ross128ba",
// T6
"GalaxySpace_Proteus", "GalaxySpace_Triton",
// T7
"GalaxySpace_Haumea", "GalaxySpace_Kuiperbelt", "GalaxySpace_MakeMake", "GalaxySpace_Pluto",
// T8
"GalaxySpace_BarnardC", "GalaxySpace_BarnardE", "GalaxySpace_BarnardF", "GalaxySpace_CentauriA",
"GalaxySpace_TcetiE", "GalaxySpace_VegaB",
// T9
"GalacticraftAmunRa_Anubis", "GalacticraftAmunRa_Horus", "GalacticraftAmunRa_Maahes",
"GalacticraftAmunRa_MehenBelt", "GalacticraftAmunRa_Neper", "GalacticraftAmunRa_Seth",
// T10
"Underdark", };
public static final String[] DimNameTrimmed = Arrays.stream(DimName)
.map(
n -> n.replaceAll("GalacticraftCore_", "")
.replaceAll("GalacticraftMars_", "")
.replaceAll("GalaxySpace_", "")
.replaceAll("GalacticraftAmunRa_", ""))
.toArray(String[]::new);
public static final String[] DimNameDisplayed = { // first 2 letters if one word else 1 letter of every word, except
// capital letter in
// name, then 1rst + capital Moon = Mo, BarnardC = BC, EndAsteroid = EA
// Non GC dimensions in progression order instead of alphabetical
"Ow", // Overworld
"Ne", // Nether
"TF", // Twilight
"ED", // TheEnd because En = Encalus
"EA", // EndAsteroid
// T1
"Mo", // GalacticraftCore_Moon
// T2
"De", // GalaxySpace_Deimos
"Ma", // GalacticraftMars_Mars
"Ph", // GalaxySpace_Phobos
// T3
"As", // GalacticraftMars_Asteroids
"Ca", // GalaxySpace_Callisto
"Ce", // GalaxySpace_Ceres
"Eu", // GalaxySpace_Europa
"Ga", // GalaxySpace_Ganymede
"Rb", // Ross128b
// T4
"Io", // GalaxySpace_Io
"Me", // GalaxySpace_Mercury
"Ve", // GalaxySpace_Venus
// T5
"En", // GalaxySpace_Enceladus
"Mi", // GalaxySpace_Miranda
"Ob", // GalaxySpace_Oberon
"Ti", // GalaxySpace_Titan
"Ra", // Ross128ba
// T6
"Pr", // GalaxySpace_Proteus
"Tr", // GalaxySpace_Triton
// T7
"Ha", // GalaxySpace_Haumea
"KB", // GalaxySpace_Kuiperbelt
"MM", // GalaxySpace_MakeMake
"Pl", // GalaxySpace_Pluto
// T8
"BC", // GalaxySpace_BarnardC
"BE", // GalaxySpace_BarnardE
"BF", // GalaxySpace_BarnardF
"CB", // GalaxySpace_CentauriA is actually α Centauri Bb
"TE", // GalaxySpace_TcetiE
"VB", // GalaxySpace_VegaB
// T9
"An", // GalacticraftAmunRa_Anubis
"Ho", // GalacticraftAmunRa_Horus
"Mh", // GalacticraftAmunRa_Maahes
"MB", // GalacticraftAmunRa_MehenBelt
"Np", // GalacticraftAmunRa_Neper
"Se", // GalacticraftAmunRa_Seth
// T10
"DD", // Underdark
};
private static final HashMap<String, List<String>> tooltipBuffer = new HashMap<>();
private static List<String> computeString(String line) {
String[] dims = parseDimNames(line);
for (int j = 0; j < dims.length; j++) {
String s = dims[j];
for (int i = 0; i < DimNameDisplayed.length; i++) {
if (s.equals(DimNameDisplayed[i])) {
String k = DimNameTrimmed[i];
s = StatCollector.translateToLocal("gtnop.world." + k);
s = switch (k) {
case "Moon" -> "T1: " + s;
case "Deimos", "Mars", "Phobos" -> "T2: " + s;
case "Asteroids", "Callisto", "Ceres", "Europa", "Ganymede", "Ross128b" -> "T3: " + s;
case "Io", "Mercury", "Venus" -> "T4: " + s;
case "Enceladus", "Miranda", "Oberon", "Titan", "Ross128ba" -> "T5: " + s;
case "Proteus", "Triton" -> "T6: " + s;
case "Haumea", "Kuiperbelt", "MakeMake", "Pluto" -> "T7: " + s;
case "BarnardC", "BarnardE", "BarnardF", "CentauriA", "TcetiE", "VegaB" -> "T8: " + s;
case "Anubis", "Horus", "Maahes", "MehenBelt", "Neper", "Seth" -> "T9: " + s;
case "Underdark" -> "T10: " + s;
default -> s;
};
dims[j] = s;
}
}
}
if (dims.length > Config.maxTooltipLines) {
dims = StringPaddingHack.stringsToSpacedColumns(
dims,
dims.length / Config.maxTooltipLines + (dims.length % Config.maxTooltipLines == 0 ? 0 : 1),
2);
}
return Arrays.asList(dims);
}
public static String[] parseDimNames(String line) {
String[] dims = line.split(",");
for (int j = 0; j < dims.length; j++) {
String s = dims[j];
s = s.replaceAll(",", "");
s = s.trim();
dims[j] = s;
}
return dims;
}
public static Map<String, Boolean> getDims(GT5OreLayerHelper.OreLayerWrapper oreLayer) {
Map<String, Boolean> enabledDims = new HashMap<>();
Map<String, Boolean> origNames = oreLayer.allowedDimWithOrigNames;
for (String dimName : origNames.keySet()) {
String abbr = getDimAbbreviatedName(dimName);
if (!origNames.getOrDefault(dimName, false)) {
continue;
}
enabledDims.put(abbr, true);
}
return enabledDims;
}
public static Map<String, Boolean> getDims(GT5OreSmallHelper.OreSmallWrapper ore) {
Map<String, Boolean> enabledDims = new HashMap<>();
Map<String, Boolean> origNames = ore.allowedDimWithOrigNames;
for (String dimName : origNames.keySet()) {
String abbr = getDimAbbreviatedName(dimName);
if (!origNames.getOrDefault(dimName, false)) {
continue;
}
enabledDims.put(abbr, true);
}
return enabledDims;
}
public static String getDimAbbreviatedName(String dimName) {
String abbreviatedName;
switch (dimName) {
case (OreMixBuilder.OW) -> abbreviatedName = "Ow"; // Overworld
case OreMixBuilder.NETHER -> abbreviatedName = "Ne"; // Nether
case OreMixBuilder.TWILIGHT_FOREST -> abbreviatedName = "TF"; // Twilight
case OreMixBuilder.THE_END -> abbreviatedName = "ED"; // TheEnd because En = Encalus
case ENDASTEROIDS -> abbreviatedName = "EA"; // EndAsteroid
// T1
case MOON -> abbreviatedName = "Mo"; // GalacticraftCore_Moon
// T2
case DEIMOS -> abbreviatedName = "De"; // GalaxySpace_Deimos
case MARS -> abbreviatedName = "Ma"; // GalacticraftMars_Mars
case PHOBOS -> abbreviatedName = "Ph"; // GalaxySpace_Phobos
// T3
case ASTEROIDS -> abbreviatedName = "As"; // GalacticraftMars_Asteroids
case CALLISTO -> abbreviatedName = "Ca"; // GalaxySpace_Callisto
case CERES -> abbreviatedName = "Ce"; // GalaxySpace_Ceres
case EUROPA -> abbreviatedName = "Eu"; // GalaxySpace_Europa
case GANYMEDE -> abbreviatedName = "Ga"; // GalaxySpace_Ganymede
case ROSS128B -> abbreviatedName = "Rb"; // Ross128b
// T4
case IO -> abbreviatedName = "Io"; // GalaxySpace_Io
case MERCURY -> abbreviatedName = "Me"; // GalaxySpace_Mercury
case VENUS -> abbreviatedName = "Ve"; // GalaxySpace_Venus
// T5
case ENCELADUS -> abbreviatedName = "En"; // GalaxySpace_Enceladus
case MIRANDA -> abbreviatedName = "Mi"; // GalaxySpace_Miranda
case OBERON -> abbreviatedName = "Ob"; // GalaxySpace_Oberon
case TITAN -> abbreviatedName = "Ti"; // GalaxySpace_Titan
case ROSS128BA -> abbreviatedName = "Ra"; // Ross128ba
// T6
case PROTEUS -> abbreviatedName = "Pr"; // GalaxySpace_Proteus
case TRITON -> abbreviatedName = "Tr"; // GalaxySpace_Triton
// T7
case HAUMEA -> abbreviatedName = "Ha"; // GalaxySpace_Haumea
case KUIPERBELT -> abbreviatedName = "KB"; // GalaxySpace_Kuiperbelt
case MAKEMAKE -> abbreviatedName = "MM"; // GalaxySpace_MakeMake
case PLUTO -> abbreviatedName = "Pl"; // GalaxySpace_Pluto
// T8
case BARNARDC -> abbreviatedName = "BC"; // GalaxySpace_BarnardC
case BARNARDE -> abbreviatedName = "BE"; // GalaxySpace_BarnardE
case BARNARDF -> abbreviatedName = "BF"; // GalaxySpace_BarnardF
case CENTAURIA -> abbreviatedName = "CB"; // GalaxySpace_CentauriA is actually α Centauri Bb
case TCETIE -> abbreviatedName = "TE"; // GalaxySpace_TcetiE
case VEGAB -> abbreviatedName = "VB"; // GalaxySpace_VegaB
// T9
case ANUBIS -> abbreviatedName = "An"; // GalacticraftAmunRa_Anubis
case HORUS -> abbreviatedName = "Ho"; // GalacticraftAmunRa_Horus
case MAAHES -> abbreviatedName = "Mh"; // GalacticraftAmunRa_Maahes
case MEHENBELT -> abbreviatedName = "MB"; // GalacticraftAmunRa_MehenBelt
case NEPER -> abbreviatedName = "Np"; // GalacticraftAmunRa_Neper
case SETH -> abbreviatedName = "Se"; // GalacticraftAmunRa_Seth
// T10
case DEEPDARK -> abbreviatedName = "DD"; // Underdark
default -> {
throw new IllegalStateException("String: " + dimName + " has no abbredged name!");
}
}
return abbreviatedName;
}
public static String getFullName(String dimName) {
return switch (dimName) {
case "Ow" -> (OreMixBuilder.OW); // Overworld
case "Ne" -> OreMixBuilder.NETHER; // Nether
case "TF" -> OreMixBuilder.TWILIGHT_FOREST; // Twilight
case "ED" -> OreMixBuilder.THE_END; // TheEnd because En = Encalus
case "EA" -> ENDASTEROIDS; // EndAsteroid
// T1
case "Mo" -> MOON; // GalacticraftCore_Moon
// T2
case "De" -> DEIMOS; // GalaxySpace_Deimos
case "Ma" -> MARS; // GalacticraftMars_Mars
case "Ph" -> PHOBOS; // GalaxySpace_Phobos
// T3
case "As" -> ASTEROIDS; // GalacticraftMars_Asteroids
case "Ca" -> CALLISTO; // GalaxySpace_Callisto
case "Ce" -> CERES; // GalaxySpace_Ceres
case "Eu" -> EUROPA; // GalaxySpace_Europa
case "Ga" -> GANYMEDE; // GalaxySpace_Ganymede
case "Rb" -> ROSS128B; // Ross128b
// T4
case "Io" -> IO; // GalaxySpace_Io
case "Me" -> MERCURY; // GalaxySpace_Mercury
case "Ve" -> VENUS; // GalaxySpace_Venus
// T5
case "En" -> ENCELADUS; // GalaxySpace_Enceladus
case "Mi" -> MIRANDA; // GalaxySpace_Miranda
case "Ob" -> OBERON; // GalaxySpace_Oberon
case "Ti" -> TITAN; // GalaxySpace_Titan
case "Ra" -> ROSS128BA; // Ross128ba
// T6
case "Pr" -> PROTEUS; // GalaxySpace_Proteus
case "Tr" -> TRITON; // GalaxySpace_Triton
// T7
case "Ha" -> HAUMEA; // GalaxySpace_Haumea
case "KB" -> KUIPERBELT; // GalaxySpace_Kuiperbelt
case "MM" -> MAKEMAKE; // GalaxySpace_MakeMake
case "Pl" -> PLUTO; // GalaxySpace_Pluto
// T8
case "BC" -> BARNARDC; // GalaxySpace_BarnardC
case "BE" -> BARNARDE; // GalaxySpace_BarnardE
case "BF" -> BARNARDF; // GalaxySpace_BarnardF
case "CB" -> CENTAURIA; // GalaxySpace_CentauriA is actually α Centauri Bb
case "TE" -> TCETIE; // GalaxySpace_TcetiE
case "VB" -> VEGAB; // GalaxySpace_VegaB
// T9
case "An" -> ANUBIS; // GalacticraftAmunRa_Anubis
case "Ho" -> HORUS; // GalacticraftAmunRa_Horus
case "Mh" -> MAAHES; // GalacticraftAmunRa_Maahes
case "MB" -> MEHENBELT; // GalacticraftAmunRa_MehenBelt
case "Np" -> NEPER; // GalacticraftAmunRa_Neper
case "Se" -> SETH; // GalacticraftAmunRa_Seth
// T10
case "DD" -> DEEPDARK; // Underdark
default -> {
throw new IllegalStateException("String: " + dimName + " has no abbredged name!");
}
};
}
public static List<String> convertCondensedStringToToolTip(String line) {
return tooltipBuffer.computeIfAbsent(line, (String tmp) -> computeString(line));
}
}
|