Skip to content

Commit 824ff37

Browse files
Fix GameMode#getById behaviour in 1.8->1.9 (ViaVersion#3947)
Vanilla fallbacks to SURVIVAL and doesn't throw any errors, also NOT_SET was missing previously.
1 parent 8bec05e commit 824ff37

File tree

1 file changed

+3
-2
lines changed
  • api/src/main/java/com/viaversion/viaversion/api/minecraft

1 file changed

+3
-2
lines changed

api/src/main/java/com/viaversion/viaversion/api/minecraft/GameMode.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
public enum GameMode {
2626

27+
NOT_SET(""),
2728
SURVIVAL("Survival Mode"),
2829
CREATIVE("Creative Mode"),
2930
ADVENTURE("Adventure Mode"),
@@ -41,11 +42,11 @@ public String text() {
4142

4243
public static GameMode getById(int id) {
4344
return switch (id) {
44-
case 0 -> SURVIVAL;
45+
case -1 -> NOT_SET;
4546
case 1 -> CREATIVE;
4647
case 2 -> ADVENTURE;
4748
case 3 -> SPECTATOR;
48-
default -> throw new IllegalArgumentException("Unknown gamemode id: " + id);
49+
default /*0*/ -> SURVIVAL;
4950
};
5051
}
5152
}

0 commit comments

Comments
 (0)