Update Environment
This commit is contained in:
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) {
|
||||
|
||||
Reference in new issue
Block a user