More compile cleanups. (#5139)

This commit is contained in:
tterrag authored and LexManos committed 2018-09-14 09:30:56 -07:00
1 parent dbf649225a
commit 3f743887e7
71 files changed
+901 -411

No files matched your search

@@ -20,11 +20,11 @@
package net.minecraftforge.fml.client;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface IDisplayableError
{
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
GuiScreen createGui();
}
@@ -203,7 +203,7 @@ public class SplashProgress
}
catch(IOException e)
{
FMLLog.log.error("Could not save the splash.properties file", e);
LOGGER.error("Could not save the splash.properties file", e);
}
miscPack = createResourcePack(miscPackFile);
@@ -240,7 +240,7 @@ public class SplashProgress
}
catch (LWJGLException e)
{
FMLLog.log.error("Error starting SplashProgress:", e);
LOGGER.error("Error starting SplashProgress:", e);
disableSplash(e);
}
@@ -537,7 +537,7 @@ public class SplashProgress
}
catch (LWJGLException e)
{
FMLLog.log.error("Error setting GL context:", e);
LOGGER.error("Error setting GL context:", e);
throw new RuntimeException(e);
}
glClearColor((float)((backgroundColor >> 16) & 0xFF) / 0xFF, (float)((backgroundColor >> 8) & 0xFF) / 0xFF, (float)(backgroundColor & 0xFF) / 0xFF, 1);
@@ -564,7 +564,7 @@ public class SplashProgress
}
catch (LWJGLException e)
{
FMLLog.log.error("Error releasing GL context:", e);
LOGGER.error("Error releasing GL context:", e);
throw new RuntimeException(e);
}
finally
@@ -578,7 +578,7 @@ public class SplashProgress
@Override
public void uncaughtException(Thread t, Throwable e)
{
FMLLog.log.error("Splash thread Exception", e);
LOGGER.error("Splash thread Exception", e);
threadError = e;
}
});
@@ -629,7 +629,7 @@ public class SplashProgress
}
catch (LWJGLException e)
{
FMLLog.log.error("Error setting GL context:", e);
LOGGER.error("Error setting GL context:", e);
throw new RuntimeException(e);
}
}
@@ -650,7 +650,7 @@ public class SplashProgress
}
catch (LWJGLException e)
{
FMLLog.log.error("Error releasing GL context:", e);
LOGGER.error("Error releasing GL context:", e);
throw new RuntimeException(e);
}
lock.unlock();
@@ -673,7 +673,7 @@ public class SplashProgress
}
catch (Exception e)
{
FMLLog.log.error("Error finishing SplashProgress:", e);
LOGGER.error("Error finishing SplashProgress:", e);
disableSplash(e);
}
}
@@ -726,7 +726,7 @@ public class SplashProgress
}
catch(IOException e)
{
FMLLog.log.error("Could not save the splash.properties file", e);
LOGGER.error("Could not save the splash.properties file", e);
return false;
}
return true;
@@ -843,7 +843,7 @@ public class SplashProgress
}
catch(IOException e)
{
FMLLog.log.error("Error reading texture from file: {}", location, e);
LOGGER.error("Error reading texture from file: {}", location, e);
throw new RuntimeException(e);
}
finally
@@ -38,10 +38,11 @@ import net.minecraftforge.fml.client.config.GuiConfigEntries.IConfigEntry;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent.PostConfigChangedEvent;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.eventbus.api.Event.Result;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
import javax.annotation.Nullable;
@@ -54,6 +55,8 @@ import javax.annotation.Nullable;
*/
public class GuiConfig extends GuiScreen
{
private static final Logger LOGGER = LogManager.getLogger();
/**
* A reference to the screen object that created this. Used for navigating between screens.
*/
@@ -289,7 +292,7 @@ public class GuiConfig extends GuiScreen
}
catch (Throwable e)
{
FMLLog.log.error("Error performing GuiConfig action:", e);
LOGGER.error("Error performing GuiConfig action:", e);
}
if (flag)
@@ -36,9 +36,11 @@ import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
/**
@@ -49,6 +51,8 @@ import org.lwjgl.input.Keyboard;
*/
public class GuiConfigEntries extends GuiListExtended
{
private static final Logger LOGGER = LogManager.getLogger();
public final GuiConfig owningScreen;
public final Minecraft mc;
public List<IConfigEntry> listEntries;
@@ -129,7 +133,7 @@ public class GuiConfigEntries extends GuiListExtended
}
catch (Throwable e)
{
FMLLog.log.error("There was a critical error instantiating the custom IConfigEntry for config element {}.", configElement.getName(), e);
LOGGER.error("There was a critical error instantiating the custom IConfigEntry for config element {}.", configElement.getName(), e);
}
else if (configElement.isProperty())
{
@@ -33,7 +33,8 @@ import net.minecraft.util.text.TextFormatting;
import static net.minecraftforge.fml.client.config.GuiUtils.RESET_CHAR;
import static net.minecraftforge.fml.client.config.GuiUtils.UNDO_CHAR;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
/**
@@ -44,6 +45,8 @@ import org.lwjgl.input.Keyboard;
*/
public class GuiEditArray extends GuiScreen
{
private static final Logger LOGGER = LogManager.getLogger();
protected GuiScreen parentScreen;
protected IConfigElement configElement;
protected GuiEditArrayEntries entryList;
@@ -129,7 +132,7 @@ public class GuiEditArray extends GuiScreen
}
catch (Throwable e)
{
FMLLog.log.error("Error performing GuiEditArray action:", e);
LOGGER.error("Error performing GuiEditArray action:", e);
}
this.mc.displayGuiScreen(this.parentScreen);
}
@@ -29,8 +29,9 @@ import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.client.config.GuiConfigEntries.ArrayEntry;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
import static net.minecraftforge.fml.client.config.GuiUtils.INVALID;
@@ -42,6 +43,8 @@ import static net.minecraftforge.fml.client.config.GuiUtils.VALID;
*/
public class GuiEditArrayEntries extends GuiListExtended
{
private static final Logger LOGGER = LogManager.getLogger();
protected GuiEditArray owningGui;
public IConfigElement configElement;
public List<IArrayEntry> listEntries;
@@ -80,7 +83,7 @@ public class GuiEditArrayEntries extends GuiListExtended
}
catch (Throwable e)
{
FMLLog.log.error("There was a critical error instantiating the custom IGuiEditListEntry for property {}.", configElement.getName(), e);
LOGGER.error("There was a critical error instantiating the custom IGuiEditListEntry for property {}.", configElement.getName(), e);
}
}
}
@@ -155,7 +158,7 @@ public class GuiEditArrayEntries extends GuiListExtended
}
catch (Throwable e)
{
FMLLog.log.error("There was a critical error instantiating the custom IGuiEditListEntry for property {}.", configElement.getName(), e);
LOGGER.error("There was a critical error instantiating the custom IGuiEditListEntry for property {}.", configElement.getName(), e);
}
}
else if (configElement.isList() && configElement.getType() == ConfigGuiType.BOOLEAN)
@@ -559,7 +562,7 @@ public class GuiEditArrayEntries extends GuiListExtended
}
}
public static class BaseEntry implements IArrayEntry
public static class BaseEntry extends GuiListExtended.IGuiListEntry implements IArrayEntry
{
protected final GuiEditArray owningScreen;
protected final GuiEditArrayEntries owningEntryList;
@@ -592,31 +595,31 @@ public class GuiEditArrayEntries extends GuiListExtended
}
@Override
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partial)
public void func_194999_a(int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isHovered, float partial)
{
if (this.getValue() != null && this.isValidated)
owningEntryList.getMC().fontRenderer.drawString(
owningEntryList.getMC().fontRenderer.func_211126_b(
isValidValue ? TextFormatting.GREEN + VALID : TextFormatting.RED + INVALID,
listWidth / 4 - owningEntryList.getMC().fontRenderer.getStringWidth(VALID) - 2,
y + slotHeight / 2 - owningEntryList.getMC().fontRenderer.FONT_HEIGHT / 2,
entryWidth / 4 - owningEntryList.getMC().fontRenderer.getStringWidth(VALID) - 2,
entryHeight / 2 - owningEntryList.getMC().fontRenderer.FONT_HEIGHT / 2,
16777215);
int half = listWidth / 2;
int half = entryWidth / 2;
if (owningEntryList.canAddMoreEntries)
{
this.btnAddNewEntryAbove.visible = true;
this.btnAddNewEntryAbove.x = half + ((half / 2) - 44);
this.btnAddNewEntryAbove.y = y;
this.btnAddNewEntryAbove.y = this.func_195001_c();
this.btnAddNewEntryAbove.drawButton(owningEntryList.getMC(), mouseX, mouseY, partial);
}
else
this.btnAddNewEntryAbove.visible = false;
if (!configElement.isListLengthFixed() && slotIndex != owningEntryList.listEntries.size() - 1)
if (!configElement.isListLengthFixed() && this.field_195005_b != owningEntryList.listEntries.size() - 1)
{
this.btnRemoveEntry.visible = true;
this.btnRemoveEntry.x = half + ((half / 2) - 22);
this.btnRemoveEntry.y = y;
this.btnRemoveEntry.y = this.func_195001_c();
this.btnRemoveEntry.drawButton(owningEntryList.getMC(), mouseX, mouseY, partial);
}
else
@@ -689,7 +692,7 @@ public class GuiEditArrayEntries extends GuiListExtended
public void updatePosition(int p_178011_1_, int p_178011_2_, int p_178011_3_, float partial){}
}
public static interface IArrayEntry extends GuiListExtended.IGuiListEntry
public static interface IArrayEntry
{
void keyTyped(char eventChar, int eventKey);
@@ -25,12 +25,14 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.common.FMLLog;
import static net.minecraftforge.fml.client.config.GuiUtils.RESET_CHAR;
import static net.minecraftforge.fml.client.config.GuiUtils.UNDO_CHAR;
@@ -42,6 +44,8 @@ import static net.minecraftforge.fml.client.config.GuiUtils.UNDO_CHAR;
*/
public class GuiSelectString extends GuiScreen
{
private static final Logger LOGGER = LogManager.getLogger();
protected GuiScreen parentScreen;
protected IConfigElement configElement;
protected GuiSelectStringEntries entryList;
@@ -129,7 +133,7 @@ public class GuiSelectString extends GuiScreen
}
catch (Throwable e)
{
FMLLog.log.error("Error performing GuiSelectString action:", e);
LOGGER.error("Error performing GuiSelectString action:", e);
}
this.mc.displayGuiScreen(this.parentScreen);
}
@@ -21,7 +21,9 @@ package net.minecraftforge.fml.client.gui;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiErrorScreen;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.IDisplayableError;
import net.minecraftforge.fml.common.EnhancedRuntimeException;
import net.minecraftforge.fml.common.IFMLHandledException;
import net.minecraftforge.api.distmarker.Dist;
@@ -22,17 +22,21 @@ package net.minecraftforge.fml.client.gui;
import java.io.File;
import java.io.IOException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.StartupQuery;
import net.minecraftforge.fml.common.ZipperUtil;
public class GuiOldSaveLoadConfirm extends GuiYesNo implements GuiYesNoCallback {
private static final Logger LOGGER = LogManager.getLogger();
private String dirName;
private String saveName;
private File zip;
@@ -75,7 +79,7 @@ public class GuiOldSaveLoadConfirm extends GuiYesNo implements GuiYesNoCallback
}
else
{
FMLLog.log.info("Capturing current state of world {} into file {}", saveName, zip.getAbsolutePath());
LOGGER.info("Capturing current state of world {} into file {}", saveName, zip.getAbsolutePath());
try
{
String skip = System.getProperty("fml.doNotBackup");
@@ -86,11 +90,11 @@ public class GuiOldSaveLoadConfirm extends GuiYesNo implements GuiYesNoCallback
else
{
for (int x = 0; x < 10; x++)
FMLLog.log.fatal("!!!!!!!!!! UPDATING WORLD WITHOUT DOING BACKUP !!!!!!!!!!!!!!!!");
LOGGER.fatal("!!!!!!!!!! UPDATING WORLD WITHOUT DOING BACKUP !!!!!!!!!!!!!!!!");
}
} catch (IOException e)
{
FMLLog.log.warn("There was a problem saving the backup {}. Please fix and try again", zip.getName(), e);
LOGGER.warn("There was a problem saving the backup {}. Please fix and try again", zip.getName(), e);
FMLClientHandler.instance().showGuiScreen(new GuiBackupFailed(parent, zip));
return;
}
@@ -52,10 +52,10 @@ public class GuiSortingProblem extends GuiScreen {
this.drawCenteredString(this.fontRenderer, "The remainder of the cycle involves these mods", this.width / 2, offset, 0xFFFFFF);
offset+=5;
for (ModContainer mc : failedList.getVisitedNodes())
{
{/* TODO Mod dependencies
offset+=10;
this.drawCenteredString(this.fontRenderer, String.format("%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies()), this.width / 2, offset, 0xEEEEEE);
}
*/}
offset+=20;
this.drawCenteredString(this.fontRenderer, "The file 'ForgeModLoader-client-0.log' contains more information", this.width / 2, offset, 0xFFFFFF);
}
@@ -44,13 +44,13 @@ public class ClientRegistry
* @param tileEntityClass
* @param id
* @param specialRenderer
*/
* / TODO GameRegistry
public static <T extends TileEntity> void registerTileEntity(Class<T> tileEntityClass, String id, TileEntityRenderer<? super T> specialRenderer)
{
GameRegistry.registerTileEntity(tileEntityClass, id);
bindTileEntitySpecialRenderer(tileEntityClass, specialRenderer);
}
*/
public static <T extends TileEntity> void bindTileEntitySpecialRenderer(Class<T> tileEntityClass, TileEntityRenderer<? super T> specialRenderer)
{
TileEntityRendererDispatcher.instance.renderers.put(tileEntityClass, specialRenderer);
@@ -18,7 +18,7 @@
*/
package net.minecraftforge.fml.common;
/* TODO ReflectionHelper
import java.util.Arrays;
import net.minecraftforge.fml.common.asm.deobf.FMLDeobfuscatingRemapper;
@@ -31,7 +31,7 @@ import net.minecraftforge.fml.relauncher.ReflectionHelper.UnableToFindFieldExcep
*
* @author cpw
*
*/
* /
public class ObfuscationReflectionHelper
{
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
@@ -42,7 +42,7 @@ public class ObfuscationReflectionHelper
}
catch (UnableToAccessFieldException e)
{
FMLLog.log.error("There was a problem getting field index {} from {}", classToAccess.getName(), e);
LOGGER.error("There was a problem getting field index {} from {}", classToAccess.getName(), e);
throw e;
}
}
@@ -67,12 +67,12 @@ public class ObfuscationReflectionHelper
}
catch (UnableToFindFieldException e)
{
FMLLog.log.error("Unable to locate any field {} on type {}", Arrays.toString(fieldNames), classToAccess.getName(), e);
LOGGER.error("Unable to locate any field {} on type {}", Arrays.toString(fieldNames), classToAccess.getName(), e);
throw e;
}
catch (UnableToAccessFieldException e)
{
FMLLog.log.error("Unable to access any field {} on type {}", classToAccess.getName(), e);
LOGGER.error("Unable to access any field {} on type {}", classToAccess.getName(), e);
throw e;
}
}
@@ -85,7 +85,7 @@ public class ObfuscationReflectionHelper
}
catch (UnableToAccessFieldException e)
{
FMLLog.log.error("There was a problem setting field index {} on type {}", classToAccess.getName(), e);
LOGGER.error("There was a problem setting field index {} on type {}", classToAccess.getName(), e);
throw e;
}
}
@@ -98,13 +98,14 @@ public class ObfuscationReflectionHelper
}
catch (UnableToFindFieldException e)
{
FMLLog.log.error("Unable to locate any field {} on type {}", classToAccess.getName(), e);
LOGGER.error("Unable to locate any field {} on type {}", classToAccess.getName(), e);
throw e;
}
catch (UnableToAccessFieldException e)
{
FMLLog.log.error("Unable to set any field {} on type {}", classToAccess.getName(), e);
LOGGER.error("Unable to set any field {} on type {}", classToAccess.getName(), e);
throw e;
}
}
}
*/
@@ -18,7 +18,7 @@
*/
package net.minecraftforge.fml.common.asm.transformers;
/* TODO Class transformers
import java.util.Iterator;
import org.objectweb.asm.ClassReader;
@@ -167,3 +167,4 @@ public class SoundEngineFixTransformer implements IClassTransformer
}
}
*/
@@ -31,6 +31,7 @@ import net.minecraftforge.registries.ForgeRegistryEntry;
import org.apache.commons.lang3.Validate;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityVillager.ITradeList;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.RegistryNamespaced;
@@ -43,18 +44,17 @@ import javax.annotation.Nullable;
*/
public class VillagerRegistry
{
/*
public static final RegistryObject<VillagerProfession> FARMER = RegistryObject.of("minecraft:farmer", ()->VillagerProfession.class);
private static final VillagerRegistry INSTANCE = new VillagerRegistry();
/* TODO village creation
private Map<Class<?>, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap();
*/
private VillagerRegistry()
{
init();
}
*/
/**
* Allow access to the {@link net.minecraft.world.gen.structure.StructureVillagePieces} array controlling new village
* creation so you can insert your own new village pieces
@@ -100,13 +100,12 @@ public class VillagerRegistry
Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int p1,
int p2, int p3, EnumFacing facing, int p5);
}
*/
public static VillagerRegistry instance()
{
return INSTANCE;
}
*/
/**
* Register a new village creation handler
*
@@ -132,7 +131,7 @@ public class VillagerRegistry
{
return instance().villageCreationHandlers.get(villagePiece.villagePieceClass).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, facing, p5);
}
*/
RegistryNamespaced<ResourceLocation, VillagerProfession> REGISTRY = GameData.getWrapper(VillagerProfession.class);
private void register(VillagerProfession prof, int id)
@@ -178,9 +177,9 @@ public class VillagerRegistry
"minecraft:textures/entity/zombie_villager/zombie_smith.png");
{
register(prof, 3);
(new VillagerCareer(prof, "armor")).init(VanillaTrades.trades[3][0]);
(new VillagerCareer(prof, "weapon")).init(VanillaTrades.trades[3][1]);
(new VillagerCareer(prof, "tool")).init(VanillaTrades.trades[3][2]);
(new VillagerCareer(prof, "armorer")).init(VanillaTrades.trades[3][0]);
(new VillagerCareer(prof, "weapon_smith")).init(VanillaTrades.trades[3][1]);
(new VillagerCareer(prof, "tool_smith")).init(VanillaTrades.trades[3][2]);
}
prof = new VillagerProfession("minecraft:butcher",
"minecraft:textures/entity/villager/butcher.png",
@@ -188,7 +187,7 @@ public class VillagerRegistry
{
register(prof, 4);
(new VillagerCareer(prof, "butcher")).init(VanillaTrades.trades[4][0]);
(new VillagerCareer(prof, "leather")).init(VanillaTrades.trades[4][1]);
(new VillagerCareer(prof, "leatherworker")).init(VanillaTrades.trades[4][1]);
}
prof = new VillagerProfession("minecraft:nitwit",
"minecraft:textures/entity/villager/villager.png",
@@ -312,13 +311,12 @@ public class VillagerRegistry
}
}
*/
/**
/**
* Hook called when spawning a Villager, sets it's profession to a random registered profession.
*
* @param entity The new entity
* @param rand The world's RNG
*//*
*/
public static void setRandomProfession(EntityVillager entity, Random rand)
{
@@ -369,5 +367,5 @@ public class VillagerRegistry
//It is nasty I know but it's vanilla.
private static final ITradeList[][][][] trades = EntityVillager.GET_TRADES_DONT_USE();
}
*/
}
@@ -22,12 +22,12 @@ package net.minecraftforge.fml.common.toposort;
import java.util.Set;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.client.GuiSortingProblem;
import net.minecraftforge.fml.client.IDisplayableError;
import net.minecraftforge.fml.common.EnhancedRuntimeException;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.client.IDisplayableError;
import net.minecraftforge.fml.client.gui.GuiSortingProblem;
import net.minecraftforge.fml.common.EnhancedRuntimeException;
public class ModSortingException extends EnhancedRuntimeException implements IDisplayableError
{
@@ -76,14 +76,14 @@ public class ModSortingException extends EnhancedRuntimeException implements IDi
stream.println("The first mod in the cycle is " + exceptionData.getFirstBadNode());
stream.println("The mod cycle involves:");
for (ModContainer mc : exceptionData.getVisitedNodes())
{
{/* TODO Mod dependencies
stream.println(String.format("\t%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies()));
}
*/}
}
@Override
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public GuiScreen createGui()
{
return new GuiSortingProblem(this);
@@ -30,6 +30,7 @@ import java.net.URISyntaxException;
import java.security.CodeSource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
@@ -46,17 +47,22 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import com.google.common.io.ByteStreams;
import com.google.common.io.Files;
import net.minecraft.launchwrapper.Launch;
import cpw.mods.modlauncher.Launcher;
import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
import net.minecraftforge.fml.loading.FMLCommonLaunchHandler;
import net.minecraftforge.fml.loading.FMLEnvironment;
public class LibraryManager
{
private static final Logger LOGGER = LogManager.getLogger();
public static final boolean DISABLE_EXTERNAL_MANIFEST = Boolean.parseBoolean(System.getProperty("forge.disable_external_manifest", "false"));
public static final boolean ENABLE_AUTO_MOD_MOVEMENT = Boolean.parseBoolean(System.getProperty("forge.enable_auto_mod_movement", "false"));
private static final String LIBRARY_DIRECTORY_OVERRIDE = System.getProperty("forge.lib_folder", null);
@@ -75,10 +81,10 @@ public class LibraryManager
public static void setup(File minecraftHome)
{
File libDir = findLibraryFolder(minecraftHome);
FMLLog.log.debug("Determined Minecraft Libraries Root: {}", libDir);
LOGGER.debug("Determined Minecraft Libraries Root: {}", libDir);
Repository old = Repository.replace(libDir, "libraries");
if (old != null)
FMLLog.log.debug(" Overwriting Previous: {}", old);
LOGGER.debug(" Overwriting Previous: {}", old);
libraries_dir = Repository.get("libraries");
File mods = new File(minecraftHome, "mods");
@@ -119,14 +125,14 @@ public class LibraryManager
{
if (LIBRARY_DIRECTORY_OVERRIDE != null)
{
FMLLog.log.error("System variable set to override Library Directory: {}", LIBRARY_DIRECTORY_OVERRIDE);
LOGGER.error("System variable set to override Library Directory: {}", LIBRARY_DIRECTORY_OVERRIDE);
return new File(LIBRARY_DIRECTORY_OVERRIDE);
}
CodeSource source = ArtifactVersion.class.getProtectionDomain().getCodeSource();
if (source == null)
{
FMLLog.log.error("Unable to determine codesource for {}. Using default libraries directory.", ArtifactVersion.class.getName());
LOGGER.error("Unable to determine codesource for {}. Using default libraries directory.", ArtifactVersion.class.getName());
return new File(minecraftHome, "libraries");
}
@@ -142,9 +148,9 @@ public class LibraryManager
if (!comp.endsWith("/org/apache/maven/maven-artifact/"))
{
FMLLog.log.error("Apache Maven library folder was not in the format expected. Using default libraries directory.");
FMLLog.log.error("Full: {}", new File(source.getLocation().toURI()));
FMLLog.log.error("Trimmed: {}", comp);
LOGGER.error("Apache Maven library folder was not in the format expected. Using default libraries directory.");
LOGGER.error("Full: {}", new File(source.getLocation().toURI()));
LOGGER.error("Trimmed: {}", comp);
return new File(minecraftHome, "libraries");
}
// maven-artifact /maven /apache /org /libraries
@@ -152,7 +158,7 @@ public class LibraryManager
}
catch (URISyntaxException e)
{
FMLLog.log.error(FMLLog.log.getMessageFactory().newMessage("Unable to determine file for {}. Using default libraries directory.", ArtifactVersion.class.getName()), e);
LOGGER.error(LOGGER.getMessageFactory().newMessage("Unable to determine file for {}. Using default libraries directory.", ArtifactVersion.class.getName()), e);
}
return new File(minecraftHome, "libraries"); //Everything else failed, return the default.
@@ -163,7 +169,7 @@ public class LibraryManager
if (!dir.exists())
return;
FMLLog.log.debug("Cleaning up mods folder: {}", dir);
LOGGER.debug("Cleaning up mods folder: {}", dir);
for (File file : dir.listFiles(f -> f.isFile() && f.getName().endsWith(".jar")))
{
Pair<Artifact, byte[]> ret = extractPacked(file, modlist, modDirs);
@@ -183,7 +189,7 @@ public class LibraryManager
}
catch (IOException e)
{
FMLLog.log.error(FMLLog.log.getMessageFactory().newMessage("Error updating modlist file {}", modlist.getName()), e);
LOGGER.error(LOGGER.getMessageFactory().newMessage("Error updating modlist file {}", modlist.getName()), e);
}
}
@@ -191,20 +197,20 @@ public class LibraryManager
{
if (processed.contains(file))
{
FMLLog.log.debug("File already proccessed {}, Skipping", file.getAbsolutePath());
LOGGER.debug("File already proccessed {}, Skipping", file.getAbsolutePath());
return null;
}
JarFile jar = null;
try
{
jar = new JarFile(file);
FMLLog.log.debug("Examining file: {}", file.getName());
LOGGER.debug("Examining file: {}", file.getName());
processed.add(file);
return extractPacked(jar, modlist, modDirs);
}
catch (IOException ioe)
{
FMLLog.log.error("Unable to read the jar file {} - ignoring", file.getName(), ioe);
LOGGER.error("Unable to read the jar file {} - ignoring", file.getName(), ioe);
}
finally
{
@@ -228,7 +234,7 @@ public class LibraryManager
attrs = jar.getManifest().getMainAttributes();
String modSide = attrs.getValue(LibraryManager.MODSIDE);
if (modSide != null && !"BOTH".equals(modSide) && !FMLLaunchHandler.side().name().equals(modSide))
if (modSide != null && !"BOTH".equals(modSide) && !FMLEnvironment.dist.name().equals(modSide))
return null;
if (attrs.containsKey(MODCONTAINSDEPS))
@@ -237,7 +243,7 @@ public class LibraryManager
{
if (!dep.endsWith(".jar"))
{
FMLLog.log.error("Contained Dep is not a jar file: {}", dep);
LOGGER.error("Contained Dep is not a jar file: {}", dep);
throw new IllegalStateException("Invalid contained dep, Must be jar: " + dep);
}
@@ -247,14 +253,14 @@ public class LibraryManager
JarEntry depEntry = jar.getJarEntry(dep);
if (depEntry == null)
{
FMLLog.log.error("Contained Dep is not in the jar: {}", dep);
LOGGER.error("Contained Dep is not in the jar: {}", dep);
throw new IllegalStateException("Invalid contained dep, Missing from jar: " + dep);
}
String depEndName = new File(dep).getName(); // extract last part of name
if (skipContainedDeps.contains(dep) || skipContainedDeps.contains(depEndName))
{
FMLLog.log.error("Skipping dep at request: {}", dep);
LOGGER.error("Skipping dep at request: {}", dep);
continue;
}
@@ -294,14 +300,14 @@ public class LibraryManager
File target = new File(dir, depEndName);
if (target.exists())
{
FMLLog.log.debug("Found existing ContainDep extracted to {}, skipping extraction", target.getCanonicalPath());
LOGGER.debug("Found existing ContainDep extracted to {}, skipping extraction", target.getCanonicalPath());
found = true;
}
}
if (!found)
{
File target = new File(modDirs[0], depEndName);
FMLLog.log.debug("Extracting ContainedDep {} from {} to {}", dep, jar.getName(), target.getCanonicalPath());
LOGGER.debug("Extracting ContainedDep {} from {} to {}", dep, jar.getName(), target.getCanonicalPath());
try
{
Files.createParentDirs(target);
@@ -313,12 +319,12 @@ public class LibraryManager
{
ByteStreams.copy(in, out);
}
FMLLog.log.debug("Extracted ContainedDep {} from {} to {}", dep, jar.getName(), target.getCanonicalPath());
LOGGER.debug("Extracted ContainedDep {} from {} to {}", dep, jar.getName(), target.getCanonicalPath());
extractPacked(target, modlist, modDirs);
}
catch (IOException e)
{
FMLLog.log.error("An error occurred extracting dependency", e);
LOGGER.error("An error occurred extracting dependency", e);
}
}
}
@@ -330,7 +336,7 @@ public class LibraryManager
File target = artifact.getFile();
if (target.exists())
{
FMLLog.log.debug("Found existing ContainedDep {}({}) from {} extracted to {}, skipping extraction", dep, artifact.toString(), target.getCanonicalPath(), jar.getName());
LOGGER.debug("Found existing ContainedDep {}({}) from {} extracted to {}, skipping extraction", dep, artifact.toString(), target.getCanonicalPath(), jar.getName());
if (!ENABLE_AUTO_MOD_MOVEMENT)
{
Pair<?, ?> child = extractPacked(target, modlist, modDirs); //If we're not building a real list we have to re-build the dep list every run. So search down.
@@ -342,7 +348,7 @@ public class LibraryManager
}
else
{
FMLLog.log.debug("Extracting ContainedDep {}({}) from {} to {}", dep, artifact.toString(), jar.getName(), target.getCanonicalPath());
LOGGER.debug("Extracting ContainedDep {}({}) from {} to {}", dep, artifact.toString(), jar.getName(), target.getCanonicalPath());
Files.createParentDirs(target);
try
(
@@ -352,7 +358,7 @@ public class LibraryManager
{
ByteStreams.copy(in, out);
}
FMLLog.log.debug("Extracted ContainedDep {}({}) from {} to {}", dep, artifact.toString(), jar.getName(), target.getCanonicalPath());
LOGGER.debug("Extracted ContainedDep {}({}) from {} to {}", dep, artifact.toString(), jar.getName(), target.getCanonicalPath());
if (artifact.isSnapshot())
{
@@ -375,11 +381,11 @@ public class LibraryManager
}
catch (NumberFormatException nfe)
{
FMLLog.log.error(FMLLog.log.getMessageFactory().newMessage("An error occurred extracting dependency. Invalid Timestamp: {}", meta.getValue(TIMESTAMP)), nfe);
LOGGER.error(LOGGER.getMessageFactory().newMessage("An error occurred extracting dependency. Invalid Timestamp: {}", meta.getValue(TIMESTAMP)), nfe);
}
catch (IOException e)
{
FMLLog.log.error("An error occurred extracting dependency", e);
LOGGER.error("An error occurred extracting dependency", e);
}
}
}
@@ -443,26 +449,26 @@ public class LibraryManager
List<File> list = new ArrayList<>();
@SuppressWarnings("unchecked")
Map<String,String> args = (Map<String, String>)Launch.blackboard.get("launchArgs");
Map<String,String> args = Collections.emptyMap(); // TODO Launch args - do we need this? (Map<String, String>)Launcher.INSTANCE.blackboard().get("launchArgs");
String extraMods = args.get("--mods");
if (extraMods != null)
{
FMLLog.log.info("Found mods from the command line:");
LOGGER.info("Found mods from the command line:");
for (String mod : extraMods.split(","))
{
File file = new File(mcDir, mod);
if (!file.exists())
{
FMLLog.log.info(" Failed to find mod file {} ({})", mod, file.getAbsolutePath());
LOGGER.info(" Failed to find mod file {} ({})", mod, file.getAbsolutePath());
}
else if (!list.contains(file))
{
FMLLog.log.debug(" Adding {} ({}) to the mod list", mod, file.getAbsolutePath());
LOGGER.debug(" Adding {} ({}) to the mod list", mod, file.getAbsolutePath());
list.add(file);
}
else if (!list.contains(file))
{
FMLLog.log.debug(" Duplicte command line mod detected {} ({})", mod, file.getAbsolutePath());
LOGGER.debug(" Duplicte command line mod detected {} ({})", mod, file.getAbsolutePath());
}
}
}
@@ -473,12 +479,12 @@ public class LibraryManager
if (!base.isDirectory() || !base.exists())
continue;
FMLLog.log.info("Searching {} for mods", base.getAbsolutePath());
LOGGER.info("Searching {} for mods", base.getAbsolutePath());
for (File f : base.listFiles(MOD_FILENAME_FILTER))
{
if (!list.contains(f))
{
FMLLog.log.debug(" Adding {} to the mod list", f.getName());
LOGGER.debug(" Adding {} to the mod list", f.getName());
list.add(f);
}
}
@@ -26,10 +26,13 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class LinkRepository extends Repository
{
private static final Logger LOGGER = LogManager.getLogger();
private Map<String, File> artifact_to_file = new HashMap<>();
private Map<String, File> filesystem = new HashMap<>();
private Map<String, Artifact> snapshots = new HashMap<>();
@@ -46,14 +49,14 @@ public class LinkRepository extends Repository
known.add(file);
if (artifact_to_file.containsKey(key))
{
FMLLog.log.debug("Maven file already exists for {}({}) at {}, ignoring duplicate.", file.getName(), artifact.toString(), artifact_to_file.get(key).getAbsolutePath());
LOGGER.debug("Maven file already exists for {}({}) at {}, ignoring duplicate.", file.getName(), artifact.toString(), artifact_to_file.get(key).getAbsolutePath());
if (artifact.isSnapshot())
{
Artifact old = snapshots.get(key);
if (old == null || old.compareVersion(artifact) < 0)
{
FMLLog.log.debug("Overriding Snapshot {} -> {}", old == null ? "null" : old.getTimestamp(), artifact.getTimestamp());
LOGGER.debug("Overriding Snapshot {} -> {}", old == null ? "null" : old.getTimestamp(), artifact.getTimestamp());
snapshots.put(key, artifact);
artifact_to_file.put(key, file);
filesystem.put(artifact.getPath(), file);
@@ -62,7 +65,7 @@ public class LinkRepository extends Repository
}
else
{
FMLLog.log.debug("Making maven link for {} in memory to {}.", key, file.getAbsolutePath());
LOGGER.debug("Making maven link for {} in memory to {}.", key, file.getAbsolutePath());
artifact_to_file.put(key, file);
filesystem.put(artifact.getPath(), file);
@@ -30,18 +30,21 @@ import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.common.collect.ImmutableList;
import com.google.common.io.Files;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.fml.common.FMLLog;
public class ModList
{
private static final Logger LOGGER = LogManager.getLogger();
private static final Gson GSON = new GsonBuilder().setLenient().create();
static final Map<String, ModList> cache = new HashMap<>();
@@ -54,7 +57,7 @@ public class ModList
}
catch (IOException e)
{
FMLLog.log.error(FMLLog.log.getMessageFactory().newMessage("Unable to load ModList json at {}.", json.getAbsoluteFile()), e);
LOGGER.error(LOGGER.getMessageFactory().newMessage("Unable to load ModList json at {}.", json.getAbsoluteFile()), e);
}
return new ModList(json, mcdir);
@@ -63,7 +66,7 @@ public class ModList
@SuppressWarnings("unchecked")
public static List<ModList> getKnownLists(File mcdir)
{
for (String list : new String[] {"mods/mod_list.json", "mods/" + ForgeVersion.mcVersion + "/mod_list.json", ((Map<String, String>)Launch.blackboard.get("launchArgs")).get("--modListFile")})
for (String list : new String[] {"mods/mod_list.json", "mods/" + ForgeVersion.mcVersion + "/mod_list.json"/* , TODO Launch args ((Map<String, String>)Launch.blackboard.get("launchArgs")).get("--modListFile")*/})
{
if (list != null)
{
@@ -84,7 +87,7 @@ public class ModList
if (memory != null)
lst.add(memory);
for (String list : new String[] {"mods/mod_list.json", "mods/" + ForgeVersion.mcVersion + "/mod_list.json", ((Map<String, String>)Launch.blackboard.get("launchArgs")).get("--modListFile")})
for (String list : new String[] {"mods/mod_list.json", "mods/" + ForgeVersion.mcVersion + "/mod_list.json"/* TODO Launch args, ((Map<String, String>)Launch.blackboard.get("launchArgs")).get("--modListFile")*/})
{
if (list != null)
{
@@ -127,11 +130,11 @@ public class ModList
}
catch (JsonSyntaxException jse)
{
FMLLog.log.info(FMLLog.log.getMessageFactory().newMessage("Failed to parse modList json file {}.", path), jse);
LOGGER.info(LOGGER.getMessageFactory().newMessage("Failed to parse modList json file {}.", path), jse);
}
catch (IOException ioe)
{
FMLLog.log.info(FMLLog.log.getMessageFactory().newMessage("Failed to read modList json file {}.", path), ioe);
LOGGER.info(LOGGER.getMessageFactory().newMessage("Failed to read modList json file {}.", path), ioe);
}
}
this.mod_list = temp_list == null ? new JsonModList() : temp_list;
@@ -148,7 +151,7 @@ public class ModList
}
catch (IOException e)
{
FMLLog.log.info(FMLLog.log.getMessageFactory().newMessage("Failed to create repository for modlist at {}.", mod_list.repositoryRoot), e);
LOGGER.info(LOGGER.getMessageFactory().newMessage("Failed to create repository for modlist at {}.", mod_list.repositoryRoot), e);
}
}
this.repo = temp;
@@ -209,7 +212,7 @@ public class ModList
}
catch (IOException ioe)
{
FMLLog.log.info(FMLLog.log.getMessageFactory().newMessage("Unable to canonicalize path {} relative to {}", path, root.getAbsolutePath()));
LOGGER.info(LOGGER.getMessageFactory().newMessage("Unable to canonicalize path {} relative to {}", path, root.getAbsolutePath()));
}
return null;
}
@@ -25,13 +25,16 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.common.hash.Hashing;
import com.google.common.io.Files;
import net.minecraftforge.fml.common.FMLLog;
public class Repository
{
private static final Logger LOGGER = LogManager.getLogger();
static final Map<String, Repository> cache = new LinkedHashMap<>();
public static Repository create(File root) throws IOException
@@ -129,12 +132,12 @@ public class Repository
{
if (target.exists())
{
FMLLog.log.debug("Maven file already exists for {}({}) at {}, deleting duplicate.", file.getName(), artifact.toString(), target.getAbsolutePath());
LOGGER.debug("Maven file already exists for {}({}) at {}, deleting duplicate.", file.getName(), artifact.toString(), target.getAbsolutePath());
file.delete();
}
else
{
FMLLog.log.debug("Moving file {}({}) to maven repo at {}.", file.getName(), artifact.toString(), target.getAbsolutePath());
LOGGER.debug("Moving file {}({}) to maven repo at {}.", file.getName(), artifact.toString(), target.getAbsolutePath());
Files.move(file, target);
if (artifact.isSnapshot())
@@ -154,7 +157,7 @@ public class Repository
}
catch (IOException e)
{
FMLLog.log.error(FMLLog.log.getMessageFactory().newMessage("Error moving file {} to {}", file, target.getAbsolutePath()), e);
LOGGER.error(LOGGER.getMessageFactory().newMessage("Error moving file {} to {}", file, target.getAbsolutePath()), e);
}
return file;
}
@@ -133,19 +133,19 @@ public class ServerLifecycleHooks
{
try
{
FMLLog.log.info("Waiting for the server to terminate/save.");
LOGGER.info("Waiting for the server to terminate/save.");
if (!latch.await(10, TimeUnit.SECONDS))
{
FMLLog.log.warn("The server didn't stop within 10 seconds, exiting anyway.");
LOGGER.warn("The server didn't stop within 10 seconds, exiting anyway.");
}
else
{
FMLLog.log.info("Server terminated.");
LOGGER.info("Server terminated.");
}
}
catch (InterruptedException e)
{
FMLLog.log.warn("Interrupted wait, exiting.");
LOGGER.warn("Interrupted wait, exiting.");
}
}