Update Environment

This commit is contained in:
Jason Penilla committed 2025-06-29 18:37:26 -07:00
1 parent 1fdf590645
commit ea5c415c39
1 file changed
+9 -1
@@ -25,7 +25,15 @@ public class Environment {
final Class<?> sharedConstants = Class.forName("net.minecraft.SharedConstants");
final Method getCurrentVersion = sharedConstants.getDeclaredMethod("getCurrentVersion");
final Object currentVersion = getCurrentVersion.invoke(null);
final Method getName = currentVersion.getClass().getDeclaredMethod("getName");
Method getName = null;
try {
getName = currentVersion.getClass().getDeclaredMethod("getName");
} catch (final NoSuchMethodException ignored) {
}
if (getName == null) {
// ~1.21.6+
getName = currentVersion.getClass().getDeclaredMethod("name");
}
final String versionName = (String) getName.invoke(currentVersion);
majorVer = Integer.parseInt(versionName.split("\\.")[1]);
} catch (final ReflectiveOperationException ex) {