mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-11 15:57:32 +00:00
Ensure NetworkConstants is loaded before mod construction (#10448)
This commit is contained in:
1 parent
dfe1f9240c
commit
fd1b206cf2
3 files changed
+11
-2
No files matched your search
@@ -1,10 +1,15 @@
|
||||
--- a/net/minecraft/server/Bootstrap.java
|
||||
+++ b/net/minecraft/server/Bootstrap.java
|
||||
@@ -53,6 +_,8 @@
|
||||
@@ -53,6 +_,13 @@
|
||||
DispenseItemBehavior.m_123402_();
|
||||
CauldronInteraction.m_175649_();
|
||||
Registry.m_206101_();
|
||||
+ net.minecraftforge.registries.GameData.vanillaSnapshot();
|
||||
+ // Forge: Hacky fix to ensure that NetworkConstants is loaded before mods are constructed.
|
||||
+ // Many older mods use network internals that shouldn't be used, yet are exposed so they get used anyways.
|
||||
+ // This can cause class-loading issues with ForgeMod loading NetworkConstants and HandshakeResolver.
|
||||
+ // To ensure that doesn't happen, we load it here and now. This is not an issue in 1.20.2 and newer.
|
||||
+ net.minecraftforge.network.NetworkHooks.init();
|
||||
+ if (false) // skip redirectOutputToLog, Forge already redirects stdout and stderr output to log so that they print with more context
|
||||
m_135890_();
|
||||
}
|
||||
|
||||
@@ -433,7 +433,6 @@ public class ForgeMod
|
||||
return uuid.toString();
|
||||
});
|
||||
|
||||
LOGGER.debug(FORGEMOD, "Loading Network data for FML net version: {}", NetworkConstants.init());
|
||||
CrashReportCallables.registerCrashCallable("FML", ForgeVersion::getSpec);
|
||||
CrashReportCallables.registerCrashCallable("Forge", ()->ForgeVersion.getGroup()+":"+ForgeVersion.getVersion());
|
||||
|
||||
|
||||
@@ -46,6 +46,11 @@ public class NetworkHooks
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static void init()
|
||||
{
|
||||
LOGGER.debug("Loading Network data for FML net version: {}", NetworkConstants.init());
|
||||
}
|
||||
|
||||
public static String getFMLVersion(final String ip)
|
||||
{
|
||||
return ip.contains("\0") ? Objects.equals(ip.split("\0")[1], NetworkConstants.NETVERSION) ? NetworkConstants.NETVERSION : ip.split("\0")[1] : NetworkConstants.NOVERSION;
|
||||
|
||||
Reference in new issue
Block a user