mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
Feat: MCP 1.8.9 Check
This commit is contained in:
1 parent
2829e14c0e
commit
041f747125
2 files changed
+58
-3
No files matched your search
@@ -24,7 +24,13 @@ public final class LoaderDetector {
|
||||
return LoaderType.FABRIC;
|
||||
}
|
||||
|
||||
// No mod loader found
|
||||
// MCP: Minecraft deobfuscated (development) environment
|
||||
// Has real class names (net.minecraft.client.Minecraft) but no mod loader
|
||||
if (isMCP(loader)) {
|
||||
return LoaderType.MCP;
|
||||
}
|
||||
|
||||
// No mod loader found, obfuscated vanilla
|
||||
return LoaderType.VANILLA;
|
||||
}
|
||||
|
||||
@@ -50,4 +56,14 @@ public final class LoaderDetector {
|
||||
"net.fabricmc.loader.api.FabricLoader");
|
||||
}
|
||||
|
||||
private static boolean isMCP(ClassLoader loader) {
|
||||
try {
|
||||
Class<?> mcClass = Class.forName("net.minecraft.client.Minecraft", false, loader);
|
||||
mcClass.getDeclaredMethod("getMinecraft");
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public final class VersionDetector {
|
||||
}
|
||||
|
||||
if (lastFailure != null) {
|
||||
lastFailure.printStackTrace();
|
||||
System.out.println("[VersionDetector] Forge/Fabric version detection failed, falling back to structural probe");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -142,6 +142,14 @@ public final class VersionDetector {
|
||||
"com/mojang/blaze3d/buffers/GpuBuffer",
|
||||
"com/mojang/blaze3d/systems/CommandEncoder");
|
||||
|
||||
// MCP (deobfuscated) detection - only 1.8.9
|
||||
boolean mcp = isMCPPresent(loaders,
|
||||
"net.minecraft.client.Minecraft", "getMinecraft", "theMinecraft",
|
||||
"net.minecraft.client.entity.EntityPlayerSP",
|
||||
"net.minecraft.client.gui.GuiIngame",
|
||||
"net.minecraft.client.renderer.EntityRenderer",
|
||||
"net.minecraft.client.network.NetHandlerPlayClient");
|
||||
|
||||
int matchingVersions = (vanilla189 ? 1 : 0)
|
||||
+ (vanilla1122 ? 1 : 0)
|
||||
+ (vanilla1165 ? 1 : 0)
|
||||
@@ -149,7 +157,8 @@ public final class VersionDetector {
|
||||
+ (vanilla1211 || neoForge1211 ? 1 : 0)
|
||||
+ (vanilla1206 ? 1 : 0)
|
||||
+ (vanilla12111 || fabric12111 ? 1 : 0)
|
||||
+ (vanilla262 || fabric262 ? 1 : 0);
|
||||
+ (vanilla262 || fabric262 ? 1 : 0)
|
||||
+ (mcp ? 1 : 0);
|
||||
|
||||
if (matchingVersions == 1) {
|
||||
if (vanilla189) return 15;
|
||||
@@ -163,11 +172,41 @@ public final class VersionDetector {
|
||||
int modernProtocol = getModernProtocol(loaders);
|
||||
return modernProtocol != 0 ? modernProtocol : 110;
|
||||
}
|
||||
if (mcp) return 15;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static boolean isMCPPresent(Set<ClassLoader> loaders,
|
||||
String minecraftClassName,
|
||||
String getterName,
|
||||
String instanceFieldName,
|
||||
String... anchorClasses) {
|
||||
for (ClassLoader loader : loaders) {
|
||||
Class<?> mcClass = resolveClass(minecraftClassName, loader);
|
||||
if (mcClass == null) continue;
|
||||
|
||||
ClassLoader definingLoader = mcClass.getClassLoader();
|
||||
if (definingLoader == null) continue;
|
||||
|
||||
boolean anchorsMatch = true;
|
||||
for (String anchor : anchorClasses) {
|
||||
Class<?> anchorClass = resolveClass(anchor, definingLoader);
|
||||
if (anchorClass == null) {
|
||||
anchorsMatch = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!anchorsMatch) continue;
|
||||
|
||||
if (matchesMinecraftStructure(mcClass, getterName, instanceFieldName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isRuntimePresent(Set<ClassLoader> loaders,
|
||||
String obfuscatedClass,
|
||||
String getterName,
|
||||
|
||||
Reference in new issue
Block a user