mirror of
https://github.com/MinecraftForge/MinecraftForge
synced 2026-08-22 04:26:10 -04:00
Ensure NetworkConstants is loaded before mod construction (#10407)
This commit is contained in:
parent
59979642e9
commit
fa109380f7
3 changed files with 11 additions and 2 deletions
|
|
@ -1,10 +1,15 @@
|
|||
--- a/net/minecraft/server/Bootstrap.java
|
||||
+++ b/net/minecraft/server/Bootstrap.java
|
||||
@@ -54,6 +_,8 @@
|
||||
@@ -54,6 +_,13 @@
|
||||
CauldronInteraction.m_175649_();
|
||||
BuiltInRegistries.m_257498_();
|
||||
CreativeModeTabs.m_280019_();
|
||||
+ 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_();
|
||||
f_285608_.set(Duration.between(instant, Instant.now()).toMillis());
|
||||
|
|
|
|||
|
|
@ -426,7 +426,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());
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue