Fixup the config GUI and get things working again.

This commit is contained in:
cpw 2018-09-29 01:29:35 -04:00
parent b54bd33332
commit 015ac2547e
23 changed files with 204 additions and 1384 deletions

View File

@ -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)
}

View File

@ -93,6 +93,7 @@ public abstract class ModContainer
try
{
triggerMap.getOrDefault(modLoadingStage, e->{}).accept(event);
modLoadingStage = event.toStage();
}
catch (ModLoadingException e)
{

View File

@ -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.
*
* <br/><em>Warning: Minecraft is in a deep error state.</em> <strong>All</strong> 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);
}
}

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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<ModContainer, File> 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);
}
}

View File

@ -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);
}
}
}

View File

@ -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<Info> {
class InfoPanel extends GuiListExtended<InfoPanel.Info> {
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<Info>
{
private ResourceLocation logoPath;
private Dimension logoDims;
private List<ITextComponent> lines;
public Info(GuiListExtended<Info> parent, List<String> lines, @Nullable ResourceLocation logoPath, Dimension logoDims)
{
this.list = parent;
this.lines = resizeContent(lines);
this.logoPath = logoPath;
this.logoDims = logoDims;
}
private List<ITextComponent> resizeContent(List<String> lines)
{
List<ITextComponent> ret = new ArrayList<ITextComponent>();
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<ComparableVersion, String> 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<Info>
{
private ResourceLocation logoPath;
private Dimension logoDims;
private List<ITextComponent> lines = null;
public Info(GuiListExtended<Info> parent, List<String> lines, @Nullable ResourceLocation logoPath, Dimension logoDims)
{
this.list = parent;
this.lines = resizeContent(lines);
this.logoPath = logoPath;
this.logoDims = logoDims;
}
private List<ITextComponent> resizeContent(List<String> lines)
{
List<ITextComponent> ret = new ArrayList<ITextComponent>();
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()));
}
}

View File

@ -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<MissingModsException.MissingModInfo> 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<? extends ModContainer> 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);
}
}

View File

@ -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<MissingModsException.MissingModInfo> 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);
}
}

View File

@ -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<MissingModsException> 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<? extends ModContainer> 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;
}
}
}
}
}

View File

@ -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);
}
}

View File

@ -47,7 +47,7 @@ public class GuiSlotModList extends GuiListExtended<GuiSlotModList.ModEntry>
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<GuiSlotModList.ModEntry>
@Override
protected int getScrollBarX()
{
return this.listWidth + 6;
return this.listWidth;
}
@Override

View File

@ -122,7 +122,7 @@ public class LoadingErrorScreen extends GuiErrorScreen {
final List<String> 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;
}
}

View File

@ -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<ModContainer, File> dupes;
public DuplicateModsFoundException(SetMultimap<ModContainer, File> dupes) {
this.dupes = dupes;
}
}

View File

@ -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<MissingModInfo> 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<ArtifactVersion> 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<MissingModInfo> 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;
}
}
}

View File

@ -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<MissingModsException> missingModsExceptions;
public MultipleModsErrored(List<MissingModsException> 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);
}
}
}

View File

@ -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)
{

View File

@ -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()
{

View File

@ -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;

View File

@ -105,7 +105,7 @@ public class ModInfo implements IModInfo
public Optional<String> 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()

View File

@ -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",

View File

@ -1,6 +1,8 @@
modId="forge"
version="${global.forgeVersion}"
displayName="Forge"
logoFile="forge_logo.png"
displayURL="https://files.minecraftforge.net/"
description='''
Forge, the magic
'''