mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
Fix classloading properly. ModLoadingClassLoader doesn't work
with the proper delegation model. Abandoned it, in favour of injecting locators into the Transformer classloader directly.
This commit is contained in:
1 parent
58c78560fa
commit
1b40618f02
27 files changed
+135
-544
No files matched your search
@@ -1,353 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2018.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraftforge.fml.ModLoadingClassLoader;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLModContainer;
|
||||
import net.minecraftforge.fml.loading.DefaultModInfos;
|
||||
|
||||
/*
|
||||
public class ForgeModContainer extends FMLModContainer
|
||||
{
|
||||
static final Logger log = LogManager.getLogger(ForgeVersion.MOD_ID);
|
||||
|
||||
private static ForgeModContainer INSTANCE;
|
||||
public static ForgeModContainer getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private URL updateJSONUrl = null;
|
||||
public UniversalBucket universalBucket;
|
||||
|
||||
public ForgeModContainer()
|
||||
{
|
||||
super(new ModMetadata());
|
||||
ModMetadata meta = getMetadata();
|
||||
meta.modId = ForgeVersion.MOD_ID;
|
||||
meta.name = "Minecraft Forge";
|
||||
meta.version = ForgeVersion.getVersion();
|
||||
meta.credits = "Made possible with help from many people";
|
||||
meta.authorList = Arrays.asList("LexManos", "cpw", "fry");
|
||||
meta.description = "Minecraft Forge is a common open source API allowing a broad range of mods " +
|
||||
"to work cooperatively together. It allows many mods to be created without " +
|
||||
"them editing the main Minecraft code.";
|
||||
meta.url = "http://minecraftforge.net";
|
||||
meta.screenshots = new String[0];
|
||||
meta.logoFile = "/forge_logo.png";
|
||||
try {
|
||||
updateJSONUrl = new URL("http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json");
|
||||
} catch (MalformedURLException e) {}
|
||||
|
||||
config = null;
|
||||
File cfgFile = new File(FMLPaths.FMLCONFIG.get().toFile(), "forge.cfg");
|
||||
config = new Configuration(cfgFile);
|
||||
|
||||
syncConfig(true);
|
||||
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiClassName()
|
||||
{
|
||||
return "net.minecraftforge.client.gui.ForgeGuiFactory";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* By subscribing to the OnConfigChangedEvent we are able to execute code when our config screens are closed.
|
||||
* This implementation uses the optional configID string to handle multiple Configurations using one event handler.
|
||||
* /
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(OnConfigChangedEvent event)
|
||||
{
|
||||
if (getMetadata().modId.equals(event.getModID()))
|
||||
{
|
||||
if ("chunkLoader".equals(event.getConfigID()))
|
||||
{
|
||||
ForgeChunkManager.syncConfigDefaults();
|
||||
ForgeChunkManager.loadConfiguration();
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean tmpStairs = disableStairSlabCulling;
|
||||
|
||||
syncConfig(false);
|
||||
|
||||
if (event.isWorldRunning() && tmpStairs != disableStairSlabCulling)
|
||||
{
|
||||
FMLCommonHandler.instance().reloadRenderers();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void missingMapping(RegistryEvent.MissingMappings<Item> event)
|
||||
{
|
||||
for (MissingMappings.Mapping<Item> entry : event.getAllMappings())
|
||||
{
|
||||
if (entry.key.toString().equals("minecraft:totem")) //This item changed from 1.11 -> 1.11.2
|
||||
{
|
||||
ResourceLocation newTotem = new ResourceLocation("minecraft:totem_of_undying");
|
||||
entry.remap(ForgeRegistries.ITEMS.getValue(newTotem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public void playerLogin(PlayerEvent.PlayerLoggedInEvent event)
|
||||
{
|
||||
UsernameCache.setUsername(event.player.getPersistentID(), event.player.getGameProfile().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerBus(EventBus bus, LoadController controller)
|
||||
{
|
||||
bus.register(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void modConstruction(FMLConstructionEvent evt)
|
||||
{
|
||||
InputStream is = ForgeModContainer.class.getResourceAsStream("/META-INF/vanilla_annotations.json");
|
||||
if (is != null)
|
||||
JsonAnnotationLoader.loadJson(is, null, evt.getASMHarvestedData());
|
||||
log.debug("Loading Vanilla annotations: " + is);
|
||||
|
||||
List<String> all = Lists.newArrayList();
|
||||
for (ASMData asm : evt.getASMHarvestedData().getAll(ICrashReportDetail.class.getName().replace('.', '/')))
|
||||
all.add(asm.getClassName());
|
||||
for (ASMData asm : evt.getASMHarvestedData().getAll(ICrashCallable.class.getName().replace('.', '/')))
|
||||
all.add(asm.getClassName());
|
||||
// Add table classes for mod list tabulation
|
||||
all.add("net/minecraftforge/common/util/TextTable");
|
||||
all.add("net/minecraftforge/common/util/TextTable$Column");
|
||||
all.add("net/minecraftforge/common/util/TextTable$Row");
|
||||
all.add("net/minecraftforge/common/util/TextTable$Alignment");
|
||||
|
||||
all.removeIf(cls -> !cls.startsWith("net/minecraft/") && !cls.startsWith("net/minecraftforge/"));
|
||||
|
||||
log.debug("Preloading CrashReport Classes");
|
||||
Collections.sort(all); //Sort it because I like pretty output ;)
|
||||
for (String name : all)
|
||||
{
|
||||
log.debug("\t{}", name);
|
||||
try
|
||||
{
|
||||
Class.forName(name.replace('/', '.'), false, MinecraftForge.class.getClassLoader());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("Could not find class for name '{}'.", name, e);
|
||||
}
|
||||
}
|
||||
|
||||
NetworkRegistry.INSTANCE.register(this, this.getClass(), "*", evt.getASMHarvestedData());
|
||||
ForgeNetworkHandler.registerChannel(this, evt.getSide());
|
||||
ConfigManager.sync(this.getModId(), Config.Type.INSTANCE);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void preInit(FMLPreInitializationEvent evt)
|
||||
{
|
||||
CapabilityItemHandler.register();
|
||||
CapabilityFluidHandler.register();
|
||||
CapabilityAnimation.register();
|
||||
CapabilityEnergy.register();
|
||||
MinecraftForge.EVENT_BUS.register(MinecraftForge.INTERNAL_HANDLER);
|
||||
if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(ForgeClientHandler.class);
|
||||
}
|
||||
ForgeChunkManager.captureConfig(evt.getModConfigurationDirectory());
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
if (!ForgeModContainer.disableVersionCheck)
|
||||
{
|
||||
ForgeVersion.startVersionCheck();
|
||||
}
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public void registrItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
// Add and register the forge universal bucket, if it's enabled
|
||||
if(FluidRegistry.isUniversalBucketEnabled())
|
||||
{
|
||||
universalBucket = new UniversalBucket();
|
||||
universalBucket.setUnlocalizedName("forge.bucketFilled");
|
||||
event.getRegistry().register(universalBucket.setRegistryName(ForgeVersion.MOD_ID, "bucketFilled"));
|
||||
MinecraftForge.EVENT_BUS.register(universalBucket);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void postInit(FMLPostInitializationEvent evt)
|
||||
{
|
||||
registerAllBiomesAndGenerateEvents();
|
||||
ForgeChunkManager.loadConfiguration();
|
||||
}
|
||||
|
||||
private static void registerAllBiomesAndGenerateEvents()
|
||||
{
|
||||
for (Biome biome : ForgeRegistries.BIOMES.getValuesCollection())
|
||||
{
|
||||
if (biome.decorator instanceof DeferredBiomeDecorator)
|
||||
{
|
||||
DeferredBiomeDecorator decorator = (DeferredBiomeDecorator)biome.decorator;
|
||||
decorator.fireCreateEventAndReplace(biome);
|
||||
}
|
||||
|
||||
BiomeDictionary.ensureHasTypes(biome);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onAvailable(FMLLoadCompleteEvent evt)
|
||||
{
|
||||
if (shouldSortRecipies)
|
||||
{
|
||||
RecipeSorter.sortCraftManager();
|
||||
}
|
||||
FluidRegistry.validateFluidRegistry();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void serverStarting(FMLServerStartingEvent evt)
|
||||
{
|
||||
evt.registerServerCommand(new ForgeCommand());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void serverStopping(FMLServerStoppingEvent evt)
|
||||
{
|
||||
WorldWorkerManager.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info)
|
||||
{
|
||||
NBTTagCompound forgeData = new NBTTagCompound();
|
||||
NBTTagCompound dimData = DimensionManager.saveDimensionDataMap();
|
||||
forgeData.setTag("DimensionData", dimData);
|
||||
FluidRegistry.writeDefaultFluidList(forgeData);
|
||||
return forgeData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(SaveHandler handler, WorldInfo info, Map<String, NBTBase> propertyMap, NBTTagCompound tag)
|
||||
{
|
||||
DimensionManager.loadDimensionDataMap(tag.hasKey("DimensionData") ? tag.getCompoundTag("DimensionData") : null);
|
||||
FluidRegistry.loadFluidDefaults(tag);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void mappingChanged(FMLModIdMappingEvent evt)
|
||||
{
|
||||
OreDictionary.rebakeMap();
|
||||
StatList.reinit();
|
||||
Ingredient.invalidateAll();
|
||||
FMLCommonHandler.instance().resetClientRecipeBook();
|
||||
FMLCommonHandler.instance().reloadSearchTrees();
|
||||
FMLCommonHandler.instance().reloadCreativeSettings();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public File getSource()
|
||||
{
|
||||
return FMLForgePlugin.forgeLocation;
|
||||
}
|
||||
@Override
|
||||
public Class<?> getCustomResourcePackClass()
|
||||
{
|
||||
if (getSource().isDirectory())
|
||||
{
|
||||
return FMLFolderResourcePack.class;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FMLFileResourcePack.class;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getOwnedPackages()
|
||||
{
|
||||
// All the packages which are part of forge. Only needs updating if new logic is added
|
||||
// that requires event handlers
|
||||
return ImmutableList.of(
|
||||
"net.minecraftforge.classloading",
|
||||
"net.minecraftforge.client",
|
||||
"net.minecraftforge.client.event",
|
||||
"net.minecraftforge.client.event.sound",
|
||||
"net.minecraftforge.client.model",
|
||||
"net.minecraftforge.client.model.obj",
|
||||
"net.minecraftforge.client.model.techne",
|
||||
"net.minecraftforge.common",
|
||||
"net.minecraftforge.common.config",
|
||||
"net.minecraftforge.common.network",
|
||||
"net.minecraftforge.common.util",
|
||||
"net.minecraftforge.event",
|
||||
"net.minecraftforge.event.brewing",
|
||||
"net.minecraftforge.event.entity",
|
||||
"net.minecraftforge.event.entity.item",
|
||||
"net.minecraftforge.event.entity.living",
|
||||
"net.minecraftforge.event.entity.minecart",
|
||||
"net.minecraftforge.event.entity.player",
|
||||
"net.minecraftforge.event.terraingen",
|
||||
"net.minecraftforge.event.world",
|
||||
"net.minecraftforge.fluids",
|
||||
"net.minecraftforge.oredict",
|
||||
"net.minecraftforge.server",
|
||||
"net.minecraftforge.server.command",
|
||||
"net.minecraftforge.transformers"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Certificate getSigningCertificate()
|
||||
{
|
||||
Certificate[] certificates = getClass().getProtectionDomain().getCodeSource().getCertificates();
|
||||
return certificates != null ? certificates[0] : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getUpdateUrl()
|
||||
{
|
||||
return updateJSONUrl;
|
||||
}
|
||||
public ForgeModContainer(ModLoadingClassLoader classLoader)
|
||||
{
|
||||
super(DefaultModInfos.forgeModInfo, "net.minecraftforge.common.ForgeMod", classLoader, null);
|
||||
ForgeConfig.load();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -66,7 +66,7 @@ public class AutomaticEventSubscriber
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
LOGGER.error(LOADING, "Failed to load mod class {} for @EventBusSubscriber annotation", ad.getClassType(), e);
|
||||
LOGGER.fatal(LOADING, "Failed to load mod class {} for @EventBusSubscriber annotation", ad.getClassType(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public final class FMLWorldPersistenceHook implements WorldPersistenceHooks.Worl
|
||||
}
|
||||
if (!Objects.equals(modVersion, MavenVersionStringHelper.artifactVersionToString(container.get().getModInfo().getVersion())))
|
||||
{
|
||||
LOGGER.info(WORLDPERSISTENCE,"This world was saved with mod {} version {} and it is now at version {}, things may not work well", modId, modVersion, MavenVersionStringHelper.artifactVersionToString(container.get().getModInfo().getVersion()));
|
||||
LOGGER.warn(WORLDPERSISTENCE,"This world was saved with mod {} version {} and it is now at version {}, things may not work well", modId, modVersion, MavenVersionStringHelper.artifactVersionToString(container.get().getModInfo().getVersion()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import net.minecraftforge.fml.loading.StringUtils;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||
import org.apache.commons.lang3.text.ExtendedMessageFormat;
|
||||
import org.apache.commons.lang3.text.FormatFactory;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.text.FieldPosition;
|
||||
import java.text.Format;
|
||||
@@ -33,6 +35,7 @@ import java.util.Objects;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public class ForgeI18n {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static Map<String,String> i18n;
|
||||
private static Map<String,FormatFactory> customFactories;
|
||||
|
||||
@@ -77,6 +80,7 @@ public class ForgeI18n {
|
||||
}
|
||||
|
||||
public static void loadLanguageData(final Map<String, String> properties) {
|
||||
LOGGER.debug("Loading I18N data entries: {}", properties.size());
|
||||
i18n = properties;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,12 +42,14 @@ public class LaunchTesting
|
||||
final MarkerFilter axformFilter= MarkerFilter.createFilter("AXFORM", Filter.Result.DENY, Filter.Result.NEUTRAL);
|
||||
final MarkerFilter eventbusFilter = MarkerFilter.createFilter("EVENTBUS", Filter.Result.DENY, Filter.Result.NEUTRAL);
|
||||
final MarkerFilter distxformFilter = MarkerFilter.createFilter("DISTXFORM", Filter.Result.DENY, Filter.Result.NEUTRAL);
|
||||
// final MarkerFilter scannerFilter = MarkerFilter.createFilter("SCAN", Filter.Result.DENY, Filter.Result.NEUTRAL);
|
||||
final LoggerContext logcontext = LoggerContext.getContext(false);
|
||||
logcontext.getConfiguration().addFilter(classloadingFilter);
|
||||
logcontext.getConfiguration().addFilter(launchpluginFilter);
|
||||
logcontext.getConfiguration().addFilter(axformFilter);
|
||||
logcontext.getConfiguration().addFilter(eventbusFilter);
|
||||
logcontext.getConfiguration().addFilter(distxformFilter);
|
||||
// logcontext.getConfiguration().addFilter(axformFilter);
|
||||
// logcontext.getConfiguration().addFilter(eventbusFilter);
|
||||
// logcontext.getConfiguration().addFilter(distxformFilter);
|
||||
// logcontext.getConfiguration().addFilter(scannerFilter);
|
||||
logcontext.updateLoggers();
|
||||
|
||||
String assets = System.getenv().getOrDefault("assetDirectory", "assets");
|
||||
|
||||
@@ -49,7 +49,6 @@ public class ModLoader
|
||||
private static ModLoader INSTANCE;
|
||||
private final TransformingClassLoader launchClassLoader;
|
||||
private final LoadingModList loadingModList;
|
||||
private final ModLoadingClassLoader modClassLoader;
|
||||
|
||||
private final List<ModLoadingException> loadingExceptions;
|
||||
private ModLoader()
|
||||
@@ -57,10 +56,8 @@ public class ModLoader
|
||||
INSTANCE = this;
|
||||
this.launchClassLoader = FMLLoader.getLaunchClassLoader();
|
||||
this.loadingModList = FMLLoader.getLoadingModList();
|
||||
this.modClassLoader = new ModLoadingClassLoader(this.launchClassLoader);
|
||||
this.loadingExceptions = FMLLoader.getLoadingModList().
|
||||
getErrors().stream().flatMap(ModLoadingException::fromEarlyException).collect(Collectors.toList());
|
||||
Thread.currentThread().setContextClassLoader(this.modClassLoader);
|
||||
}
|
||||
|
||||
public static ModLoader get()
|
||||
@@ -80,10 +77,10 @@ public class ModLoader
|
||||
}
|
||||
final Stream<ModContainer> modContainerStream = loadingModList.getModFiles().stream().
|
||||
map(ModFileInfo::getFile).
|
||||
map(mf -> buildMods(mf, modClassLoader)).
|
||||
map(mf -> buildMods(mf, launchClassLoader)).
|
||||
flatMap(Collection::stream);
|
||||
if (!loadingExceptions.isEmpty()) {
|
||||
LOGGER.error(CORE, "Failed to initialize mod containers");
|
||||
LOGGER.fatal(CORE, "Failed to initialize mod containers");
|
||||
throw new LoadingFailedException(loadingExceptions);
|
||||
}
|
||||
modList.setLoadedMods(modContainerStream.collect(Collectors.toList()));
|
||||
@@ -102,7 +99,7 @@ public class ModLoader
|
||||
event.dispatch(this::accumulateErrors);
|
||||
}
|
||||
if (!loadingExceptions.isEmpty()) {
|
||||
LOGGER.error("Failed to complete lifecycle event {}, {} errors found", event, loadingExceptions.size());
|
||||
LOGGER.fatal("Failed to complete lifecycle event {}, {} errors found", event, loadingExceptions.size());
|
||||
throw new LoadingFailedException(loadingExceptions);
|
||||
}
|
||||
}
|
||||
@@ -110,7 +107,7 @@ public class ModLoader
|
||||
loadingExceptions.addAll(errors);
|
||||
}
|
||||
|
||||
private List<ModContainer> buildMods(final ModFile modFile, final ModLoadingClassLoader modClassLoader)
|
||||
private List<ModContainer> buildMods(final ModFile modFile, final TransformingClassLoader modClassLoader)
|
||||
{
|
||||
final Map<String, IModInfo> modInfoMap = modFile.getModFileInfo().getMods().stream().collect(Collectors.toMap(IModInfo::getModId, Function.identity()));
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2018.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import cpw.mods.modlauncher.TransformingClassLoader;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.fml.loading.ModJarURLHandler;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static net.minecraftforge.fml.Logging.LOADING;
|
||||
|
||||
public class ModLoadingClassLoader extends TransformingClassLoader
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
static {
|
||||
ClassLoader.registerAsParallelCapable();
|
||||
}
|
||||
|
||||
private final Predicate<String> classLoadingPredicate;
|
||||
private final TransformingClassLoader tcl;
|
||||
|
||||
protected ModLoadingClassLoader(final TransformingClassLoader parent) {
|
||||
super(parent, path->FMLLoader.getLoadingModList().findURLForResource(path));
|
||||
this.tcl = parent;
|
||||
this.classLoadingPredicate = FMLLoader.getClassLoaderExclusions();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URL locateResource(final String path) {
|
||||
return FMLLoader.getLoadingModList().findURLForResource(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String name)
|
||||
{
|
||||
return locateResource(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
|
||||
{
|
||||
synchronized (getClassLoadingLock(name)) {
|
||||
Class<?> existingClass = tcl.getLoadedClass(name);
|
||||
if (existingClass != null) return existingClass;
|
||||
|
||||
LOGGER.debug(LOADING, "Loading class {}", name);
|
||||
if (!classLoadingPredicate.test(name)) {
|
||||
LOGGER.debug(LOADING, "Delegating to parent {}", name);
|
||||
return tcl.loadClass(name);
|
||||
}
|
||||
return tcl.loadClass(name, this::locateResource);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URL findResource(String name)
|
||||
{
|
||||
return locateResource(name);
|
||||
}
|
||||
}
|
||||
@@ -51,9 +51,9 @@ public class ForgeVersion
|
||||
forgeVersion = vers;
|
||||
forgeSpec = spec;
|
||||
forgeGroup = group;
|
||||
LOGGER.info(CORE, "Found Forge version {}", forgeVersion);
|
||||
LOGGER.info(CORE, "Found Forge spec {}", forgeSpec);
|
||||
LOGGER.info(CORE, "Found Forge group {}", forgeGroup);
|
||||
LOGGER.debug(CORE, "Found Forge version {}", forgeVersion);
|
||||
LOGGER.debug(CORE, "Found Forge spec {}", forgeSpec);
|
||||
LOGGER.debug(CORE, "Found Forge group {}", forgeGroup);
|
||||
}
|
||||
|
||||
public static String getVersion()
|
||||
|
||||
@@ -42,8 +42,8 @@ public class MCPVersion {
|
||||
}
|
||||
if (vers == null) throw new RuntimeException("Missing MCP version, cannot continue");
|
||||
mcpVersion = vers;
|
||||
LOGGER.info(CORE, "Found MC version information {}", mcVersion);
|
||||
LOGGER.info(CORE, "Found MCP version information {}", mcpVersion);
|
||||
LOGGER.debug(CORE, "Found MC version information {}", mcVersion);
|
||||
LOGGER.debug(CORE, "Found MCP version information {}", mcpVersion);
|
||||
}
|
||||
public static String getMCVersion() {
|
||||
return mcVersion;
|
||||
|
||||
Reference in new issue
Block a user