Update to 1.14.2

This commit is contained in:
LexManos authored and cpw committed 2019-06-07 16:50:47 -04:00
1 parent d3e8804dbf
commit a7df63e1a1
1010 files changed
+15254 -19520

No files matched your search

@@ -34,9 +34,9 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
import com.google.common.collect.Table;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiMultiplayer;
import net.minecraft.client.gui.GuiWorldSelection;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.screen.MultiplayerScreen;
import net.minecraft.client.gui.screen.WorldSelectionScreen;
import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.ForgeI18n;
import net.minecraftforge.fml.ModList;
@@ -55,10 +55,10 @@ import com.google.common.base.Strings;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.ServerStatusResponse;
import net.minecraft.resources.AbstractResourcePack;
import net.minecraft.resources.ResourcePack;
import net.minecraft.resources.FallbackResourceManager;
import net.minecraft.resources.IResourcePack;
import net.minecraft.resources.SimpleReloadableResourceManager;
@@ -127,7 +127,7 @@ public class ClientHooks
}
public static void drawForgePingInfo(GuiMultiplayer gui, ServerData target, int x, int y, int width, int relativeMouseX, int relativeMouseY) {
public static void drawForgePingInfo(MultiplayerScreen gui, ServerData target, int x, int y, int width, int relativeMouseX, int relativeMouseY) {
int idx;
String tooltip;
if (target.forgeData == null)
@@ -162,7 +162,7 @@ public class ClientHooks
}
Minecraft.getInstance().getTextureManager().bindTexture(iconSheet);
Gui.drawModalRectWithCustomSizedTexture(x + width - 18, y + 10, 0, (float)idx, 16, 16, 256.0f, 256.0f);
AbstractGui.blit(x + width - 18, y + 10, 16, 16, 0, idx, 16, 16, 256, 256);
if(relativeMouseX > width - 15 && relativeMouseX < width && relativeMouseY > 10 && relativeMouseY < 26)
gui.setHoveringText(tooltip);
@@ -179,7 +179,7 @@ public class ClientHooks
return new File(Minecraft.getInstance().gameDir, "saves");
}
public static void tryLoadExistingWorld(GuiWorldSelection selectWorldGUI, WorldSummary comparator)
public static void tryLoadExistingWorld(WorldSelectionScreen selectWorldGUI, WorldSummary comparator)
{
try
{
@@ -196,7 +196,7 @@ public class ClientHooks
return Minecraft.getInstance().getConnection()!=null ? Minecraft.getInstance().getConnection().getNetworkManager() : null;
}
public static void handleClientWorldClosing(WorldClient world)
public static void handleClientWorldClosing(ClientWorld world)
{
NetworkManager client = getClientToServerNetworkManager();
// ONLY revert a non-local connection
@@ -268,9 +268,9 @@ public class ClientHooks
List<IModInfo> mods = modRP.getModFile().getModInfos();
logger.error(" mod(s) {} resources at {}", mods.stream().map(IModInfo::getDisplayName).collect(Collectors.toList()), modRP.getModFile().getFilePath());
}
else if (resPack instanceof AbstractResourcePack)
else if (resPack instanceof ResourcePack)
{
logger.error(" resource pack at path {}", ((AbstractResourcePack)resPack).file.getPath());
logger.error(" resource pack at path {}", ((ResourcePack)resPack).file.getPath());
}
else
{
@@ -20,9 +20,8 @@
package net.minecraftforge.fml.client;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.DownloadingPackFinder;
import net.minecraft.client.resources.ResourcePackInfoClient;
import net.minecraft.client.resources.ClientResourcePackInfo;
import net.minecraft.resources.IReloadableResourceManager;
import net.minecraft.resources.ResourcePackList;
import net.minecraftforge.api.distmarker.Dist;
@@ -40,6 +39,8 @@ import net.minecraftforge.fml.packs.ResourcePackLoader;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.mojang.blaze3d.platform.GlStateManager;
import java.util.Collections;
import java.util.List;
@@ -53,7 +54,7 @@ public class ClientModLoader
private static Minecraft mc;
private static LoadingFailedException error;
public static void begin(final Minecraft minecraft, final ResourcePackList<ResourcePackInfoClient> defaultResourcePacks, final IReloadableResourceManager mcResourceManager, DownloadingPackFinder metadataSerializer)
public static void begin(final Minecraft minecraft, final ResourcePackList<ClientResourcePackInfo> defaultResourcePacks, final IReloadableResourceManager mcResourceManager, DownloadingPackFinder metadataSerializer)
{
loading = true;
ClientModLoader.mc = minecraft;
@@ -87,8 +88,8 @@ public class ClientModLoader
public static void complete()
{
GlStateManager.disableTexture2D();
GlStateManager.enableTexture2D();
GlStateManager.disableTexture();
GlStateManager.enableTexture();
List<ModLoadingWarning> warnings = ModLoader.get().getWarnings();
boolean showWarnings = true;
try {
@@ -20,7 +20,7 @@
package net.minecraftforge.fml.client;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
@@ -30,7 +30,7 @@ import java.util.function.BiFunction;
public class ConfigGuiHandler
{
public static Optional<BiFunction<Minecraft, GuiScreen, GuiScreen>> getGuiFactoryFor(ModInfo selectedMod)
public static Optional<BiFunction<Minecraft, Screen, Screen>> getGuiFactoryFor(ModInfo selectedMod)
{
return ModList.get().getModContainerById(selectedMod.getModId()).
flatMap(mc -> mc.getCustomExtension(ExtensionPoint.CONFIGGUIFACTORY));
@@ -19,12 +19,12 @@
package net.minecraftforge.fml.client;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface IDisplayableError
{
@OnlyIn(Dist.CLIENT)
GuiScreen createGui();
Screen createGui();
}
@@ -21,7 +21,7 @@ package net.minecraftforge.fml.client;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.screen.Screen;
/**
* This is the interface you need to implement if you want to provide a customized config screen.
@@ -62,7 +62,7 @@ public interface IModGuiFactory {
* @return A class that will be instantiated on clicks on the config button
* or null if no GUI is desired.
*/
GuiScreen createConfigGui(GuiScreen parentScreen);
Screen createConfigGui(Screen parentScreen);
/**
* Return a list of the "runtime" categories this mod wishes to populate with
@@ -20,7 +20,8 @@
package net.minecraftforge.fml.client.config;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.widget.button.Button;
/**
* This class provides a button that fixes several bugs present in the vanilla GuiButton drawing code.
@@ -32,54 +33,24 @@ import net.minecraft.client.gui.GuiButton;
*
* @author bspkrs
*/
public class GuiButtonExt extends GuiButton
public class GuiButtonExt extends Button
{
public GuiButtonExt(int id, int xPos, int yPos, String displayString)
public GuiButtonExt(int xPos, int yPos, int width, int height, String displayString, IPressable handler)
{
super(id, xPos, yPos, displayString);
}
public GuiButtonExt(int id, int xPos, int yPos, int width, int height, String displayString)
{
super(id, xPos, yPos, width, height, displayString);
super(xPos, yPos, width, height, displayString, handler);
}
/**
* Draws this button to the screen.
*/
@Override
public void render(int mouseX, int mouseY, float partial)
public void renderButton(int mouseX, int mouseY, float partial)
{
if (this.visible)
{
Minecraft mc = Minecraft.getInstance();
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int k = this.getHoverState(this.hovered);
GuiUtils.drawContinuousTexturedBox(BUTTON_TEXTURES, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.zLevel);
this.renderBg(mc, mouseX, mouseY);
int color = 14737632;
if (packedFGColor != 0)
{
color = packedFGColor;
}
else if (!this.enabled)
{
color = 10526880;
}
else if (this.hovered)
{
color = 16777120;
}
String buttonText = this.displayString;
int strWidth = mc.fontRenderer.getStringWidth(buttonText);
int ellipsisWidth = mc.fontRenderer.getStringWidth("...");
if (strWidth > width - 6 && strWidth > ellipsisWidth)
buttonText = mc.fontRenderer.trimStringToWidth(buttonText, width - 6 - ellipsisWidth).trim() + "...";
this.drawCenteredString(mc.fontRenderer, buttonText, this.x + this.width / 2, this.y + (this.height - 8) / 2, color);
}
super.renderButton(mouseX, mouseY, partial);
FontRenderer font = Minecraft.getInstance().fontRenderer;
int strWidth = font.getStringWidth(this.getMessage());
int ellipsisWidth = font.getStringWidth("...");
if (strWidth > width - 6 && strWidth > ellipsisWidth)
setMessage(font.trimStringToWidth(getMessage(), width - 6 - ellipsisWidth).trim() + "...");
}
}
@@ -20,56 +20,32 @@
package net.minecraftforge.fml.client.config;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.widget.button.Button;
/**
* This class provides a checkbox style control.
*
* @author bspkrs
*/
public class GuiCheckBox extends GuiButton
public class GuiCheckBox extends Button
{
private boolean isChecked;
private int boxWidth;
public GuiCheckBox(int id, int xPos, int yPos, String displayString, boolean isChecked)
public GuiCheckBox(int xPos, int yPos, String displayString, boolean isChecked)
{
super(id, xPos, yPos, displayString);
super(xPos, yPos, Minecraft.getInstance().fontRenderer.getStringWidth(displayString) + 2 + 11, 11, displayString, b -> {});
this.isChecked = isChecked;
this.boxWidth = 11;
this.height = 11;
this.width = this.boxWidth + 2 + Minecraft.getInstance().fontRenderer.getStringWidth(displayString);
}
@Override
public void render(int mouseX, int mouseY, float partial)
public void renderButton(int mouseX, int mouseY, float partial)
{
if (this.visible)
{
Minecraft mc = Minecraft.getInstance();
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.boxWidth && mouseY < this.y + this.height;
GuiUtils.drawContinuousTexturedBox(BUTTON_TEXTURES, this.x, this.y, 0, 46, this.boxWidth, this.height, 200, 20, 2, 3, 2, 2, this.zLevel);
this.renderBg(mc, mouseX, mouseY);
int color = 14737632;
if (packedFGColor != 0)
{
color = packedFGColor;
}
else if (!this.enabled)
{
color = 10526880;
}
if (this.isChecked)
this.drawCenteredString(mc.fontRenderer, "x", this.x + this.boxWidth / 2 + 1, this.y + 1, 14737632);
this.drawString(mc.fontRenderer, displayString, this.x + this.boxWidth + 2, this.y + 2, color);
}
super.renderButton(mouseX, mouseY, partial);
if (this.isChecked)
this.drawCenteredString(Minecraft.getInstance().fontRenderer, "x", this.x + this.boxWidth / 2 + 1, this.y + 1, 14737632);
}
@Override
public void onClick(double mouseX, double mouseY)
public void onPress()
{
this.isChecked = !this.isChecked;
}
@@ -19,27 +19,20 @@
package net.minecraftforge.fml.client.config;
import net.minecraft.client.gui.GuiDisconnected;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.screen.DisconnectedScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.ITextComponent;
import javax.annotation.Nullable;
public class GuiMessageDialog extends GuiDisconnected
public class GuiMessageDialog extends DisconnectedScreen
{
protected String buttonText;
public GuiMessageDialog(@Nullable GuiScreen nextScreen, String title, ITextComponent message, String buttonText)
public GuiMessageDialog(@Nullable Screen nextScreen, String title, ITextComponent message, String buttonText)
{
super(nextScreen, title, message);
this.buttonText = buttonText;
}
@Override
public void initGui()
{
super.initGui();
buttons.get(0).displayString = I18n.format(buttonText);
this.buttonText = I18n.format(buttonText);
}
}
@@ -50,14 +50,14 @@ public class GuiSlider extends GuiButtonExt
public boolean drawString = true;
public GuiSlider(int id, int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr)
public GuiSlider(int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, IPressable handler)
{
this(id, xPos, yPos, width, height, prefix, suf, minVal, maxVal, currentVal, showDec, drawStr, null);
this(xPos, yPos, width, height, prefix, suf, minVal, maxVal, currentVal, showDec, drawStr, handler, null);
}
public GuiSlider(int id, int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, @Nullable ISlider par)
public GuiSlider(int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, IPressable handler, @Nullable ISlider par)
{
super(id, xPos, yPos, width, height, prefix);
super(xPos, yPos, width, height, prefix, handler);
minValue = minVal;
maxValue = maxVal;
sliderValue = (currentVal - minValue) / (maxValue - minValue);
@@ -78,18 +78,16 @@ public class GuiSlider extends GuiButtonExt
precision = 0;
}
displayString = dispString + val + suffix;
setMessage(dispString + val + suffix);
drawString = drawStr;
if(!drawString)
{
displayString = "";
}
setMessage("");
}
public GuiSlider(int id, int xPos, int yPos, String displayStr, double minVal, double maxVal, double currentVal, ISlider par)
public GuiSlider(int xPos, int yPos, String displayStr, double minVal, double maxVal, double currentVal, IPressable handler, ISlider par)
{
this(id, xPos, yPos, 150, 20, displayStr, "", minVal, maxVal, currentVal, true, true, par);
this(xPos, yPos, 150, 20, displayStr, "", minVal, maxVal, currentVal, true, true, handler, par);
}
/**
@@ -97,7 +95,7 @@ public class GuiSlider extends GuiButtonExt
* this button.
*/
@Override
public int getHoverState(boolean par1)
public int getYImage(boolean par1)
{
return 0;
}
@@ -116,7 +114,7 @@ public class GuiSlider extends GuiButtonExt
updateSlider();
}
GuiUtils.drawContinuousTexturedBox(BUTTON_TEXTURES, this.x + (int)(this.sliderValue * (float)(this.width - 8)), this.y, 0, 66, 8, this.height, 200, 20, 2, 3, 2, 2, this.zLevel);
GuiUtils.drawContinuousTexturedBox(WIDGETS_LOCATION, this.x + (int)(this.sliderValue * (float)(this.width - 8)), this.y, 0, 66, 8, this.height, 200, 20, 2, 3, 2, 2, this.blitOffset);
}
}
@@ -174,7 +172,7 @@ public class GuiSlider extends GuiButtonExt
if(drawString)
{
displayString = dispString + val + suffix;
setMessage(dispString + val + suffix);
}
if (parent != null)
@@ -19,9 +19,10 @@
package net.minecraftforge.fml.client.config;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.gui.widget.button.Button;
/**
* This class provides a button that shows a string glyph at the beginning. The glyph can be scaled using the glyphScale parameter.
@@ -33,9 +34,9 @@ public class GuiUnicodeGlyphButton extends GuiButtonExt
public String glyph;
public float glyphScale;
public GuiUnicodeGlyphButton(int id, int xPos, int yPos, int width, int height, String displayString, String glyph, float glyphScale)
public GuiUnicodeGlyphButton(int xPos, int yPos, int width, int height, String displayString, String glyph, float glyphScale, IPressable handler)
{
super(id, xPos, yPos, width, height, displayString);
super(xPos, yPos, width, height, displayString, handler);
this.glyph = glyph;
this.glyphScale = glyphScale;
}
@@ -46,26 +47,12 @@ public class GuiUnicodeGlyphButton extends GuiButtonExt
if (this.visible)
{
Minecraft mc = Minecraft.getInstance();
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int k = this.getHoverState(this.hovered);
GuiUtils.drawContinuousTexturedBox(GuiButton.BUTTON_TEXTURES, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.zLevel);
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int k = this.getYImage(this.isHovered);
GuiUtils.drawContinuousTexturedBox(Button.WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.blitOffset);
this.renderBg(mc, mouseX, mouseY);
int color = 14737632;
if (packedFGColor != 0)
{
color = packedFGColor;
}
else if (!this.enabled)
{
color = 10526880;
}
else if (this.hovered)
{
color = 16777120;
}
String buttonText = this.displayString;
String buttonText = this.getMessage();
int glyphWidth = (int) (mc.fontRenderer.getStringWidth(glyph) * glyphScale);
int strWidth = mc.fontRenderer.getStringWidth(buttonText);
int ellipsisWidth = mc.fontRenderer.getStringWidth("...");
@@ -81,11 +68,11 @@ public class GuiUnicodeGlyphButton extends GuiButtonExt
GlStateManager.scalef(glyphScale, glyphScale, 1.0F);
this.drawCenteredString(mc.fontRenderer, glyph,
(int) (((this.x + (this.width / 2) - (strWidth / 2)) / glyphScale) - (glyphWidth / (2 * glyphScale)) + 2),
(int) (((this.y + ((this.height - 8) / glyphScale) / 2) - 1) / glyphScale), color);
(int) (((this.y + ((this.height - 8) / glyphScale) / 2) - 1) / glyphScale), getFGColor());
GlStateManager.popMatrix();
this.drawCenteredString(mc.fontRenderer, buttonText, (int) (this.x + (this.width / 2) + (glyphWidth / glyphScale)),
this.y + (this.height - 8) / 2, color);
this.y + (this.height - 8) / 2, getFGColor());
}
}
}
@@ -21,8 +21,7 @@ package net.minecraftforge.fml.client.config;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.BufferBuilder;
@@ -34,6 +33,8 @@ import net.minecraftforge.common.MinecraftForge;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.platform.GlStateManager;
import java.util.ArrayList;
import java.util.List;
@@ -427,7 +428,7 @@ public class GuiUtils
float endGreen = (float)(endColor >> 8 & 255) / 255.0F;
float endBlue = (float)(endColor & 255) / 255.0F;
GlStateManager.disableTexture2D();
GlStateManager.disableTexture();
GlStateManager.enableBlend();
GlStateManager.disableAlphaTest();
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
@@ -445,7 +446,7 @@ public class GuiUtils
GlStateManager.shadeModel(GL11.GL_FLAT);
GlStateManager.disableBlend();
GlStateManager.enableAlphaTest();
GlStateManager.enableTexture2D();
GlStateManager.enableTexture();
}
public static void drawInscribedRect(int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight)
@@ -465,6 +466,6 @@ public class GuiUtils
if (centerX) x += (w - boundsWidth) / 2;
}
Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, rectWidth, rectHeight, boundsWidth, boundsHeight, rectWidth, rectHeight);
AbstractGui.blit(x, y, 0, 0, rectWidth, rectHeight, boundsWidth, boundsHeight, rectWidth, rectHeight);
}
}
@@ -19,20 +19,20 @@
package net.minecraftforge.fml.client.config;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.widget.button.Button;
/**
* This class implements an easy way to check if the mouse has hovered within a certain region of the screen for a given
* This class implements an easy way to check if the mouse has hovered within a certain region of the screen for a given
* period of time. The region can be defined manually or by supplying a GuiButton object.
*
*
* @author bspkrs
*/
public class HoverChecker
{
private int top, bottom, left, right, threshold;
private GuiButton button;
private Button button;
private long hoverStart;
public HoverChecker(int top, int bottom, int left, int right, int threshold)
{
this.top = top;
@@ -42,13 +42,13 @@ public class HoverChecker
this.threshold = threshold;
this.hoverStart = -1;
}
public HoverChecker(GuiButton button, int threshold)
public HoverChecker(Button button, int threshold)
{
this.button = button;
this.threshold = threshold;
}
/**
* Call this method if the intended region has changed such as if the region must follow a scrolling list.
* It is not necessary to call this method if a GuiButton defines the hover region.
@@ -60,7 +60,7 @@ public class HoverChecker
this.left = left;
this.right = right;
}
/**
* Checks if the mouse is in the hover region. If the specified time period has elapsed the method returns true.
* The hover timer is reset if the mouse is not within the region.
@@ -79,20 +79,20 @@ public class HoverChecker
if (this.button != null)
{
this.top = button.y;
this.bottom = button.y + button.height;
this.bottom = button.y + button.getHeight();
this.left = button.x;
this.right = button.x + button.width;
this.right = button.x + button.getWidth();
canHover = canHover && button.visible;
}
if (canHover && hoverStart == -1 && mouseY >= top && mouseY <= bottom && mouseX >= left && mouseX <= right)
hoverStart = System.currentTimeMillis();
else if (!canHover || mouseY < top || mouseY > bottom || mouseX < left || mouseX > right)
resetHoverTimer();
return canHover && hoverStart != -1 && System.currentTimeMillis() - hoverStart >= threshold;
}
/**
* Manually resets the hover timer.
*/
@@ -19,8 +19,6 @@
package net.minecraftforge.fml.client.config;
import net.minecraft.client.gui.GuiTextField;
/**
* Provides an interface for defining GuiConfigEntry.listEntry objects.
*/
@@ -19,41 +19,39 @@
package net.minecraftforge.fml.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TranslationTextComponent;
public class GuiAccessDenied extends GuiScreen
public class GuiAccessDenied extends Screen
{
private GuiScreen parent;
private Screen parent;
private ServerData data;
public GuiAccessDenied(GuiScreen parent, ServerData data)
public GuiAccessDenied(Screen parent, ServerData data)
{
super(new TranslationTextComponent("fml.menu.accessdenied.title"));
this.parent = parent;
this.data = data;
}
@Override
public void initGui()
public void init()
{
this.buttons.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))
{
public void onClick(double mouseX, double mouseY)
{
GuiAccessDenied.this.mc.displayGuiScreen(parent);
}
});
this.buttons.add(new Button(this.width / 2 - 75, this.height - 38, 200, 20, I18n.format("gui.done"), b -> GuiAccessDenied.this.minecraft.displayGuiScreen(parent)));
}
@Override
public void render(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
int offset = Math.max(85 - 2 * 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, String.format("The server %s has forbidden modded access", data.serverName), this.width / 2, offset, 0xFFFFFF);
this.renderBackground();
String[] lines = I18n.format("fml.menu.accessdenied.message", data.serverName).split("\n");
int offset = Math.max(85 - lines.length * 10, 10);
for (String line : lines) {
this.drawCenteredString(this.font, line, this.width / 2, offset, 0xFFFFFF);
offset += 10;
}
super.render(mouseX, mouseY, partialTicks);
}
}
@@ -20,40 +20,38 @@
package net.minecraftforge.fml.client.gui;
import java.io.File;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TranslationTextComponent;
public class GuiBackupFailed extends GuiScreen
public class GuiBackupFailed extends Screen
{
private GuiScreen parent;
private Screen parent;
private File zipName;
public GuiBackupFailed(GuiScreen parent, File zipName)
public GuiBackupFailed(Screen parent, File zipName)
{
super(new TranslationTextComponent("fml.menu.backupfailed.title"));
this.parent = parent;
this.zipName = zipName;
}
@Override
public void initGui()
public void init()
{
this.buttons.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))
{
public void onClick(double mouseX, double mouseY)
{
GuiBackupFailed.this.mc.displayGuiScreen(parent);
}
});
this.buttons.add(new Button(this.width / 2 - 75, this.height - 38, 200, 20, I18n.format("gui.done"), b -> GuiBackupFailed.this.minecraft.displayGuiScreen(parent)));
}
@Override
public void render(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
int offset = Math.max(85 - 2 * 10, 10);
this.drawCenteredString(this.fontRenderer, String.format("There was an error saving the archive %s", zipName.getName()), this.width / 2, offset, 0xFFFFFF);
offset += 10;
this.drawCenteredString(this.fontRenderer, String.format("Please fix the problem and try again"), this.width / 2, offset, 0xFFFFFF);
this.renderBackground();
String[] lines = I18n.format("fml.menu.backupfailed.message", zipName.getName()).split("\n");
int offset = Math.max(85 - lines.length * 10, 10);
for (String line : lines) {
this.drawCenteredString(this.font, line, this.width / 2, offset, 0xFFFFFF);
offset += 10;
}
super.render(mouseX, mouseY, partialTicks);
}
}
@@ -1,43 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* 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.GuiButton;
public class GuiButtonClickConsumer extends GuiButton {
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 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;
}
@Override
public void onClick(final double mouseX, final double mouseY) {
onClickAction.applyAsDouble(mouseX, mouseY);
}
}
@@ -18,6 +18,7 @@
*/
package net.minecraftforge.fml.client.gui;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraftforge.fml.ForgeI18n;
import net.minecraftforge.fml.StartupQuery;
@@ -29,18 +30,18 @@ public class GuiConfirmation extends GuiNotification
}
@Override
public void initGui()
public void init()
{
this.addButton(new GuiButtonClickConsumer(0, this.width / 2 - 104, this.height - 38, 100, 20, ForgeI18n.parseMessage("gui.yes"),(x, y)->
this.addButton(new Button(this.width / 2 - 104, this.height - 38, 100, 20, ForgeI18n.parseMessage("gui.yes"), b ->
{
GuiConfirmation.this.mc.currentScreen = null;
GuiConfirmation.this.minecraft.currentScreen = null;
query.setResult(true);
query.finish();
}
));
this.addButton(new GuiButtonClickConsumer(1, this.width / 2 + 4, this.height - 38, 100, 20, ForgeI18n.parseMessage("gui.no"), (x,y)->
this.addButton(new Button(this.width / 2 + 4, this.height - 38, 100, 20, ForgeI18n.parseMessage("gui.no"), b ->
{
GuiConfirmation.this.mc.currentScreen = null;
GuiConfirmation.this.minecraft.currentScreen = null;
query.setResult(false);
query.finish();
}
@@ -39,15 +39,16 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.maven.artifact.versioning.ComparableVersion;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiListExtended;
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.gui.widget.button.Button;
import net.minecraft.client.gui.widget.list.ExtendedList;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.gui.RenderComponentsUtil;
import net.minecraft.client.renderer.Rectangle2d;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.NativeImage;
@@ -55,7 +56,8 @@ import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.util.Size2i;
import net.minecraftforge.fml.ForgeI18n;
@@ -71,32 +73,19 @@ import net.minecraftforge.fml.packs.ModFileResourcePack;
import net.minecraftforge.fml.packs.ResourcePackLoader;
import net.minecraftforge.forgespi.language.IModInfo;
/**
* @author cpw
*
*/
public class GuiModList extends GuiScreen
public class GuiModList extends Screen
{
private static final Logger LOGGER = LogManager.getLogger();
private enum SortType implements Comparator<ModInfo>
{
NORMAL(24),
A_TO_Z(25){ @Override protected int compare(String name1, String name2){ return name1.compareTo(name2); }},
Z_TO_A(26){ @Override protected int compare(String name1, String name2){ return name2.compareTo(name1); }};
NORMAL,
A_TO_Z{ @Override protected int compare(String name1, String name2){ return name1.compareTo(name2); }},
Z_TO_A{ @Override protected int compare(String name1, String name2){ return name2.compareTo(name1); }};
GuiButton button;
private int buttonID;
private SortType(int buttonID)
{
this.buttonID = buttonID;
}
Button button;
protected int compare(String name1, String name2){ return 0; }
@Override
public int compare(ModInfo o1, ModInfo o2)
{
public int compare(ModInfo o1, ModInfo o2) {
String name1 = StringUtils.toLowerCase(stripControlCodes(o1.getDisplayName()));
String name2 = StringUtils.toLowerCase(stripControlCodes(o2.getDisplayName()));
return compare(name1, name2);
@@ -105,41 +94,23 @@ public class GuiModList extends GuiScreen
String getButtonText() {
return I18n.format("fml.menu.mods."+StringUtils.toLowerCase(name()));
}
}
private class SortButton extends GuiButton {
private final SortType type;
public SortButton(int buttonId, int x, int y, int width, int height, SortType type)
{
super(buttonId, x, y, width, height, type.getButtonText());
this.type = type;
}
@Override
public void onClick(double mouseX, double mouseY)
{
GuiModList.this.sortType = this.type;
resortMods();
}
}
private GuiScreen mainMenu;
private Screen mainMenu;
private GuiSlotModList modList;
private InfoPanel modInfo;
private int selected = -1;
private ModInfo selectedMod;
private GuiSlotModList.ModEntry selected = null;
private int listWidth;
private List<ModInfo> mods;
private final List<ModInfo> unsortedMods;
private GuiButton configButton;
private Button configButton;
private int buttonMargin = 1;
private int numButtons = SortType.values().length;
private String lastFilterText = "";
private GuiTextField search;
private TextFieldWidget search;
private boolean sorted = false;
private SortType sortType = SortType.NORMAL;
@@ -147,27 +118,28 @@ public class GuiModList extends GuiScreen
/**
* @param mainMenu
*/
public GuiModList(GuiScreen mainMenu)
public GuiModList(Screen mainMenu)
{
super(new TranslationTextComponent("fml.menu.mods.title"));
this.mainMenu = mainMenu;
this.mods = Collections.unmodifiableList(ModList.get().getMods());
this.unsortedMods = Collections.unmodifiableList(this.mods);
}
class InfoPanel extends GuiListExtended<InfoPanel.Info> {
class InfoPanel extends ExtendedList<InfoPanel.Info> {
InfoPanel(Minecraft mcIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn)
{
super(mcIn, widthIn, heightIn, topIn, bottomIn, slotHeightIn);
}
@Override
protected int getScrollBarX()
protected int getScrollbarPosition()
{
return this.right - 6;
return this.getRight() - 6;
}
@Override
public int getListWidth() {
public int getRowWidth() {
return this.width;
}
@@ -181,13 +153,13 @@ public class GuiModList extends GuiScreen
{
this.clearEntries();
}
class Info extends GuiListExtended.IGuiListEntry<Info>
class Info extends ExtendedList.AbstractListEntry<Info>
{
private ResourceLocation logoPath;
private Size2i logoDims;
private List<ITextComponent> lines;
public Info(GuiListExtended<Info> parent, List<String> lines, @Nullable ResourceLocation logoPath, Size2i logoDims)
public Info(ExtendedList<Info> parent, List<String> lines, @Nullable ResourceLocation logoPath, Size2i logoDims)
{
this.list = parent;
this.lines = resizeContent(lines);
@@ -210,20 +182,17 @@ public class GuiModList extends GuiScreen
int maxTextLength = InfoPanel.this.width - 8;
if (maxTextLength >= 0)
{
ret.addAll(GuiUtilRenderComponents.splitText(chat, maxTextLength, GuiModList.this.fontRenderer, false, true));
ret.addAll(RenderComponentsUtil.splitText(chat, maxTextLength, GuiModList.this.font, false, true));
}
}
return ret;
}
@Override
public void drawEntry(int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks)
public void render(int entryIdx, int top, int left, 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);
Minecraft.getInstance().getTextureManager().bindTexture(logoPath);
GlStateManager.enableBlend();
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
// Draw the logo image inscribed in a rectangle with width entryWidth (minus some padding) and height 50
@@ -237,16 +206,16 @@ public class GuiModList extends GuiScreen
if (line != null)
{
GlStateManager.enableBlend();
GuiModList.this.fontRenderer.drawStringWithShadow(line.getFormattedText(), left + 4, top, 0xFFFFFF);
GuiModList.this.font.drawStringWithShadow(line.getFormattedText(), left + 4, top, 0xFFFFFF);
GlStateManager.disableAlphaTest();
GlStateManager.disableBlend();
}
top += fontRenderer.FONT_HEIGHT;
top += font.FONT_HEIGHT;
}
final ITextComponent component = findTextLine(mouseX, mouseY, 0, 0);
if (component!=null) {
GuiModList.this.handleComponentHover(component, mouseX, mouseY);
GuiModList.this.renderComponentHoverEffect(component, mouseX, mouseY);
}
}
@@ -258,7 +227,7 @@ public class GuiModList extends GuiScreen
if (offset <= 0)
return null;
int lineIdx = offset / fontRenderer.FONT_HEIGHT;
int lineIdx = offset / font.FONT_HEIGHT;
if (lineIdx >= lines.size() || lineIdx < 1)
return null;
@@ -267,9 +236,9 @@ public class GuiModList extends GuiScreen
{
int k = offX;
for (ITextComponent part : line) {
if (!(part instanceof TextComponentString))
if (!(part instanceof StringTextComponent))
continue;
k += GuiModList.this.fontRenderer.getStringWidth(((TextComponentString)part).getText());
k += GuiModList.this.font.getStringWidth(((StringTextComponent)part).getText());
if (k >= mouseX)
{
return part;
@@ -281,9 +250,9 @@ public class GuiModList extends GuiScreen
@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);
final ITextComponent component = findTextLine((int) mouseX, (int) mouseY, InfoPanel.this.getLeft(), InfoPanel.this.getTop());
if (component != null) {
GuiModList.this.handleComponentClick(component);
GuiModList.this.handleComponentClicked(component);
return true;
}
return false;
@@ -291,7 +260,7 @@ public class GuiModList extends GuiScreen
}
}
@Override
public void initGui()
public void init()
{
for (ModInfo mod : mods)
{
@@ -301,16 +270,16 @@ public class GuiModList extends GuiScreen
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 - 20, this.height, 10, this.height - 30, this.height - 46);
this.modInfo.setSlotXBoundsFromLeft(this.listWidth + 14);
this.modList.setLeftPos(6);
this.modInfo = new InfoPanel(this.minecraft, this.width - this.listWidth - 20, this.height, 10, this.height - 30, this.height - 46);
this.modInfo.setLeftPos(this.listWidth + 14);
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()));
this.addButton(new Button(((modList.getRight() + this.width) / 2) - 100, this.height - 24, 200, 20,
I18n.format("gui.done"), b -> GuiModList.this.minecraft.displayGuiScreen(GuiModList.this.mainMenu)));
this.addButton(this.configButton = new Button(6, this.height - 24, this.listWidth, 20,
I18n.format("fml.menu.mods.config"), b -> GuiModList.this.displayModConfig()));
search = new GuiTextField(0, getFontRenderer(), 8, modList.bottom + 17, listWidth - 4, 14);
search = new TextFieldWidget(getFontRenderer(), 8, modList.getBottom() + 17, listWidth - 4, 14, I18n.format("fml.menu.mods.search"));
children.add(search);
children.add(modList);
children.add(modInfo);
@@ -319,25 +288,25 @@ public class GuiModList extends GuiScreen
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));
addButton(SortType.NORMAL.button = new Button(x, y, width - buttonMargin, 20, SortType.NORMAL.getButtonText(), b -> this.sortType = 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));
addButton(SortType.A_TO_Z.button = new Button(x, y, width - buttonMargin, 20, SortType.A_TO_Z.getButtonText(), b -> this.sortType = SortType.A_TO_Z));
x += width + buttonMargin;
addButton(SortType.Z_TO_A.button = new SortButton(SortType.NORMAL.buttonID, x, y, width - buttonMargin, 20, SortType.Z_TO_A));
addButton(SortType.Z_TO_A.button = new Button(x, y, width - buttonMargin, 20, SortType.Z_TO_A.getButtonText(), b -> this.sortType = SortType.Z_TO_A));
resortMods();
updateCache();
}
private void displayModConfig()
{
if (selectedMod == null) return;
if (selected == null) return;
try
{
ConfigGuiHandler.getGuiFactoryFor(selectedMod).map(f->f.apply(this.mc, this)).ifPresent(newScreen -> this.mc.displayGuiScreen(newScreen));
ConfigGuiHandler.getGuiFactoryFor(selected.getInfo()).map(f->f.apply(this.minecraft, this)).ifPresent(newScreen -> this.minecraft.displayGuiScreen(newScreen));
}
catch (final Exception e)
{
LOGGER.error("There was a critical issue trying to build the config GUI for {}", selectedMod.getModId(), e);
LOGGER.error("There was a critical issue trying to build the config GUI for {}", selected.getInfo().getModId(), e);
}
}
@@ -356,13 +325,14 @@ public class GuiModList extends GuiScreen
{
reloadMods();
mods.sort(sortType);
selected = mods.indexOf(selectedMod);
modList.refreshList();
if (selected != null)
selected = modList.children().stream().filter(e -> e.getInfo() == selected.getInfo()).findFirst().orElse(null);
sorted = true;
}
}
public <T extends GuiListExtended.IGuiListEntry<T>> void buildModList(Consumer<T> modListViewConsumer, Function<ModInfo, T> newEntry)
public <T extends ExtendedList.AbstractListEntry<T>> void buildModList(Consumer<T> modListViewConsumer, Function<ModInfo, T> newEntry)
{
mods.forEach(mod->modListViewConsumer.accept(newEntry.apply(mod)));
}
@@ -376,11 +346,10 @@ public class GuiModList extends GuiScreen
private void resortMods()
{
for (GuiButton b : buttons)
for (SortType sort : SortType.values())
{
if (b instanceof SortButton) {
b.enabled = sortType.button != b;
}
if (sort.button != null)
sort.button.active = sortType != sort;
}
sorted = false;
}
@@ -388,60 +357,49 @@ public class GuiModList extends GuiScreen
@Override
public void render(int mouseX, int mouseY, float partialTicks)
{
this.modList.drawScreen(mouseX, mouseY, partialTicks);
this.modInfo.drawScreen(mouseX, mouseY, partialTicks);
this.modList.render(mouseX, mouseY, partialTicks);
this.modInfo.render(mouseX, mouseY, partialTicks);
int left = ((this.width - this.listWidth - 38) / 2) + this.listWidth + 30;
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);
int x = ((10 + modList.getRight()) / 2) - (getFontRenderer().getStringWidth(text) / 2);
getFontRenderer().drawString(text, x, modList.getBottom() + 5, 0xFFFFFF);
this.search.render(mouseX, mouseY, partialTicks);
super.render(mouseX, mouseY, partialTicks);
}
Minecraft getMinecraftInstance()
{
return mc;
return minecraft;
}
FontRenderer getFontRenderer()
{
return fontRenderer;
return font;
}
public void selectModIndex(int index)
public void setSelected(GuiSlotModList.ModEntry entry)
{
if (index == this.selected) {
this.selected = -1;
} else
{
this.selected = index;
}
this.selectedMod = (this.selected >= 0 && this.selected< mods.size()) ? mods.get(this.selected) : null;
this.selected = entry == this.selected ? null : entry;
updateCache();
}
public boolean modIndexSelected(int index)
{
return index == selected;
}
private void updateCache()
{
if (selectedMod == null) {
if (selected == null) {
modInfo.clear();
return;
}
ModInfo selectedMod = selected.getInfo();
this.configButton.enabled = selectedMod.hasConfigUI();
this.configButton.active = selectedMod.hasConfigUI();
List<String> lines = new ArrayList<>();
VersionChecker.CheckResult vercheck = VersionChecker.getResult(selectedMod);
Pair<ResourceLocation, Size2i> logoData = selectedMod.getLogoFile().map(logoFile->
{
TextureManager tm = mc.getTextureManager();
TextureManager tm = this.minecraft.getTextureManager();
final ModFileResourcePack resourcePack = ResourcePackLoader.getResourcePackFor(selectedMod.getModId())
.orElse(ResourcePackLoader.getResourcePackFor("forge").
orElseThrow(()->new RuntimeException("Can't find forge, WHAT!")));
@@ -19,35 +19,33 @@
package net.minecraftforge.fml.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.StartupQuery;
public class GuiNotification extends GuiScreen
public class GuiNotification extends Screen
{
public GuiNotification(StartupQuery query)
{
super(new TranslationTextComponent("fml.menu.notification.title"));
this.query = query;
}
@Override
public void initGui()
public void init()
{
this.buttons.add(new GuiButton(0, this.width / 2 - 100, this.height - 38, I18n.format("gui.done"))
{
public void onClick(double mouseX, double mouseY)
{
GuiNotification.this.mc.displayGuiScreen(null);
query.finish();
}
});
this.buttons.add(new Button(this.width / 2 - 100, this.height - 38, 200, 20, I18n.format("gui.done"), b -> {
GuiNotification.this.minecraft.displayGuiScreen(null);
query.finish();
}));
}
@Override
public void render(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.renderBackground();
String[] lines = query.getText().split("\n");
@@ -60,12 +58,12 @@ public class GuiNotification extends GuiScreen
{
if (offset >= spaceAvailable)
{
this.drawCenteredString(this.fontRenderer, "...", this.width / 2, offset, 0xFFFFFF);
this.drawCenteredString(this.font, "...", this.width / 2, offset, 0xFFFFFF);
break;
}
else
{
if (!line.isEmpty()) this.drawCenteredString(this.fontRenderer, line, this.width / 2, offset, 0xFFFFFF);
if (!line.isEmpty()) this.drawCenteredString(this.font, line, this.width / 2, offset, 0xFFFFFF);
offset += 10;
}
}
@@ -21,9 +21,8 @@ package net.minecraftforge.fml.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiListExtended;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.widget.list.ExtendedList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.versions.forge.ForgeVersion;
import net.minecraftforge.fml.MavenVersionStringHelper;
@@ -32,11 +31,9 @@ import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
import static net.minecraft.util.StringUtils.stripControlCodes;
/**
* @author cpw
*
*/
public class GuiSlotModList extends GuiListExtended<GuiSlotModList.ModEntry>
import com.mojang.blaze3d.platform.GlStateManager;
public class GuiSlotModList extends ExtendedList<GuiSlotModList.ModEntry>
{
private static final ResourceLocation VERSION_CHECK_ICONS = new ResourceLocation(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png");
private final int listWidth;
@@ -52,13 +49,13 @@ public class GuiSlotModList extends GuiListExtended<GuiSlotModList.ModEntry>
}
@Override
protected int getScrollBarX()
protected int getScrollbarPosition()
{
return this.listWidth;
}
@Override
public int getListWidth()
public int getRowWidth()
{
return this.listWidth;
}
@@ -69,18 +66,12 @@ public class GuiSlotModList extends GuiListExtended<GuiSlotModList.ModEntry>
}
@Override
protected boolean isSelected(int index)
protected void renderBackground()
{
return this.parent.modIndexSelected(index);
this.parent.renderBackground();
}
@Override
protected void drawBackground()
{
this.parent.drawDefaultBackground();
}
class ModEntry extends GuiListExtended.IGuiListEntry<ModEntry> {
class ModEntry extends ExtendedList.AbstractListEntry<ModEntry> {
private final ModInfo modInfo;
private final GuiModList parent;
@@ -90,10 +81,8 @@ public class GuiSlotModList extends GuiListExtended<GuiSlotModList.ModEntry>
}
@Override
public void drawEntry(int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks)
public void render(int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks)
{
int top = this.getY();
int left = this.getX();
String name = stripControlCodes(modInfo.getDisplayName());
String version = stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion()));
VersionChecker.CheckResult vercheck = VersionChecker.getResult(modInfo);
@@ -106,7 +95,7 @@ public class GuiSlotModList extends GuiListExtended<GuiSlotModList.ModEntry>
Minecraft.getInstance().getTextureManager().bindTexture(VERSION_CHECK_ICONS);
GlStateManager.color4f(1, 1, 1, 1);
GlStateManager.pushMatrix();
Gui.drawModalRectWithCustomSizedTexture(right - (height / 2 + 4), GuiSlotModList.this.top + (height / 2 - 4), vercheck.status.getSheetOffset() * 8, (vercheck.status.isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
AbstractGui.blit(getRight() - (height / 2 + 4), GuiSlotModList.this.getTop() + (height / 2 - 4), vercheck.status.getSheetOffset() * 8, (vercheck.status.isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
GlStateManager.popMatrix();
}
}
@@ -114,8 +103,14 @@ public class GuiSlotModList extends GuiListExtended<GuiSlotModList.ModEntry>
@Override
public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_)
{
parent.selectModIndex(this.getIndex());
parent.setSelected(this);
GuiSlotModList.this.setSelected(this);
return false;
}
public ModInfo getInfo()
{
return modInfo;
}
}
}
@@ -22,9 +22,11 @@ package net.minecraftforge.fml.client.gui;
import com.google.common.base.Strings;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiErrorScreen;
import net.minecraft.client.gui.GuiListExtended;
import net.minecraft.client.gui.screen.ErrorScreen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.widget.list.ExtendedList;
import net.minecraft.util.Util;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.ForgeI18n;
import net.minecraftforge.fml.LoadingFailedException;
@@ -41,7 +43,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
public class LoadingErrorScreen extends GuiErrorScreen {
public class LoadingErrorScreen extends ErrorScreen {
private static final Logger LOGGER = LogManager.getLogger();
private final Path modsDir;
private final Path logFile;
@@ -53,36 +55,17 @@ public class LoadingErrorScreen extends GuiErrorScreen {
public LoadingErrorScreen(LoadingFailedException loadingException, List<ModLoadingWarning> warnings)
{
super(null, null);
super(new StringTextComponent("Loading Error"), null);
this.modLoadWarnings = warnings;
this.modLoadErrors = loadingException == null ? Collections.emptyList() : loadingException.getErrors();
this.modsDir = FMLPaths.MODSDIR.get();
this.logFile = FMLPaths.GAMEDIR.get().resolve(Paths.get("logs","latest.log"));
}
private double openModsDir(double mouseX, double mouseY)
{
Util.getOSType().openFile(modsDir.toFile());
return 0.0;
}
private double openLogFile(double mouseX, double mouseY)
{
Util.getOSType().openFile(logFile.toFile());
return 0.0;
}
private double continueGame(double mouseX, double mouseY)
{
ClientHooks.logMissingTextureErrors();
mc.displayGuiScreen(null);
return 0.0;
}
@Override
public void initGui()
public void init()
{
super.initGui();
super.init();
this.buttons.clear();
this.children.clear();
@@ -90,13 +73,13 @@ public class LoadingErrorScreen extends GuiErrorScreen {
this.warningHeader = TextFormatting.YELLOW + ForgeI18n.parseMessage("fml.loadingerrorscreen.warningheader", this.modLoadErrors.size()) + TextFormatting.RESET;
int yOffset = this.modLoadErrors.isEmpty() ? 46 : 38;
this.addButton(new GuiButtonClickConsumer(10, 50, this.height - yOffset, this.width / 2 - 55, 20,
ForgeI18n.parseMessage("fml.button.open.mods.folder"), this::openModsDir));
this.addButton(new GuiButtonClickConsumer(11, this.width / 2 + 5, this.height - yOffset, this.width / 2 - 55, 20,
ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName()), this::openLogFile));
this.addButton(new Button(50, this.height - yOffset, this.width / 2 - 55, 20, ForgeI18n.parseMessage("fml.button.open.mods.folder"), b -> Util.getOSType().openFile(modsDir.toFile())));
this.addButton(new Button(this.width / 2 + 5, this.height - yOffset, this.width / 2 - 55, 20, ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName()), b -> Util.getOSType().openFile(logFile.toFile())));
if (this.modLoadErrors.isEmpty()) {
this.addButton(new GuiButtonClickConsumer(12, this.width / 4, this.height - 24, this.width / 2, 20,
ForgeI18n.parseMessage("fml.button.continue.launch"), this::continueGame));
this.addButton(new Button(this.width / 4, this.height - 24, this.width / 2, 20, ForgeI18n.parseMessage("fml.button.continue.launch"), b -> {
ClientHooks.logMissingTextureErrors();
this.minecraft.displayGuiScreen(null);
}));
}
this.entryList = new LoadingEntryList(this, this.modLoadErrors, this.modLoadWarnings);
@@ -107,9 +90,9 @@ public class LoadingErrorScreen extends GuiErrorScreen {
@Override
public void render(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.entryList.drawScreen(mouseX, mouseY, partialTicks);
drawMultiLineCenteredString(fontRenderer, this.modLoadErrors.isEmpty() ? warningHeader : errorHeader, this.width / 2, 10);
this.renderBackground();
this.entryList.render(mouseX, mouseY, partialTicks);
drawMultiLineCenteredString(font, this.modLoadErrors.isEmpty() ? warningHeader : errorHeader, this.width / 2, 10);
this.buttons.forEach(button -> button.render(mouseX, mouseY, partialTicks));
}
@@ -119,15 +102,15 @@ public class LoadingErrorScreen extends GuiErrorScreen {
y+=fr.FONT_HEIGHT;
}
}
public static class LoadingEntryList extends GuiListExtended<LoadingEntryList.LoadingMessageEntry> {
public static class LoadingEntryList extends ExtendedList<LoadingEntryList.LoadingMessageEntry> {
LoadingEntryList(final LoadingErrorScreen parent, final List<ModLoadingException> errors, final List<ModLoadingWarning> warnings) {
super(parent.mc, parent.width, parent.height, 35, parent.height - 50, 2 * parent.mc.fontRenderer.FONT_HEIGHT + 8);
super(parent.minecraft, parent.width, parent.height, 35, parent.height - 50, 2 * parent.minecraft.fontRenderer.FONT_HEIGHT + 8);
boolean both = !errors.isEmpty() && !warnings.isEmpty();
if (both)
addEntry(new LoadingMessageEntry(parent.errorHeader, true));
errors.forEach(e->addEntry(new LoadingMessageEntry(e.formatToString())));
if (both) {
int maxChars = (this.width - 10) / parent.mc.fontRenderer.getStringWidth("-");
int maxChars = (this.width - 10) / parent.minecraft.fontRenderer.getStringWidth("-");
addEntry(new LoadingMessageEntry("\n" + Strings.repeat("-", maxChars) + "\n"));
addEntry(new LoadingMessageEntry(parent.warningHeader, true));
}
@@ -135,18 +118,18 @@ public class LoadingErrorScreen extends GuiErrorScreen {
}
@Override
protected int getScrollBarX()
protected int getScrollbarPosition()
{
return this.right - 6;
return this.getRight() - 6;
}
@Override
public int getListWidth()
public int getRowWidth()
{
return this.width;
}
public class LoadingMessageEntry extends GuiListExtended.IGuiListEntry<LoadingMessageEntry> {
public class LoadingMessageEntry extends ExtendedList.AbstractListEntry<LoadingMessageEntry> {
private final String message;
private final boolean center;
@@ -160,9 +143,7 @@ public class LoadingErrorScreen extends GuiErrorScreen {
}
@Override
public void drawEntry(final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean p_194999_5_, final float partialTicks) {
int top = this.getY();
int left = this.getX();
public void render(int entryIdx, int top, int left, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean p_194999_5_, final float partialTicks) {
FontRenderer font = Minecraft.getInstance().fontRenderer;
final List<String> strings = font.listFormattedStringToWidth(message, LoadingEntryList.this.width);
int y = top + 2;
@@ -19,11 +19,11 @@
package net.minecraftforge.fml.client.registry;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.entity.Entity;
public interface IRenderFactory<T extends Entity>
{
Render<? super T> createRenderFor(RenderManager manager);
EntityRenderer<? super T> createRenderFor(EntityRendererManager manager);
}
@@ -22,8 +22,8 @@ package net.minecraftforge.fml.client.registry;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.entity.Entity;
public class RenderingRegistry
@@ -43,13 +43,13 @@ public class RenderingRegistry
INSTANCE.entityRenderers.put(entityClass, renderFactory);
}
public static void loadEntityRenderers(RenderManager manager, Map<Class<? extends Entity>, Render<? extends Entity>> renderMap)
public static void loadEntityRenderers(EntityRendererManager manager, Map<Class<? extends Entity>, EntityRenderer<? extends Entity>> renderMap)
{
INSTANCE.entityRenderers.forEach((key, value) -> register(manager, renderMap, key, value));
}
@SuppressWarnings("unchecked")
private static <T extends Entity> void register(RenderManager manager, Map<Class<? extends Entity>, Render<? extends Entity>> renderMap, Class<T> entityClass, IRenderFactory<?> renderFactory)
private static <T extends Entity> void register(EntityRendererManager manager, Map<Class<? extends Entity>, EntityRenderer<? extends Entity>> renderMap, Class<T> entityClass, IRenderFactory<?> renderFactory)
{
renderMap.put(entityClass, ((IRenderFactory<T>)renderFactory).createRenderFor(manager));
}