From 015ac2547e4fa38f96f1dcef496ae4bee35ba12d Mon Sep 17 00:00:00 2001 From: cpw Date: Sat, 29 Sep 2018 01:29:35 -0400 Subject: [PATCH] Fixup the config GUI and get things working again. --- build.gradle | 24 +- .../net/minecraftforge/fml/ModContainer.java | 1 + ...CustomModLoadingErrorDisplayException.java | 83 ---- .../client/gui/GuiButtonClickConsumer.java | 13 +- .../gui/GuiCustomModLoadingErrorScreen.java | 49 --- .../fml/client/gui/GuiDupesFound.java | 58 --- .../fml/client/gui/GuiErrorBase.java | 96 ----- .../fml/client/gui/GuiModList.java | 291 +++++++------- .../fml/client/gui/GuiModsMissing.java | 94 ----- .../client/gui/GuiModsMissingForServer.java | 71 ---- .../client/gui/GuiMultipleModsErrored.java | 170 -------- .../fml/client/gui/GuiScrollingList.java | 378 ------------------ .../fml/client/gui/GuiSlotModList.java | 4 +- .../fml/client/gui/LoadingErrorScreen.java | 2 +- .../common/DuplicateModsFoundException.java | 41 -- .../fml/common/MissingModsException.java | 131 ------ .../fml/common/MultipleModsErrored.java | 55 --- .../fml/javafmlmod/FMLModContainer.java | 5 +- .../fml/loading/FMLClientLaunchProvider.java | 8 +- .../minecraftforge/fml/loading/ModSorter.java | 1 - .../fml/loading/moddiscovery/ModInfo.java | 2 +- .../resources/assets/forge/lang/en_us.json | 9 + src/main/resources/forgemod.toml | 2 + 23 files changed, 204 insertions(+), 1384 deletions(-) delete mode 100644 src/main/java/net/minecraftforge/fml/client/gui/CustomModLoadingErrorDisplayException.java delete mode 100644 src/main/java/net/minecraftforge/fml/client/gui/GuiCustomModLoadingErrorScreen.java delete mode 100644 src/main/java/net/minecraftforge/fml/client/gui/GuiDupesFound.java delete mode 100644 src/main/java/net/minecraftforge/fml/client/gui/GuiErrorBase.java delete mode 100644 src/main/java/net/minecraftforge/fml/client/gui/GuiModsMissing.java delete mode 100644 src/main/java/net/minecraftforge/fml/client/gui/GuiModsMissingForServer.java delete mode 100644 src/main/java/net/minecraftforge/fml/client/gui/GuiMultipleModsErrored.java delete mode 100644 src/main/java/net/minecraftforge/fml/client/gui/GuiScrollingList.java delete mode 100644 src/main/java/net/minecraftforge/fml/common/DuplicateModsFoundException.java delete mode 100644 src/main/java/net/minecraftforge/fml/common/MissingModsException.java delete mode 100644 src/main/java/net/minecraftforge/fml/common/MultipleModsErrored.java diff --git a/build.gradle b/build.gradle index ab9bfad3c..ad5b9f7ca 100644 --- a/build.gradle +++ b/build.gradle @@ -171,19 +171,21 @@ project(':forge') { workingDir 'runserver' } - task ciWriteBuildNumber << { - def file = file("$rootDir/src/main/java/net/minecraftforge/common/ForgeVersion.java") - def bn = System.getenv('BUILD_NUMBER') ?: project.ext.properties.buildNumber ?: 0 - def outfile = '' + task ciWriteBuildNumber { + doLast { + def file = file("$rootDir/src/main/java/net/minecraftforge/common/ForgeVersion.java") + def bn = System.getenv('BUILD_NUMBER') ?: project.ext.properties.buildNumber ?: 0 + def outfile = '' - file.eachLine{ String s -> - if (s.matches('^ public static final int buildVersion = [\\d]+;\$')) - s = " public static final int buildVersion = ${bn};" - if (s.matches('^ public static final String mcVersion = "[^\\"]+";')) - s = " public static final String mcVersion = \"${patcher.mcVersion}\";" - outfile += (s+'\n') + file.eachLine{ String s -> + if (s.matches('^ public static final int buildVersion = [\\d]+;\$')) + s = " public static final int buildVersion = ${bn};" + if (s.matches('^ public static final String mcVersion = "[^\\"]+";')) + s = " public static final String mcVersion = \"${patcher.mcVersion}\";" + outfile += (s+'\n') + } + file.write(outfile) } - file.write(outfile) } diff --git a/src/main/java/net/minecraftforge/fml/ModContainer.java b/src/main/java/net/minecraftforge/fml/ModContainer.java index 40bfa46d2..2d89596f4 100644 --- a/src/main/java/net/minecraftforge/fml/ModContainer.java +++ b/src/main/java/net/minecraftforge/fml/ModContainer.java @@ -93,6 +93,7 @@ public abstract class ModContainer try { triggerMap.getOrDefault(modLoadingStage, e->{}).accept(event); + modLoadingStage = event.toStage(); } catch (ModLoadingException e) { diff --git a/src/main/java/net/minecraftforge/fml/client/gui/CustomModLoadingErrorDisplayException.java b/src/main/java/net/minecraftforge/fml/client/gui/CustomModLoadingErrorDisplayException.java deleted file mode 100644 index caa712477..000000000 --- a/src/main/java/net/minecraftforge/fml/client/gui/CustomModLoadingErrorDisplayException.java +++ /dev/null @@ -1,83 +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.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; - -/** - * If a mod throws this exception during loading, it will be called back to render - * the error screen through the methods below. This error will not be cleared, and will - * not allow the game to carry on, but might be useful if your mod wishes to report - * a fatal configuration error in a pretty way. - * - * Throw this through a proxy. It won't work on the dedicated server environment. - * @author cpw - * - */ -@OnlyIn(Dist.CLIENT) -public abstract class CustomModLoadingErrorDisplayException extends EnhancedRuntimeException implements IFMLHandledException, IDisplayableError -{ - public CustomModLoadingErrorDisplayException() { - } - - public CustomModLoadingErrorDisplayException(String message, Throwable cause) - { - super(message, cause); - } - - private static final long serialVersionUID = 1L; - - /** - * Called after the GUI is initialized by the parent code. You can do extra stuff here, maybe? - * - * @param errorScreen The error screen we're painting - * @param fontRenderer A font renderer for you - */ - public abstract void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer); - - /** - * Draw your error to the screen. - * - *
Warning: Minecraft is in a deep error state. All it can do is stop. - * Do not try and do anything involving complex user interaction here. - * - * @param errorScreen The error screen to draw to - * @param fontRenderer A font renderer for you - * @param mouseRelX Mouse X - * @param mouseRelY Mouse Y - * @param tickTime tick time - */ - public abstract void drawScreen(GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime); - - @Override public void printStackTrace(EnhancedRuntimeException.WrappedPrintStream s){}; // Do Nothing unless the modder wants to. - - @Override - public final GuiScreen createGui() - { - return new GuiCustomModLoadingErrorScreen(this); - } -} diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiButtonClickConsumer.java b/src/main/java/net/minecraftforge/fml/client/gui/GuiButtonClickConsumer.java index 025e136c3..078651c7a 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiButtonClickConsumer.java +++ b/src/main/java/net/minecraftforge/fml/client/gui/GuiButtonClickConsumer.java @@ -2,12 +2,17 @@ package net.minecraftforge.fml.client.gui; import net.minecraft.client.gui.GuiButton; -import java.util.function.DoubleBinaryOperator; - public class GuiButtonClickConsumer extends GuiButton { - private final DoubleBinaryOperator onClickAction; + public interface DoubleBiConsumer { + void applyAsDouble(double x, double y); + } + private final DoubleBiConsumer onClickAction; - public GuiButtonClickConsumer(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, DoubleBinaryOperator onClick) { + public GuiButtonClickConsumer(final int buttonId, final int x, final int y, final String buttonText, DoubleBiConsumer onClick) { + super(buttonId, x, y, buttonText); + this.onClickAction = onClick; + } + public GuiButtonClickConsumer(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, DoubleBiConsumer onClick) { super(buttonId, x, y, widthIn, heightIn, buttonText); this.onClickAction = onClick; } diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiCustomModLoadingErrorScreen.java b/src/main/java/net/minecraftforge/fml/client/gui/GuiCustomModLoadingErrorScreen.java deleted file mode 100644 index cd119f7cc..000000000 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiCustomModLoadingErrorScreen.java +++ /dev/null @@ -1,49 +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.client.gui; - -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -@OnlyIn(Dist.CLIENT) -public class GuiCustomModLoadingErrorScreen extends GuiErrorBase -{ - private CustomModLoadingErrorDisplayException customException; - - public GuiCustomModLoadingErrorScreen(CustomModLoadingErrorDisplayException customException) - { - this.customException = customException; - } - - @Override - public void initGui() - { - super.initGui(); - this.customException.initGui(this, fontRenderer); - } - - @Override - public void render(int mouseX, int mouseY, float partialTicks) - { - this.drawDefaultBackground(); - super.render(mouseX, mouseY, partialTicks); - this.customException.drawScreen(this, fontRenderer, mouseX, mouseY, partialTicks); - } -} diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiDupesFound.java b/src/main/java/net/minecraftforge/fml/client/gui/GuiDupesFound.java deleted file mode 100644 index 62a45f3ff..000000000 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiDupesFound.java +++ /dev/null @@ -1,58 +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.client.gui; - -import java.io.File; -import java.util.Map.Entry; - -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.ModContainer; -import net.minecraftforge.fml.common.DuplicateModsFoundException; - -@OnlyIn(Dist.CLIENT) -public class GuiDupesFound extends GuiErrorBase -{ - private DuplicateModsFoundException dupes; - - public GuiDupesFound(DuplicateModsFoundException dupes) - { - this.dupes = dupes; - } - - @Override - public void render(int mouseX, int mouseY, float partialTicks) - { - this.drawDefaultBackground(); - int offset = Math.max(85 - dupes.dupes.size() * 10, 10); - this.drawCenteredString(this.fontRenderer, "Forge Mod Loader has found a problem with your minecraft installation", this.width / 2, offset, 0xFFFFFF); - offset += 10; - this.drawCenteredString(this.fontRenderer, "You have mod sources that are duplicate within your system", this.width / 2, offset, 0xFFFFFF); - offset += 10; - this.drawCenteredString(this.fontRenderer, "Mod Id : File name", this.width / 2, offset, 0xFFFFFF); - offset += 5; - for (Entry mc : dupes.dupes.entries()) - { - offset += 10; - this.drawCenteredString(this.fontRenderer, String.format("%s : %s", mc.getKey().getModId(), mc.getValue().getName()), this.width / 2, offset, 0xEEEEEE); - } - super.render(mouseX, mouseY, partialTicks); - } -} diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiErrorBase.java b/src/main/java/net/minecraftforge/fml/client/gui/GuiErrorBase.java deleted file mode 100644 index 79a16f36e..000000000 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiErrorBase.java +++ /dev/null @@ -1,96 +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.client.gui; - -import java.awt.Desktop; -import java.io.File; - -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiErrorScreen; -import net.minecraft.client.resources.I18n; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.loading.FMLPaths; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -@OnlyIn(Dist.CLIENT) -public class GuiErrorBase extends GuiErrorScreen -{ - private static final Logger LOGGER = LogManager.getLogger(); - static final File minecraftDir = new File(FMLPaths.FMLCONFIG.get().toFile().getParent()); - static final File logFile = new File(minecraftDir, "logs/latest.log"); - - public GuiErrorBase() - { - super(null, null); - } - - private String translateOrDefault(String translateKey, String alternative, Object... format) - { - return I18n.hasKey(translateKey) ? I18n.format(translateKey, format) : String.format(alternative, format); //When throwing a DuplicateModsException, the translation system does not work... - } - - @Override - public void initGui() - { - super.initGui(); - this.buttons.clear(); - this.buttons.add(new GuiButton(10, 50, this.height - 38, this.width / 2 - 55, 20, translateOrDefault("fml.button.open.mods.folder", "Open Mods Folder")) - { - public void onClick(double mouseX, double mouseY) - { - try - { - File modsDir = new File(minecraftDir, "mods"); - Desktop.getDesktop().open(modsDir); - } - catch (Exception e) - { - LOGGER.error("Problem opening mods folder", e); - } - } - }); - String openFileText = translateOrDefault("fml.button.open.file", "Open %s", logFile.getName()); - this.buttons.add(new GuiButton(11, this.width / 2 + 5, this.height - 38, this.width / 2 - 55, 20, openFileText) - { - public void onClick(double mouseX, double mouseY) - { - try - { - Desktop.getDesktop().open(logFile); - } - catch (Exception e) - { - LOGGER.error("Problem opening log file {}", logFile, e); - } - } - }); - } - - @Override - public void render(int mouseX, int mouseY, float partialTicks) - { - for (GuiButton button : buttons) - { - button.render(mouseX, mouseY, partialTicks); - } - } -} diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiModList.java b/src/main/java/net/minecraftforge/fml/client/gui/GuiModList.java index 18cd7509e..4be0b37e3 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiModList.java +++ b/src/main/java/net/minecraftforge/fml/client/gui/GuiModList.java @@ -19,21 +19,6 @@ package net.minecraftforge.fml.client.gui; -import java.awt.Dimension; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map.Entry; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.stream.Collectors; - -import javax.annotation.Nullable; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; @@ -43,26 +28,22 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.GuiUtilRenderComponents; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.ResourcePackInfoClient; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.fml.ForgeI18n; +import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.VersionChecker; import net.minecraftforge.fml.client.ConfigGuiHandler; import net.minecraftforge.fml.client.ResourcePackLoader; -import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.common.versioning.ComparableVersion; - -import static net.minecraft.util.StringUtils.stripControlCodes; - import net.minecraftforge.fml.language.IModInfo; import net.minecraftforge.fml.loading.StringUtils; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; @@ -70,6 +51,21 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import javax.annotation.Nullable; +import java.awt.Dimension; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map.Entry; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static net.minecraft.util.StringUtils.stripControlCodes; + /** * @author cpw * @@ -142,6 +138,7 @@ public class GuiModList extends GuiScreen private boolean sorted = false; private SortType sortType = SortType.NORMAL; + /** * @param mainMenu */ @@ -152,7 +149,7 @@ public class GuiModList extends GuiScreen this.unsortedMods = Collections.unmodifiableList(this.mods); } - class InfoPanel extends GuiListExtended { + class InfoPanel extends GuiListExtended { InfoPanel(Minecraft mcIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn) { super(mcIn, widthIn, heightIn, topIn, bottomIn, slotHeightIn); @@ -161,7 +158,12 @@ public class GuiModList extends GuiScreen @Override protected int getScrollBarX() { - return this.width - 6; + return this.right - 6; + } + + @Override + public int getListWidth() { + return this.width; } void setInfo(Info info) @@ -174,6 +176,113 @@ public class GuiModList extends GuiScreen { this.clearEntries(); } + class Info extends GuiListExtended.IGuiListEntry + { + private ResourceLocation logoPath; + private Dimension logoDims; + private List lines; + + public Info(GuiListExtended parent, List lines, @Nullable ResourceLocation logoPath, Dimension logoDims) + { + this.list = parent; + this.lines = resizeContent(lines); + this.logoPath = logoPath; + this.logoDims = logoDims; + } + + private List resizeContent(List lines) + { + List ret = new ArrayList(); + for (String line : lines) + { + if (line == null) + { + ret.add(null); + continue; + } + + ITextComponent chat = ForgeHooks.newChatWithLinks(line, false); + int maxTextLength = InfoPanel.this.width - 8; + if (maxTextLength >= 0) + { + ret.addAll(GuiUtilRenderComponents.splitText(chat, maxTextLength, GuiModList.this.fontRenderer, false, true)); + } + } + return ret; + } + + + @Override + public void drawEntry(int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks) + { + int top = this.getY(); + int left = this.getX(); + + if (logoPath != null) { + mc.getTextureManager().bindTexture(logoPath); + GlStateManager.enableBlend(); + GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); + Gui.drawModalRectWithCustomSizedTexture(left, top, 0.0F, 0.0F, logoDims.width, logoDims.height, logoDims.width, logoDims.height); + top += logoDims.height + 10; + } + + for (ITextComponent line : lines) + { + if (line != null) + { + GlStateManager.enableBlend(); + GuiModList.this.fontRenderer.drawStringWithShadow(line.getFormattedText(), left + 4, top, 0xFFFFFF); + GlStateManager.disableAlphaTest(); + GlStateManager.disableBlend(); + } + top += fontRenderer.FONT_HEIGHT; + } + + final ITextComponent component = findTextLine(mouseX, mouseY, 0, 0); + if (component!=null) { + GuiModList.this.handleComponentHover(component, mouseX, mouseY); + } + } + + private ITextComponent findTextLine(final int mouseX, final int mouseY, final int offX, final int offY) { + int offset = mouseY - offY; + if (logoPath != null) { + offset -= logoDims.height + 10; + } + if (offset <= 0) + return null; + + int lineIdx = offset / fontRenderer.FONT_HEIGHT; + if (lineIdx >= lines.size() || lineIdx < 1) + return null; + + ITextComponent line = lines.get(lineIdx-1); + if (line != null) + { + int k = offX; + for (ITextComponent part : line) { + if (!(part instanceof TextComponentString)) + continue; + k += GuiModList.this.fontRenderer.getStringWidth(((TextComponentString)part).getText()); + if (k >= mouseX) + { + return part; + } + } + } + return null; + } + + @Override + public boolean mouseClicked(final double mouseX, final double mouseY, final int buttonmask) { + final ITextComponent component = findTextLine((int) mouseX, (int) mouseY, InfoPanel.this.left, InfoPanel.this.top); + if (component != null) { + GuiModList.this.handleComponentClick(component); + return true; + } + return false; + } + } } @Override public void initGui() @@ -184,34 +293,26 @@ public class GuiModList extends GuiScreen listWidth = Math.max(listWidth,getFontRenderer().getStringWidth(mod.getVersion().getVersionString()) + 5); } listWidth = Math.min(listWidth, 150); + listWidth += listWidth % numButtons != 0 ? (numButtons - listWidth % numButtons) : 0; this.modList = new GuiSlotModList(this, listWidth); this.modList.setSlotXBoundsFromLeft(6); - this.modInfo = new InfoPanel(this.mc, this.width - this.listWidth - 30, this.height, 32, this.height - 88 + 4, 1); - this.modInfo.setSlotXBoundsFromLeft(this.listWidth + 24); + this.modInfo = new InfoPanel(this.mc, this.width - this.listWidth - 20, this.height, 10, this.height - 30, this.height - 46); + this.modInfo.setSlotXBoundsFromLeft(this.listWidth + 14); - this.addButton(new GuiButton(6, ((modList.right + this.width) / 2) - 100, this.height - 38, I18n.format("gui.done")){ - @Override - public void onClick(double mouseX, double mouseY) - { - GuiModList.this.mc.displayGuiScreen(GuiModList.this.mainMenu); - } - }); - this.addButton(this.configButton = new GuiButton(20, 10, this.height - 49, this.listWidth, 20, I18n.format("fml.menu.mods.config")){ - @Override - public void onClick(double mouseX, double mouseY) - { - GuiModList.this.displayModConfig(); - } - }); + this.addButton(new GuiButtonClickConsumer(6, ((modList.right + this.width) / 2) - 100, this.height - 24, + I18n.format("gui.done"), (x, y) -> GuiModList.this.mc.displayGuiScreen(GuiModList.this.mainMenu))); + this.addButton(this.configButton = new GuiButtonClickConsumer(20, 6, this.height - 24, this.listWidth, 20, + I18n.format("fml.menu.mods.config"), (x,y)-> GuiModList.this.displayModConfig())); - search = new GuiTextField(0, getFontRenderer(), 12, modList.bottom + 17, modList.width - 4, 14); + search = new GuiTextField(0, getFontRenderer(), 8, modList.bottom + 17, listWidth - 4, 14); children.add(search); children.add(modList); + children.add(modInfo); search.setFocused(true); search.setCanLoseFocus(true); - final int width = (modList.width / numButtons); - int x = 10, y = 10; + final int width = listWidth / numButtons; + int x = 6, y = 10; addButton(SortType.NORMAL.button = new SortButton(SortType.NORMAL.buttonID, x, y, width - buttonMargin, 20, SortType.NORMAL)); x += width + buttonMargin; addButton(SortType.A_TO_Z.button = new SortButton(SortType.NORMAL.buttonID, x, y, width - buttonMargin, 20, SortType.A_TO_Z)); @@ -285,12 +386,12 @@ public class GuiModList extends GuiScreen this.modInfo.drawScreen(mouseX, mouseY, partialTicks); int left = ((this.width - this.listWidth - 38) / 2) + this.listWidth + 30; - super.render(mouseX, mouseY, partialTicks); String text = I18n.format("fml.menu.mods.search"); int x = ((10 + modList.right) / 2) - (getFontRenderer().getStringWidth(text) / 2); getFontRenderer().drawString(text, x, modList.bottom + 5, 0xFFFFFF); this.search.drawTextField(mouseX, mouseY, partialTicks); + super.render(mouseX, mouseY, partialTicks); } Minecraft getMinecraftInstance() @@ -339,7 +440,7 @@ public class GuiModList extends GuiScreen try { NativeImage logo = null; - InputStream logoResource = getClass().getResourceAsStream(logoFile); + InputStream logoResource = pack.getResourcePack().getRootResourceStream(logoFile); if (logoResource != null) logo = NativeImage.read(logoResource); if (logo != null) @@ -352,23 +453,23 @@ public class GuiModList extends GuiScreen }).orElse(Pair.of(null, new Dimension(0, 0))); lines.add(selectedMod.getDisplayName()); - lines.add(String.format("Version: %s", selectedMod.getVersion().getVersionString())); - lines.add(String.format("Mod ID: '%s' Mod State: %s", selectedMod.getModId(), ModList.get().getModContainerById(selectedMod.getModId()). + lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.version", selectedMod.getVersion().getVersionString())); + lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.idstate", selectedMod.getModId(), ModList.get().getModContainerById(selectedMod.getModId()). map(ModContainer::getCurrentState).map(Object::toString).orElse("NONE"))); selectedMod.getModConfig().getOptional("credits").ifPresent(credits-> - lines.add("Credits: " + credits)); + lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.credits", credits))); selectedMod.getModConfig().getOptional("authors").ifPresent(authors -> - lines.add("Authors: " + authors)); + lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.authors", authors))); selectedMod.getModConfig().getOptional("displayURL").ifPresent(displayURL -> - lines.add("URL: " + displayURL)); + lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.displayurl", displayURL))); if (selectedMod.getOwningFile() == null || selectedMod.getOwningFile().getMods().size()==1) - lines.add("No child mods for this mod"); + lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.nochildmods")); else - lines.add("Child mods: " + selectedMod.getOwningFile().getMods().stream().map(IModInfo::getDisplayName).collect(Collectors.joining(","))); + lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.childmods", selectedMod.getOwningFile().getMods().stream().map(IModInfo::getDisplayName).collect(Collectors.joining(",")))); if (vercheck.status == VersionChecker.Status.OUTDATED || vercheck.status == VersionChecker.Status.BETA_OUTDATED) - lines.add("Update Available: " + (vercheck.url == null ? "" : vercheck.url)); + lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.updateavailable", vercheck.url == null ? "" : vercheck.url)); lines.add(null); lines.add(selectedMod.getDescription()); @@ -376,7 +477,7 @@ public class GuiModList extends GuiScreen if ((vercheck.status == VersionChecker.Status.OUTDATED || vercheck.status == VersionChecker.Status.BETA_OUTDATED) && vercheck.changes.size() > 0) { lines.add(null); - lines.add("Changes:"); + lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.changelogheader")); for (Entry entry : vercheck.changes.entrySet()) { lines.add(" " + entry.getKey() + ":"); @@ -385,84 +486,6 @@ public class GuiModList extends GuiScreen } } - modInfo.setInfo(new Info(modInfo, lines, logoData.getLeft(), logoData.getRight())); - } - - class Info extends GuiListExtended.IGuiListEntry - { - private ResourceLocation logoPath; - private Dimension logoDims; - private List lines = null; - - public Info(GuiListExtended parent, List lines, @Nullable ResourceLocation logoPath, Dimension logoDims) - { - this.list = parent; - this.lines = resizeContent(lines); - this.logoPath = logoPath; - this.logoDims = logoDims; - } - - private List resizeContent(List lines) - { - List ret = new ArrayList(); - for (String line : lines) - { - if (line == null) - { - ret.add(null); - continue; - } - -// ITextComponent chat = ForgeHooks.newChatWithLinks(line, false); - ITextComponent chat = new TextComponentString(line); - int maxTextLength = this.getX() - 8; - if (maxTextLength >= 0) - { - ret.addAll(GuiUtilRenderComponents.splitText(chat, maxTextLength, GuiModList.this.fontRenderer, false, true)); - } - } - return ret; - } - - - @Override - public void drawEntry(int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks) - { - int top = this.getY(); - int left = this.getX(); -/* - int top = this. - - if (logoPath != null) - { - GlStateManager.enableBlend(); - GuiModList.this.mc.renderEngine.bindTexture(logoPath); - GlStateManager.draw - BufferBuilder wr = tess.getBuffer(); - int offset = (this.left + this.listWidth/2) - (logoDims.width / 2); - wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - wr.pos(offset, top + logoDims.height, zLevel).tex(0, 1).endVertex(); - wr.pos(offset + logoDims.width, top + logoDims.height, zLevel).tex(1, 1).endVertex(); - wr.pos(offset + logoDims.width, top, zLevel).tex(1, 0).endVertex(); - wr.pos(offset, top, zLevel).tex(0, 0).endVertex(); - tess.draw(); - GlStateManager.disableBlend(); - top += logoDims.height + 10; - } - -*/ - for (ITextComponent line : lines) - { - if (line != null) - { - GlStateManager.enableBlend(); - GuiModList.this.fontRenderer.drawStringWithShadow(line.getFormattedText(), left + 4, top, 0xFFFFFF); - GlStateManager.disableAlphaTest(); - GlStateManager.disableBlend(); - } - top += fontRenderer.FONT_HEIGHT + 1; - } - - } + modInfo.setInfo(modInfo.new Info(modInfo, lines, logoData.getLeft(), logoData.getRight())); } } diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiModsMissing.java b/src/main/java/net/minecraftforge/fml/client/gui/GuiModsMissing.java deleted file mode 100644 index 34cf8d3dd..000000000 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiModsMissing.java +++ /dev/null @@ -1,94 +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.client.gui; - -import java.util.List; -import java.util.Optional; - -import net.minecraft.client.resources.I18n; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.ModContainer; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.common.MissingModsException; -import net.minecraftforge.fml.common.versioning.ArtifactVersion; -import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; - -@OnlyIn(Dist.CLIENT) -public class GuiModsMissing extends GuiErrorBase -{ - private MissingModsException modsMissing; - - public GuiModsMissing(MissingModsException modsMissing) - { - this.modsMissing = modsMissing; - } - - @Override - public void render(int mouseX, int mouseY, float partialTicks) - { - this.drawDefaultBackground(); - List missingModsVersions = modsMissing.getMissingModInfos(); - int offset = Math.max(85 - missingModsVersions.size() * 10, 10); - String modMissingDependenciesText = I18n.format("fml.messages.mod.missing.dependencies.compatibility", TextFormatting.BOLD + modsMissing.getModName() + TextFormatting.RESET); - this.drawCenteredString(this.fontRenderer, modMissingDependenciesText, this.width / 2, offset, 0xFFFFFF); - offset += 5; - for (MissingModsException.MissingModInfo versionInfo : missingModsVersions) - { - ArtifactVersion acceptedVersion = versionInfo.getAcceptedVersion(); - String acceptedModId = acceptedVersion.getLabel(); - ArtifactVersion currentVersion = versionInfo.getCurrentVersion(); - String missingReason; - if (currentVersion == null) - { - missingReason = I18n.format("fml.messages.mod.missing.dependencies.missing"); - } - else - { - missingReason = I18n.format("fml.messages.mod.missing.dependencies.you.have", currentVersion.getVersionString()); - } - String acceptedModVersionString = acceptedVersion.getRangeString(); - if (acceptedVersion instanceof DefaultArtifactVersion) - { - DefaultArtifactVersion dav = (DefaultArtifactVersion) acceptedVersion; - if (dav.getRange() != null) - { - acceptedModVersionString = dav.getRange().toStringFriendly(); - } - } - Optional acceptedMod = ModList.get().getModContainerById(acceptedModId); - String acceptedModName = acceptedMod.map((mod) -> mod.getModInfo().getDisplayName()).orElse(acceptedModId); - String versionInfoText = String.format(TextFormatting.BOLD + "%s " + TextFormatting.RESET + "%s (%s)", acceptedModName, acceptedModVersionString, missingReason); - String message; - if (versionInfo.isRequired()) - { - message = I18n.format("fml.messages.mod.missing.dependencies.requires", versionInfoText); - } - else - { - message = I18n.format("fml.messages.mod.missing.dependencies.compatible.with", versionInfoText); - } - offset += 10; - this.drawCenteredString(this.fontRenderer, message, this.width / 2, offset, 0xEEEEEE); - } - super.render(mouseX, mouseY, partialTicks); - } -} diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiModsMissingForServer.java b/src/main/java/net/minecraftforge/fml/client/gui/GuiModsMissingForServer.java deleted file mode 100644 index bbc1b5083..000000000 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiModsMissingForServer.java +++ /dev/null @@ -1,71 +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.client.gui; - -import java.util.List; - -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.resources.I18n; -import net.minecraftforge.fml.common.MissingModsException; -import net.minecraftforge.fml.common.versioning.ArtifactVersion; - -public class GuiModsMissingForServer extends GuiScreen -{ - private MissingModsException modsMissing; - - public GuiModsMissingForServer(MissingModsException modsMissing) - { - this.modsMissing = modsMissing; - } - - @Override - public void initGui() - { - this.buttons.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done")) - { - public void onClick(double mouseX, double mouseY) - { - GuiModsMissingForServer.this.mc.displayGuiScreen(null); - } - }); - } - - @Override - public void render(int mouseX, int mouseY, float partialTicks) - { - this.drawDefaultBackground(); - List missingModsVersions = modsMissing.getMissingModInfos(); - int offset = Math.max(85 - missingModsVersions.size() * 10, 10); - this.drawCenteredString(this.fontRenderer, "Forge Mod Loader could not connect to this server", this.width / 2, offset, 0xFFFFFF); - offset += 10; - this.drawCenteredString(this.fontRenderer, "The mods and versions listed below could not be found", this.width / 2, offset, 0xFFFFFF); - offset += 10; - this.drawCenteredString(this.fontRenderer, "They are required to play on this server", this.width / 2, offset, 0xFFFFFF); - offset += 5; - for (MissingModsException.MissingModInfo info : missingModsVersions) - { - ArtifactVersion v = info.getAcceptedVersion(); - offset += 10; - this.drawCenteredString(this.fontRenderer, String.format("%s : %s", v.getLabel(), v.getRangeString()), this.width / 2, offset, 0xEEEEEE); - } - super.render(mouseX, mouseY, partialTicks); - } -} diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiMultipleModsErrored.java b/src/main/java/net/minecraftforge/fml/client/gui/GuiMultipleModsErrored.java deleted file mode 100644 index 6fec893a8..000000000 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiMultipleModsErrored.java +++ /dev/null @@ -1,170 +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.client.gui; - -import java.util.List; -import java.util.Optional; - -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.ModContainer; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.common.MissingModsException; -import net.minecraftforge.fml.common.MultipleModsErrored; -import net.minecraftforge.fml.common.versioning.ArtifactVersion; -import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; - -@OnlyIn(Dist.CLIENT) -public class GuiMultipleModsErrored extends GuiErrorBase -{ - private final List missingModsExceptions; - private GuiList list; - - public GuiMultipleModsErrored(MultipleModsErrored exception) - { - missingModsExceptions = exception.missingModsExceptions; - } - - @Override - public void initGui() - { - super.initGui(); - int additionalSize = missingModsExceptions.isEmpty() ? 20 : 55; - for (MissingModsException exception : missingModsExceptions) - { - additionalSize += exception.getMissingModInfos().size() * 10; - } - list = new GuiList(missingModsExceptions.size() * 15 + additionalSize); - } - - @Override - public void render(int mouseX, int mouseY, float partialTicks) - { - this.drawDefaultBackground(); - this.list.drawScreen(mouseX, mouseY, partialTicks); - String missingMultipleModsText = I18n.format("fml.messages.mod.missing.multiple", missingModsExceptions.size()); - this.drawCenteredString(this.fontRenderer, missingMultipleModsText, this.width / 2, 10, 0xFFFFFF); - super.render(mouseX, mouseY, partialTicks); - } - - @Override - public boolean mouseScrolled(double scroll) - { - return this.list.mouseScrolled(scroll); - } - - private class GuiList extends GuiScrollingList - { - public GuiList(int entryHeight) - { - super(GuiMultipleModsErrored.this.mc, - GuiMultipleModsErrored.this.width - 20, - GuiMultipleModsErrored.this.height - 30, - 30, GuiMultipleModsErrored.this.height - 50, - 10, - entryHeight, - GuiMultipleModsErrored.this.width, - GuiMultipleModsErrored.this.height); - } - - @Override - protected int getSize() - { - return 1; - } - - @Override - protected void elementClicked(int index, boolean doubleClick) - { - } - - @Override - protected boolean isSelected(int index) - { - return false; - } - - @Override - protected void drawBackground() - { - drawDefaultBackground(); - } - - @Override - protected void drawSlot(int slotIdx, int entryRight, int slotTop, int slotBuffer, Tessellator tess) - { - int offset = slotTop; - FontRenderer renderer = GuiMultipleModsErrored.this.fontRenderer; - if (!missingModsExceptions.isEmpty()) - { - renderer.drawString(I18n.format("fml.messages.mod.missing.dependencies.multiple.issues"), this.left, offset, 0xFFFFFF); - offset += 15; - for (MissingModsException exception : missingModsExceptions) - { - renderer.drawString(exception.getModName() + ":", this.left, offset, 0xFFFFFF); - for (MissingModsException.MissingModInfo versionInfo : exception.getMissingModInfos()) - { - ArtifactVersion acceptedVersion = versionInfo.getAcceptedVersion(); - String acceptedModId = acceptedVersion.getLabel(); - ArtifactVersion currentVersion = versionInfo.getCurrentVersion(); - String missingReason; - if (currentVersion == null) - { - missingReason = I18n.format("fml.messages.mod.missing.dependencies.missing"); - } - else - { - missingReason = I18n.format("fml.messages.mod.missing.dependencies.you.have", currentVersion.getVersionString()); - } - String acceptedModVersionString = acceptedVersion.getRangeString(); - if (acceptedVersion instanceof DefaultArtifactVersion) - { - DefaultArtifactVersion dav = (DefaultArtifactVersion) acceptedVersion; - if (dav.getRange() != null) - { - acceptedModVersionString = dav.getRange().toStringFriendly(); - } - } - Optional acceptedMod = ModList.get().getModContainerById(acceptedModId); - String acceptedModName = acceptedMod.map((mod) -> mod.getModInfo().getDisplayName()).orElse(acceptedModId); - String versionInfoText = String.format(TextFormatting.BOLD + "%s " + TextFormatting.RESET + "%s (%s)", acceptedModName, acceptedModVersionString, missingReason); - String message; - if (versionInfo.isRequired()) - { - message = I18n.format("fml.messages.mod.missing.dependencies.requires", versionInfoText); - } - else - { - message = I18n.format("fml.messages.mod.missing.dependencies.compatible.with", versionInfoText); - } - offset += 10; - renderer.drawString(message, this.left, offset, 0xEEEEEE); - } - - offset += 15; - } - } - } - } -} diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiScrollingList.java b/src/main/java/net/minecraftforge/fml/client/gui/GuiScrollingList.java deleted file mode 100644 index 7841c017f..000000000 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiScrollingList.java +++ /dev/null @@ -1,378 +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.client.gui; - -import net.minecraft.client.MainWindow; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.client.config.GuiUtils; -import org.lwjgl.opengl.GL11; - -@OnlyIn(Dist.CLIENT) -public abstract class GuiScrollingList -{ - private final Minecraft client; - protected final int listWidth; - protected final int listHeight; - protected final int screenWidth; - protected final int screenHeight; - protected final int top; - protected final int bottom; - protected final int right; - protected final int left; - protected final int slotHeight; - protected int mouseX; - protected int mouseY; - private float initialMouseClickY = -2.0F; - private float scrollFactor; - private float scrollDistance; - protected int selectedIndex = -1; - private long lastClickTime = 0L; - private boolean highlightSelected = true; - private boolean hasHeader; - private int headerHeight; - - @Deprecated // We need to know screen size. - public GuiScrollingList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight) - { - this(client, width, height, top, bottom, left, entryHeight, width, height); - } - - public GuiScrollingList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight, int screenWidth, int screenHeight) - { - this.client = client; - this.listWidth = width; - this.listHeight = height; - this.top = top; - this.bottom = bottom; - this.slotHeight = entryHeight; - this.left = left; - this.right = width + this.left; - this.screenWidth = screenWidth; - this.screenHeight = screenHeight; - } - - protected void setHeaderInfo(boolean hasHeader, int headerHeight) - { - this.hasHeader = hasHeader; - this.headerHeight = headerHeight; - if (!hasHeader) this.headerHeight = 0; - } - - protected void setHighlightSelected(boolean highlightSelected) - { - this.highlightSelected = highlightSelected; - } - - protected abstract int getSize(); - - protected abstract void elementClicked(int index, boolean doubleClick); - - protected abstract boolean isSelected(int index); - - protected int getContentHeight() - { - return this.getSize() * this.slotHeight + this.headerHeight; - } - - protected abstract void drawBackground(); - - /** - * Draw anything special on the screen. GL_SCISSOR is enabled for anything that - * is rendered outside of the view box. Do not mess with SCISSOR unless you support this. - */ - protected abstract void drawSlot(int slotIdx, int entryRight, int slotTop, int slotBuffer, Tessellator tess); - - /** - * Draw anything special on the screen. GL_SCISSOR is enabled for anything that - * is rendered outside of the view box. Do not mess with SCISSOR unless you support this. - */ - protected void drawHeader(int entryRight, int relativeY, Tessellator tess) - { - } - - protected void clickHeader(int x, int y) - { - } - - /** - * Draw anything special on the screen. GL_SCISSOR is enabled for anything that - * is rendered outside of the view box. Do not mess with SCISSOR unless you support this. - */ - protected void drawScreen(int mouseX, int mouseY) - { - } - - private void applyScrollLimits() - { - int listHeight = this.getContentHeight() - (this.bottom - this.top - 4); - - if (listHeight < 0) - { - listHeight /= 2; - } - - if (this.scrollDistance < 0.0F) - { - this.scrollDistance = 0.0F; - } - - if (this.scrollDistance > (float) listHeight) - { - this.scrollDistance = (float) listHeight; - } - } - - /** - * Scroll up a fixed amount, used for button callbacks. - */ - public void scrollUp() - { - this.scrollDistance -= (float) (this.slotHeight * 2 / 3); - this.initialMouseClickY = -2.0F; - this.applyScrollLimits(); - } - - /** - * Scroll down a fixed amount, used for button callbacks. - */ - public void scrollDown() - { - this.scrollDistance += (float) (this.slotHeight * 2 / 3); - this.initialMouseClickY = -2.0F; - this.applyScrollLimits(); - } - - private boolean isHovering() - { - return mouseX >= this.left && mouseX <= this.left + this.listWidth && - mouseY >= this.top && mouseY <= this.bottom; - } - - public boolean mouseScrolled(double scroll) - { - if (this.isHovering() && scroll != 0) - { - this.scrollDistance += (float) ((-1 * scroll / 120.0F) * this.slotHeight / 2); - return true; - } - return false; - } - - public void drawScreen(int mouseX, int mouseY, float partialTicks) - { - this.mouseX = mouseX; - this.mouseY = mouseY; - this.drawBackground(); - - boolean isHovering = this.isHovering(); - int listLength = this.getSize(); - int scrollBarWidth = 6; - int scrollBarRight = this.left + this.listWidth; - int scrollBarLeft = scrollBarRight - scrollBarWidth; - int entryLeft = this.left; - int entryRight = scrollBarLeft - 1; - int viewHeight = this.bottom - this.top; - int border = 4; - - Minecraft minecraft = Minecraft.getInstance(); - if (minecraft.mouseHelper.isLeftDown()) - { - if (this.initialMouseClickY == -1.0F) - { - if (isHovering) - { - int mouseListY = mouseY - this.top - this.headerHeight + (int) this.scrollDistance - border; - int slotIndex = mouseListY / this.slotHeight; - - if (mouseX >= entryLeft && mouseX <= entryRight && slotIndex >= 0 && mouseListY >= 0 && slotIndex < listLength) - { - this.elementClicked(slotIndex, slotIndex == this.selectedIndex && System.currentTimeMillis() - this.lastClickTime < 250L); - this.selectedIndex = slotIndex; - this.lastClickTime = System.currentTimeMillis(); - } - else if (mouseX >= entryLeft && mouseX <= entryRight && mouseListY < 0) - { - this.clickHeader(mouseX - entryLeft, mouseY - this.top + (int) this.scrollDistance - border); - } - - if (mouseX >= scrollBarLeft && mouseX <= scrollBarRight) - { - this.scrollFactor = -1.0F; - int scrollHeight = this.getContentHeight() - viewHeight - border; - if (scrollHeight < 1) scrollHeight = 1; - - int var13 = (int) ((float) (viewHeight * viewHeight) / (float) this.getContentHeight()); - - if (var13 < 32) var13 = 32; - if (var13 > viewHeight - border * 2) - var13 = viewHeight - border * 2; - - this.scrollFactor /= (float) (viewHeight - var13) / (float) scrollHeight; - } - else - { - this.scrollFactor = 1.0F; - } - - this.initialMouseClickY = mouseY; - } - else - { - this.initialMouseClickY = -2.0F; - } - } - else if (this.initialMouseClickY >= 0.0F) - { - this.scrollDistance -= ((float) mouseY - this.initialMouseClickY) * this.scrollFactor; - this.initialMouseClickY = (float) mouseY; - } - } - else - { - this.initialMouseClickY = -1.0F; - } - - this.applyScrollLimits(); - - Tessellator tess = Tessellator.getInstance(); - BufferBuilder worldr = tess.getBuffer(); - - MainWindow window = client.mainWindow; - double scaleW = window.getScaledWidth(); - double scaleH = window.getScaledHeight(); - GL11.glEnable(GL11.GL_SCISSOR_TEST); - GL11.glScissor((int) (left * scaleW), (int) (window.getScaledWidth() - (bottom * scaleH)), - (int) (listWidth * scaleW), (int) (viewHeight * scaleH)); - - if (this.client.world != null) - { - this.drawGradientRect(this.left, this.top, this.right, this.bottom, 0xC0101010, 0xD0101010); - } - else // Draw dark dirt background - { - GlStateManager.disableLighting(); - GlStateManager.disableFog(); - this.client.textureManager.bindTexture(Gui.OPTIONS_BACKGROUND); - GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); - final float scale = 32.0F; - worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - worldr.pos(this.left, this.bottom, 0.0D).tex(this.left / scale, (this.bottom + (int) this.scrollDistance) / scale).color(0x20, 0x20, 0x20, 0xFF).endVertex(); - worldr.pos(this.right, this.bottom, 0.0D).tex(this.right / scale, (this.bottom + (int) this.scrollDistance) / scale).color(0x20, 0x20, 0x20, 0xFF).endVertex(); - worldr.pos(this.right, this.top, 0.0D).tex(this.right / scale, (this.top + (int) this.scrollDistance) / scale).color(0x20, 0x20, 0x20, 0xFF).endVertex(); - worldr.pos(this.left, this.top, 0.0D).tex(this.left / scale, (this.top + (int) this.scrollDistance) / scale).color(0x20, 0x20, 0x20, 0xFF).endVertex(); - tess.draw(); - } - - int baseY = this.top + border - (int) this.scrollDistance; - - if (this.hasHeader) - { - this.drawHeader(entryRight, baseY, tess); - } - - for (int slotIdx = 0; slotIdx < listLength; ++slotIdx) - { - int slotTop = baseY + slotIdx * this.slotHeight + this.headerHeight; - int slotBuffer = this.slotHeight - border; - - if (slotTop <= this.bottom && slotTop + slotBuffer >= this.top) - { - if (this.highlightSelected && this.isSelected(slotIdx)) - { - int min = this.left; - int max = entryRight; - GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.disableTexture2D(); - worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - worldr.pos(min, slotTop + slotBuffer + 2, 0).tex(0, 1).color(0x80, 0x80, 0x80, 0xFF).endVertex(); - worldr.pos(max, slotTop + slotBuffer + 2, 0).tex(1, 1).color(0x80, 0x80, 0x80, 0xFF).endVertex(); - worldr.pos(max, slotTop - 2, 0).tex(1, 0).color(0x80, 0x80, 0x80, 0xFF).endVertex(); - worldr.pos(min, slotTop - 2, 0).tex(0, 0).color(0x80, 0x80, 0x80, 0xFF).endVertex(); - worldr.pos(min + 1, slotTop + slotBuffer + 1, 0).tex(0, 1).color(0x00, 0x00, 0x00, 0xFF).endVertex(); - worldr.pos(max - 1, slotTop + slotBuffer + 1, 0).tex(1, 1).color(0x00, 0x00, 0x00, 0xFF).endVertex(); - worldr.pos(max - 1, slotTop - 1, 0).tex(1, 0).color(0x00, 0x00, 0x00, 0xFF).endVertex(); - worldr.pos(min + 1, slotTop - 1, 0).tex(0, 0).color(0x00, 0x00, 0x00, 0xFF).endVertex(); - tess.draw(); - GlStateManager.enableTexture2D(); - } - - this.drawSlot(slotIdx, entryRight, slotTop, slotBuffer, tess); - } - } - - GlStateManager.disableDepthTest(); - - int extraHeight = (this.getContentHeight() + border) - viewHeight; - if (extraHeight > 0) - { - int height = (viewHeight * viewHeight) / this.getContentHeight(); - - if (height < 32) height = 32; - - if (height > viewHeight - border * 2) - height = viewHeight - border * 2; - - int barTop = (int) this.scrollDistance * (viewHeight - height) / extraHeight + this.top; - if (barTop < this.top) - { - barTop = this.top; - } - - GlStateManager.disableTexture2D(); - worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - worldr.pos(scrollBarLeft, this.bottom, 0.0D).tex(0.0D, 1.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex(); - worldr.pos(scrollBarRight, this.bottom, 0.0D).tex(1.0D, 1.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex(); - worldr.pos(scrollBarRight, this.top, 0.0D).tex(1.0D, 0.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex(); - worldr.pos(scrollBarLeft, this.top, 0.0D).tex(0.0D, 0.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex(); - tess.draw(); - worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - worldr.pos(scrollBarLeft, barTop + height, 0.0D).tex(0.0D, 1.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex(); - worldr.pos(scrollBarRight, barTop + height, 0.0D).tex(1.0D, 1.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex(); - worldr.pos(scrollBarRight, barTop, 0.0D).tex(1.0D, 0.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex(); - worldr.pos(scrollBarLeft, barTop, 0.0D).tex(0.0D, 0.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex(); - tess.draw(); - worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - worldr.pos(scrollBarLeft, barTop + height - 1, 0.0D).tex(0.0D, 1.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); - worldr.pos(scrollBarRight - 1, barTop + height - 1, 0.0D).tex(1.0D, 1.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); - worldr.pos(scrollBarRight - 1, barTop, 0.0D).tex(1.0D, 0.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); - worldr.pos(scrollBarLeft, barTop, 0.0D).tex(0.0D, 0.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); - tess.draw(); - } - - this.drawScreen(mouseX, mouseY); - GlStateManager.enableTexture2D(); - GlStateManager.shadeModel(GL11.GL_FLAT); - GlStateManager.enableAlphaTest(); - GlStateManager.disableBlend(); - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } - - protected void drawGradientRect(int left, int top, int right, int bottom, int color1, int color2) - { - GuiUtils.drawGradientRect(0, left, top, right, bottom, color1, color2); - } -} diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiSlotModList.java b/src/main/java/net/minecraftforge/fml/client/gui/GuiSlotModList.java index f1b620747..db92165ac 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiSlotModList.java +++ b/src/main/java/net/minecraftforge/fml/client/gui/GuiSlotModList.java @@ -47,7 +47,7 @@ public class GuiSlotModList extends GuiListExtended public GuiSlotModList(GuiModList parent, int listWidth) { - super(parent.getMinecraftInstance(), listWidth, parent.height, 32, parent.height - 88 + 4, parent.getFontRenderer().FONT_HEIGHT * 2 + 8); + super(parent.getMinecraftInstance(), listWidth, parent.height, 32, parent.height - 67 + 4, parent.getFontRenderer().FONT_HEIGHT * 2 + 8); this.parent = parent; this.listWidth = listWidth; this.refreshList(); @@ -56,7 +56,7 @@ public class GuiSlotModList extends GuiListExtended @Override protected int getScrollBarX() { - return this.listWidth + 6; + return this.listWidth; } @Override diff --git a/src/main/java/net/minecraftforge/fml/client/gui/LoadingErrorScreen.java b/src/main/java/net/minecraftforge/fml/client/gui/LoadingErrorScreen.java index 65086ef3a..9519c7697 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/LoadingErrorScreen.java +++ b/src/main/java/net/minecraftforge/fml/client/gui/LoadingErrorScreen.java @@ -122,7 +122,7 @@ public class LoadingErrorScreen extends GuiErrorScreen { final List strings = font.listFormattedStringToWidth(error.formatToString(), LoadingErrorList.this.width); float f = (float)top + 2; for (int i = 0; i < Math.min(strings.size(), 2); i++) { - font.drawString(strings.get(i), left + 5, f, 0xFFFFFFFF); + font.drawString(strings.get(i), left + 5, f, 0xFFFFFF); f += font.FONT_HEIGHT; } } diff --git a/src/main/java/net/minecraftforge/fml/common/DuplicateModsFoundException.java b/src/main/java/net/minecraftforge/fml/common/DuplicateModsFoundException.java deleted file mode 100644 index 23a67267e..000000000 --- a/src/main/java/net/minecraftforge/fml/common/DuplicateModsFoundException.java +++ /dev/null @@ -1,41 +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.common; - -import java.io.File; -import java.util.Map.Entry; - -import com.google.common.collect.SetMultimap; -import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.ModContainer; -import net.minecraftforge.fml.client.IDisplayableError; -import net.minecraftforge.fml.client.gui.GuiDupesFound; - -public class DuplicateModsFoundException extends LoaderException -{ - private static final long serialVersionUID = 1L; - public SetMultimap dupes; - - public DuplicateModsFoundException(SetMultimap dupes) { - this.dupes = dupes; - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/MissingModsException.java b/src/main/java/net/minecraftforge/fml/common/MissingModsException.java deleted file mode 100644 index e78186b01..000000000 --- a/src/main/java/net/minecraftforge/fml/common/MissingModsException.java +++ /dev/null @@ -1,131 +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.common; - -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import com.google.common.base.Preconditions; -import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.client.gui.GuiModsMissing; -import net.minecraftforge.fml.client.IDisplayableError; -import net.minecraftforge.fml.common.versioning.ArtifactVersion; - -import net.minecraftforge.fml.common.EnhancedRuntimeException.WrappedPrintStream; - -public class MissingModsException extends EnhancedRuntimeException implements IDisplayableError -{ - private static final long serialVersionUID = 1L; - private final String id; - private final String name; - private final List missingModsInfos; - private final String modName; - - public MissingModsException(String id, String name) - { - this.id = id; - this.name = name; - this.missingModsInfos = new ArrayList<>(); - this.modName = name; - } - - @Override - public String getMessage() - { - Set missingMods = missingModsInfos.stream().map(MissingModInfo::getAcceptedVersion).collect(Collectors.toSet()); - return String.format("Mod %s (%s) requires %s", id, name, missingMods); - } - - public void addMissingMod(ArtifactVersion acceptedVersion, @Nullable ArtifactVersion currentVersion, boolean required) - { - MissingModInfo missingModInfo = new MissingModInfo(acceptedVersion, currentVersion, required); - this.missingModsInfos.add(missingModInfo); - } - - public String getModName() - { - return modName; - } - - public List getMissingModInfos() - { - return Collections.unmodifiableList(this.missingModsInfos); - } - - @Override - protected void printStackTrace(WrappedPrintStream stream) - { - stream.println("Missing Mods:"); - for (MissingModInfo info : this.missingModsInfos) - { - ArtifactVersion acceptedVersion = info.getAcceptedVersion(); - ArtifactVersion currentVersion = info.getCurrentVersion(); - String currentString = currentVersion != null ? currentVersion.getVersionString() : "missing"; - stream.println(String.format("\t%s : need %s: have %s", acceptedVersion.getVersionString(), acceptedVersion.getRangeString(), currentString)); - } - stream.println(""); - } - - @Override - @OnlyIn(Dist.CLIENT) - public GuiScreen createGui() - { - return new GuiModsMissing(this); - } - - public static class MissingModInfo - { - private final ArtifactVersion acceptedVersion; - @Nullable - private final ArtifactVersion currentVersion; - private final boolean required; - - private MissingModInfo(ArtifactVersion acceptedVersion, @Nullable ArtifactVersion currentVersion, boolean required) - { - Preconditions.checkNotNull(acceptedVersion, "acceptedVersion"); - this.acceptedVersion = acceptedVersion; - this.currentVersion = currentVersion; - this.required = required; - } - - @Nullable - public ArtifactVersion getCurrentVersion() - { - return currentVersion; - } - - public ArtifactVersion getAcceptedVersion() - { - return acceptedVersion; - } - - public boolean isRequired() - { - return required; - } - } - -} diff --git a/src/main/java/net/minecraftforge/fml/common/MultipleModsErrored.java b/src/main/java/net/minecraftforge/fml/common/MultipleModsErrored.java deleted file mode 100644 index b39ff2a4f..000000000 --- a/src/main/java/net/minecraftforge/fml/common/MultipleModsErrored.java +++ /dev/null @@ -1,55 +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.common; - -import java.util.List; - -import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.client.IDisplayableError; -import net.minecraftforge.fml.client.gui.GuiMultipleModsErrored; - -import net.minecraftforge.fml.common.EnhancedRuntimeException.WrappedPrintStream; - -public class MultipleModsErrored extends EnhancedRuntimeException implements IDisplayableError -{ - public final List missingModsExceptions; - public MultipleModsErrored(List missingModsExceptions) - { - this.missingModsExceptions = missingModsExceptions; - } - - @Override - @OnlyIn(Dist.CLIENT) - public GuiScreen createGui() - { - return new GuiMultipleModsErrored(this); - } - - @Override - protected void printStackTrace(WrappedPrintStream stream) - { - for (MissingModsException missingModsException : this.missingModsExceptions) - { - missingModsException.printStackTrace(stream); - } - } -} diff --git a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java index 0230f021f..d36f51904 100644 --- a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java +++ b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java @@ -87,7 +87,6 @@ public class FMLModContainer extends ModContainer private void onEventFailed(IEventBus iEventBus, Event event, IEventListener[] iEventListeners, int i, Throwable throwable) { LOGGER.error(new EventBusErrorMessage(event, i, iEventListeners, throwable)); - } private void beforeEvent(LifecycleEventProvider.LifecycleEvent lifecycleEvent) { @@ -97,11 +96,11 @@ public class FMLModContainer extends ModContainer private void fireEvent(LifecycleEventProvider.LifecycleEvent lifecycleEvent) { final ModLifecycleEvent event = lifecycleEvent.buildModEvent(this); - LOGGER.debug(LOADING, "Firing event for modid {} : {} @ {}", this.getModId(), event, System.identityHashCode(event.getClass())); + LOGGER.debug(LOADING, "Firing event for modid {} : {}", this.getModId(), event.getClass().getName()); try { eventBus.post(event); - LOGGER.debug(LOADING, "Fired event for modid {} : {}", this.getModId(), event); + LOGGER.debug(LOADING, "Fired event for modid {} : {}", this.getModId(), event.getClass().getName()); } catch (Throwable e) { diff --git a/src/main/java/net/minecraftforge/fml/loading/FMLClientLaunchProvider.java b/src/main/java/net/minecraftforge/fml/loading/FMLClientLaunchProvider.java index 503a0d01c..0d1bce691 100644 --- a/src/main/java/net/minecraftforge/fml/loading/FMLClientLaunchProvider.java +++ b/src/main/java/net/minecraftforge/fml/loading/FMLClientLaunchProvider.java @@ -19,9 +19,11 @@ package net.minecraftforge.fml.loading; +import cpw.mods.modlauncher.api.IEnvironment; import cpw.mods.modlauncher.api.ILaunchHandlerService; import cpw.mods.modlauncher.api.ITransformingClassLoader; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.common.ForgeVersion; import java.net.URISyntaxException; import java.nio.file.Path; @@ -44,7 +46,7 @@ public class FMLClientLaunchProvider extends FMLCommonLaunchHandler implements I static { try { forgePath = Paths.get(FMLClientLaunchProvider.class.getProtectionDomain().getCodeSource().getLocation().toURI()); - mcPath = forgePath.resolveSibling("minecraft.jar"); + mcPath = forgePath.resolveSibling("forge-"+ForgeVersion.getVersion()+"-srg.jar"); } catch (URISyntaxException e) { throw new RuntimeException("Unable to locate myself!"); } @@ -72,6 +74,10 @@ public class FMLClientLaunchProvider extends FMLCommonLaunchHandler implements I }; } + @Override + public void setup(final IEnvironment environment) { + } + @Override public Dist getDist() { diff --git a/src/main/java/net/minecraftforge/fml/loading/ModSorter.java b/src/main/java/net/minecraftforge/fml/loading/ModSorter.java index 60d7366f9..bcab6d780 100644 --- a/src/main/java/net/minecraftforge/fml/loading/ModSorter.java +++ b/src/main/java/net/minecraftforge/fml/loading/ModSorter.java @@ -20,7 +20,6 @@ package net.minecraftforge.fml.loading; import net.minecraftforge.fml.Java9BackportUtils; -import net.minecraftforge.fml.common.DuplicateModsFoundException; import net.minecraftforge.fml.common.toposort.TopologicalSort; import net.minecraftforge.fml.common.versioning.ArtifactVersion; import net.minecraftforge.fml.language.IModInfo; diff --git a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java index 403c6c33d..0a3f42e4d 100644 --- a/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java +++ b/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModInfo.java @@ -105,7 +105,7 @@ public class ModInfo implements IModInfo public Optional getLogoFile() { - return this.owningFile != null ? this.owningFile.getConfig().getOptional("logoFile") : Optional.empty(); + return this.owningFile != null ? this.owningFile.getConfig().getOptional("logoFile") : this.modConfig.getOptional("logoFile"); } public boolean hasConfigUI() diff --git a/src/main/resources/assets/forge/lang/en_us.json b/src/main/resources/assets/forge/lang/en_us.json index c6794fbfb..d17462553 100644 --- a/src/main/resources/assets/forge/lang/en_us.json +++ b/src/main/resources/assets/forge/lang/en_us.json @@ -6,6 +6,15 @@ "fml.menu.mods.z_to_a": "Z-A", "fml.menu.mods.config": "Config", "fml.menu.modoptions": "Mod Options...", + "fml.menu.mods.info.version":"Version: {0}", + "fml.menu.mods.info.idstate":"ModID: {0} State:{1,lower}", + "fml.menu.mods.info.credits":"Credits: {0}", + "fml.menu.mods.info.authors":"Authors: {0}", + "fml.menu.mods.info.displayurl":"Homepage: {0}", + "fml.menu.mods.info.nochildmods":"No child mods found", + "fml.menu.mods.info.childmods":"Child mods: {0}", + "fml.menu.mods.info.updateavailable":"Update available: {0}", + "fml.menu.mods.info.changelogheader":"Changelog:", "fml.menu.loadingmods": "{0,choice,0#No mods|1#1 mod|1<{0} mods} loaded", "fml.button.open.file": "Open {0}", "fml.button.open.mods.folder": "Open Mods Folder", diff --git a/src/main/resources/forgemod.toml b/src/main/resources/forgemod.toml index ad1ece3f8..a478beb19 100644 --- a/src/main/resources/forgemod.toml +++ b/src/main/resources/forgemod.toml @@ -1,6 +1,8 @@ modId="forge" version="${global.forgeVersion}" displayName="Forge" +logoFile="forge_logo.png" +displayURL="https://files.minecraftforge.net/" description=''' Forge, the magic ''' \ No newline at end of file