Skip to content

Commit 95a2985

Browse files
committed
Support new 26.1 snapshot versions
1 parent 5e184e8 commit 95a2985

2 files changed

Lines changed: 271 additions & 9 deletions

File tree

src/main/java/net/minecraftforge/srgutils/MinecraftVersion.java

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,17 @@ private static String fromSnapshot(int year, int week) {
5454
if (value >= 2303 && value <= 2307) return "1.19.4";
5555
if (value >= 2312 && value <= 2318) return "1.20";
5656
if (value >= 2320 && value <= 2330) return "1.20.1";
57-
if (value >= 2331 && value <= 2341) return "1.20.2";
58-
if (value >= 2342 && value <= 2346) return "1.20.3";
57+
if (value >= 2331 && value <= 2335) return "1.20.2";
58+
if (value >= 2340 && value <= 2346) return "1.20.3";
5959
if (value >= 2347 && value <= 2350) return "1.20.4";
6060
if (value >= 2351 && value <= 2414) return "1.20.5";
6161
if (value >= 2418 && value <= 2421) return "1.21";
6262
if (value >= 2433 && value <= 2440) return "1.21.2";
6363
if (value >= 2444 && value <= 2446) return "1.21.4";
6464
if (value >= 2502 && value <= 2510) return "1.21.5";
65-
if (value >= 2514 && value <= 9999) return "1.21.6";
65+
if (value >= 2515 && value <= 2521) return "1.21.6";
66+
if (value >= 2531 && value <= 2537) return "1.21.9";
67+
if (value >= 2541 && value <= 2546) return "1.21.11";
6668
throw new IllegalArgumentException("Invalid snapshot date: " + value);
6769
}
6870

@@ -98,7 +100,7 @@ private static MinecraftVersion get(String version) {
98100
String preA = Character.toString((char)('a' - 1));
99101

100102
if ("15w14a".equals(lower)) // 2015 April Fools
101-
return new MinecraftVersion(Type.APRIL_FOOLS, version, 14, 15, 0, "a", splitDots("1.10"));
103+
return new MinecraftVersion(Type.APRIL_FOOLS, version, 14, 15, 0, "a", splitDots("1.9"));
102104
else if ("1.rv-pre1".equals(lower)) // 2016 April Fools
103105
return new MinecraftVersion(Type.APRIL_FOOLS, version, 14, 16, 0, preA, splitDots("1.9.3"));
104106
else if ("3d shareware v1.34".equals(lower)) // 2019 April Fools
@@ -148,7 +150,13 @@ else if (lower.startsWith("rd-")) {
148150
} else {
149151
int pre = 0;
150152
String nearest = version;
151-
if (version.contains("-pre")) {
153+
// The new versioning system https://www.minecraft.net/en-us/article/minecraft-new-version-numbering-system
154+
// They did not specify pre-release or release candidate naming system.
155+
// The only one we've seen so far is snapshot. So i'll add that and add the others when they show up
156+
if (version.contains("-snapshot-")) {
157+
String[] pts = version.split("-snapshot-");
158+
return new MinecraftVersion(Type.SNAPSHOT, version, Integer.parseInt(pts[1]), -1, 0, null, splitDots(pts[0]));
159+
} else if (version.contains("-pre")) {
152160
String[] pts = version.split("-pre");
153161
pre = Integer.parseInt(pts[1]);
154162
nearest = pts[0];
@@ -219,18 +227,22 @@ public int compareTo(MinecraftVersion o) {
219227

220228
switch (this.type) {
221229
case ALPHA:
222-
case BETA:
230+
case BETA: {
223231
int ret = compareFull(o);
224232
if (ret != 0) return ret;
225233
if (this.revision == null && o.revision != null) return 1;
226234
if (this.revision != null && o.revision == null) return -1;
227235
return this.revision.compareTo(o.revision);
236+
}
228237

229238
case SNAPSHOT:
230-
case APRIL_FOOLS:
239+
case APRIL_FOOLS: {
240+
int nearest = compareNearest(o);
241+
if (nearest != 0) return nearest;
231242
if (this.year != o.year) return this.year - o.year;
232243
if (this.week != o.week) return this.week - o.week;
233244
return this.revision.compareTo(o.revision);
245+
}
234246

235247
case RELEASE:
236248
return compareFull(o);
@@ -240,14 +252,20 @@ public int compareTo(MinecraftVersion o) {
240252
}
241253
}
242254

243-
private int compareFull(MinecraftVersion o) {
255+
private int compareNearest(MinecraftVersion o) {
244256
for (int x = 0; x < this.nearest.length; x++) {
245257
if (x >= o.nearest.length) return 1;
246258
if (this.nearest[x] != o.nearest[x])
247259
return this.nearest[x] - o.nearest[x];
248260
}
249261
if (this.nearest.length < o.nearest.length)
250262
return -1;
263+
return 0;
264+
}
265+
266+
private int compareFull(MinecraftVersion o) {
267+
int nearest = compareNearest(o);
268+
if (nearest != 0) return nearest;
251269
if (this.type == Type.RELEASE && o.type != Type.RELEASE) return 1;
252270
if (this.type != Type.RELEASE && o.type == Type.RELEASE) return -1;
253271
//Release candidates have negative numbers to make them sort differently then pre releases.

src/test/java/net/minecraftforge/srgutils/test/VersionList.java

Lines changed: 245 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,251 @@ public class VersionList {
1818

1919
//Just copy pasted with a little resorting from Mojang's version manifest, https://launchermeta.mojang.com/mc/game/version_manifest.json
2020
//We can't read this file directly, because its in strict release date order, not target version order
21-
private final String[] versions = new String[] {
21+
private final String[] versions = new String[] {
22+
"26.1-snapshot-11",
23+
"26.1-snapshot-10",
24+
"26.1-snapshot-9",
25+
"26.1-snapshot-8",
26+
"26.1-snapshot-7",
27+
"26.1-snapshot-6",
28+
"26.1-snapshot-5",
29+
"26.1-snapshot-4",
30+
"26.1-snapshot-3",
31+
"26.1-snapshot-2",
32+
"26.1-snapshot-1",
33+
"1.21.11",
34+
"1.21.11-rc3",
35+
"1.21.11-rc2",
36+
"1.21.11-rc1",
37+
"1.21.11-pre5",
38+
"1.21.11-pre4",
39+
"1.21.11-pre3",
40+
"1.21.11-pre2",
41+
"1.21.11-pre1",
42+
"25w46a",
43+
"25w45a",
44+
"25w44a",
45+
"25w43a",
46+
"25w42a",
47+
"25w41a",
48+
"1.21.10",
49+
"1.21.10-rc1",
50+
"1.21.9",
51+
"1.21.9-rc1",
52+
"1.21.9-pre4",
53+
"1.21.9-pre3",
54+
"1.21.9-pre2",
55+
"1.21.9-pre1",
56+
"25w37a",
57+
"25w36b",
58+
"25w36a",
59+
"25w35a",
60+
"25w34b",
61+
"25w34a",
62+
"25w33a",
63+
"25w32a",
64+
"25w31a",
65+
"1.21.8",
66+
"1.21.8-rc1",
67+
"1.21.7",
68+
"1.21.7-rc2",
69+
"1.21.7-rc1",
70+
"1.21.6",
71+
"1.21.6-rc1",
72+
"1.21.6-pre4",
73+
"1.21.6-pre3",
74+
"1.21.6-pre2",
75+
"1.21.6-pre1",
76+
"25w21a",
77+
"25w20a",
78+
"25w19a",
79+
"25w18a",
80+
"25w17a",
81+
"25w16a",
82+
"25w15a",
83+
"1.21.5",
84+
"1.21.5-rc2",
85+
"1.21.5-rc1",
86+
"1.21.5-pre3",
87+
"1.21.5-pre2",
88+
"1.21.5-pre1",
89+
"25w14craftmine",
90+
"25w10a",
91+
"25w09b",
92+
"25w09a",
93+
"25w08a",
94+
"25w07a",
95+
"25w06a",
96+
"25w05a",
97+
"25w04a",
98+
"25w03a",
99+
"25w02a",
100+
"1.21.4",
101+
"1.21.4-rc3",
102+
"1.21.4-rc2",
103+
"1.21.4-rc1",
104+
"1.21.4-pre3",
105+
"1.21.4-pre2",
106+
"1.21.4-pre1",
107+
"24w46a",
108+
"24w45a",
109+
"24w44a",
110+
"1.21.3",
111+
"1.21.2",
112+
"1.21.2-rc2",
113+
"1.21.2-rc1",
114+
"1.21.2-pre5",
115+
"1.21.2-pre4",
116+
"1.21.2-pre3",
117+
"1.21.2-pre2",
118+
"1.21.2-pre1",
119+
"24w40a",
120+
"24w39a",
121+
"24w38a",
122+
"24w37a",
123+
"24w36a",
124+
"24w35a",
125+
"24w34a",
126+
"24w33a",
127+
"1.21.1",
128+
"1.21.1-rc1",
129+
"1.21",
130+
"1.21-rc1",
131+
"1.21-pre4",
132+
"1.21-pre3",
133+
"1.21-pre2",
134+
"1.21-pre1",
135+
"24w21b",
136+
"24w21a",
137+
"24w20a",
138+
"24w19b",
139+
"24w19a",
140+
"24w18a",
141+
"1.20.6",
142+
"1.20.6-rc1",
143+
"1.20.5",
144+
"1.20.5-rc3",
145+
"1.20.5-rc2",
146+
"1.20.5-rc1",
147+
"1.20.5-pre4",
148+
"1.20.5-pre3",
149+
"1.20.5-pre2",
150+
"1.20.5-pre1",
151+
"24w14potato",
152+
"24w14a",
153+
"24w13a",
154+
"24w12a",
155+
"24w11a",
156+
"24w10a",
157+
"24w09a",
158+
"24w07a",
159+
"24w06a",
160+
"24w05b",
161+
"24w05a",
162+
"24w04a",
163+
"24w03b",
164+
"24w03a",
165+
"23w51b",
166+
"23w51a",
167+
"1.20.4",
168+
"1.20.4-rc1",
169+
"1.20.3",
170+
"1.20.3-rc1",
171+
"1.20.3-pre4",
172+
"1.20.3-pre3",
173+
"1.20.3-pre2",
174+
"1.20.3-pre1",
175+
"23w46a",
176+
"23w45a",
177+
"23w44a",
178+
"23w43b",
179+
"23w43a",
180+
"23w42a",
181+
"23w41a",
182+
"23w40a",
183+
"1.20.2",
184+
"1.20.2-rc2",
185+
"1.20.2-rc1",
186+
"1.20.2-pre4",
187+
"1.20.2-pre3",
188+
"1.20.2-pre2",
189+
"1.20.2-pre1",
190+
"23w35a",
191+
"23w33a",
192+
"23w32a",
193+
"23w31a",
194+
"1.20.1",
195+
"1.20.1-rc1",
196+
"1.20",
197+
"1.20-rc1",
198+
"1.20-pre7",
199+
"1.20-pre6",
200+
"1.20-pre5",
201+
"1.20-pre4",
202+
"1.20-pre3",
203+
"1.20-pre2",
204+
"1.20-pre1",
205+
"23w18a",
206+
"23w17a",
207+
"23w16a",
208+
"23w14a",
209+
"23w13a_or_b",
210+
"23w13a",
211+
"23w12a",
212+
"1.19.4",
213+
"1.19.4-rc3",
214+
"1.19.4-rc2",
215+
"1.19.4-rc1",
216+
"1.19.4-pre4",
217+
"1.19.4-pre3",
218+
"1.19.4-pre2",
219+
"1.19.4-pre1",
220+
"23w07a",
221+
"23w06a",
222+
"23w05a",
223+
"23w04a",
224+
"23w03a",
225+
"1.19.3",
226+
"1.19.3-rc3",
227+
"1.19.3-rc2",
228+
"1.19.3-rc1",
229+
"1.19.3-pre3",
230+
"1.19.3-pre2",
231+
"1.19.3-pre1",
232+
"22w46a",
233+
"22w45a",
234+
"22w44a",
235+
"22w43a",
236+
"22w42a",
237+
"1.19.2",
238+
"1.19.2-rc2",
239+
"1.19.2-rc1",
240+
"1.19.1",
241+
"1.19.1-rc3",
242+
"1.19.1-rc2",
243+
"1.19.1-rc1",
244+
"1.19.1-pre6",
245+
"1.19.1-pre5",
246+
"1.19.1-pre4",
247+
"1.19.1-pre3",
248+
"1.19.1-pre2",
249+
"1.19.1-pre1",
250+
"22w24a",
251+
"1.19",
252+
"1.19-rc2",
253+
"1.19-rc1",
254+
"1.19-pre5",
255+
"1.19-pre4",
256+
"1.19-pre3",
257+
"1.19-pre2",
258+
"1.19-pre1",
259+
"22w19a",
260+
"22w18a",
261+
"22w17a",
262+
"22w16b",
263+
"22w16a",
264+
"22w15a",
265+
"22w14a",
22266
"22w13oneblockatatime",
23267
"22w13a",
24268
"22w12a",

0 commit comments

Comments
 (0)