mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 20:22:28 +00:00
Setup and import of 1.16 YEET
This commit is contained in:
931 files changed
+18847
-9127
No files matched your search
@@ -28,8 +28,8 @@ import com.google.common.collect.Multimap;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraft.world.storage.IServerConfiguration;
|
||||
import net.minecraft.world.storage.SaveFormat;
|
||||
import net.minecraftforge.registries.ForgeRegistry;
|
||||
import net.minecraftforge.registries.GameData;
|
||||
import net.minecraftforge.registries.RegistryManager;
|
||||
@@ -56,7 +56,7 @@ public final class FMLWorldPersistenceHook implements WorldPersistenceHooks.Worl
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT getDataForWriting(SaveHandler handler, WorldInfo info)
|
||||
public CompoundNBT getDataForWriting(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo)
|
||||
{
|
||||
CompoundNBT fmlData = new CompoundNBT();
|
||||
ListNBT modList = new ListNBT();
|
||||
@@ -71,7 +71,7 @@ public final class FMLWorldPersistenceHook implements WorldPersistenceHooks.Worl
|
||||
|
||||
CompoundNBT registries = new CompoundNBT();
|
||||
fmlData.put("Registries", registries);
|
||||
LOGGER.debug(WORLDPERSISTENCE,"Gathering id map for writing to world save {}", info.getWorldName());
|
||||
LOGGER.debug(WORLDPERSISTENCE,"Gathering id map for writing to world save {}", serverInfo.getWorldName());
|
||||
|
||||
for (Map.Entry<ResourceLocation, ForgeRegistry.Snapshot> e : RegistryManager.ACTIVE.takeSnapshot(true).entrySet())
|
||||
{
|
||||
@@ -81,7 +81,7 @@ public final class FMLWorldPersistenceHook implements WorldPersistenceHooks.Worl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(SaveHandler handler, WorldInfo info, CompoundNBT tag)
|
||||
public void readData(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo, CompoundNBT tag)
|
||||
{
|
||||
if (tag.contains("LoadingModList"))
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.util.function.BiConsumer;
|
||||
|
||||
import static net.minecraftforge.fml.Logging.CORE;
|
||||
|
||||
//TODO, this should be re-evaluated now that ITextComponents are passed everywhere instaed of strings.
|
||||
public class ForgeI18n {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static Map<String,String> i18n;
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.ITextProperties;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TextComponentMessageFormatHandler {
|
||||
public static int handle(final TranslationTextComponent parent, final List<ITextComponent> children, final Object[] formatArgs, final String format) {
|
||||
public static int handle(final TranslationTextComponent parent, final List<ITextProperties> children, final Object[] formatArgs, final String format) {
|
||||
try {
|
||||
StringTextComponent component = new StringTextComponent(ForgeI18n.parseFormat(format, formatArgs));
|
||||
component.getStyle().setParentStyle(parent.getStyle());
|
||||
component.getStyle().func_240717_a_(parent.getStyle());
|
||||
children.add(component);
|
||||
return format.length();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraft.world.storage.IServerConfiguration;
|
||||
import net.minecraft.world.storage.SaveFormat;
|
||||
import net.minecraftforge.fml.common.thread.EffectiveSide;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -35,42 +35,23 @@ public class WorldPersistenceHooks
|
||||
worldPersistenceHooks.add(hook);
|
||||
}
|
||||
|
||||
public static void handleWorldDataSave(final SaveHandler handler, final WorldInfo worldInfo, final CompoundNBT tagCompound)
|
||||
public static void handleWorldDataSave(final SaveFormat.LevelSave levelSave, final IServerConfiguration serverInfo, final CompoundNBT tagCompound)
|
||||
{
|
||||
worldPersistenceHooks.forEach(wac->tagCompound.put(wac.getModId(), wac.getDataForWriting(handler, worldInfo)));
|
||||
worldPersistenceHooks.forEach(wac->tagCompound.put(wac.getModId(), wac.getDataForWriting(levelSave, serverInfo)));
|
||||
}
|
||||
|
||||
public static void handleWorldDataLoad(SaveHandler handler, WorldInfo worldInfo, CompoundNBT tagCompound)
|
||||
public static void handleWorldDataLoad(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo, CompoundNBT tagCompound)
|
||||
{
|
||||
if (EffectiveSide.get() == LogicalSide.SERVER)
|
||||
{
|
||||
worldPersistenceHooks.forEach(wac->wac.readData(handler, worldInfo, tagCompound.getCompound(wac.getModId())));
|
||||
worldPersistenceHooks.forEach(wac->wac.readData(levelSave, serverInfo, tagCompound.getCompound(wac.getModId())));
|
||||
}
|
||||
}
|
||||
|
||||
public static void confirmBackupLevelDatUse(SaveHandler handler)
|
||||
{
|
||||
/*
|
||||
if (handlerToCheck == null || handlerToCheck.get() != handler) {
|
||||
// only run if the save has been initially loaded
|
||||
handlerToCheck = null;
|
||||
return;
|
||||
}
|
||||
|
||||
String text = "Forge Mod Loader detected that the backup level.dat is being used.\n\n" +
|
||||
"This may happen due to a bug or corruption, continuing can damage\n" +
|
||||
"your world beyond repair or lose data / progress.\n\n" +
|
||||
"It's recommended to create a world backup before continuing.";
|
||||
|
||||
boolean confirmed = StartupQuery.confirm(text);
|
||||
if (!confirmed) StartupQuery.abort();
|
||||
*/
|
||||
}
|
||||
|
||||
public interface WorldPersistenceHook
|
||||
{
|
||||
String getModId();
|
||||
CompoundNBT getDataForWriting(SaveHandler handler, WorldInfo info);
|
||||
void readData(SaveHandler handler, WorldInfo info, CompoundNBT tag);
|
||||
CompoundNBT getDataForWriting(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo);
|
||||
void readData(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo, CompoundNBT tag);
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,7 @@
|
||||
package net.minecraftforge.fml.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -34,11 +31,13 @@ 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 com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.screen.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.screen.WorldSelectionScreen;
|
||||
import net.minecraft.client.multiplayer.PlayerController;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.client.event.ClientPlayerNetworkEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.ExtensionPoint;
|
||||
@@ -131,7 +130,7 @@ public class ClientHooks
|
||||
|
||||
}
|
||||
|
||||
public static void drawForgePingInfo(MultiplayerScreen gui, ServerData target, int x, int y, int width, int relativeMouseX, int relativeMouseY) {
|
||||
public static void drawForgePingInfo(MultiplayerScreen gui, ServerData target, MatrixStack mStack, int x, int y, int width, int relativeMouseX, int relativeMouseY) {
|
||||
int idx;
|
||||
String tooltip;
|
||||
if (target.forgeData == null)
|
||||
@@ -166,10 +165,11 @@ public class ClientHooks
|
||||
}
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(iconSheet);
|
||||
AbstractGui.blit(x + width - 18, y + 10, 16, 16, 0, idx, 16, 16, 256, 256);
|
||||
AbstractGui.func_238466_a_(mStack, 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);
|
||||
//TODO using StringTextComponent here is a hack, we should be using TranslationTextComponents.
|
||||
gui.func_238854_b_(Collections.singletonList(new StringTextComponent(tooltip)));
|
||||
|
||||
}
|
||||
|
||||
@@ -187,7 +187,8 @@ public class ClientHooks
|
||||
{
|
||||
try
|
||||
{
|
||||
Minecraft.getInstance().launchIntegratedServer(comparator.getFileName(), comparator.getDisplayName(), null);
|
||||
//TODO
|
||||
//Minecraft.getInstance().launchIntegratedServer(comparator.getFileName(), comparator.getDisplayName(), null);
|
||||
}
|
||||
catch (StartupQuery.AbortedException e)
|
||||
{
|
||||
|
||||
@@ -34,6 +34,7 @@ import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.resources.*;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -43,11 +44,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.ClientResourcePackInfo;
|
||||
import net.minecraft.client.resources.DownloadingPackFinder;
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.resources.IFutureReloadListener;
|
||||
import net.minecraft.resources.IReloadableResourceManager;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.resources.ResourcePackInfo;
|
||||
import net.minecraft.resources.ResourcePackList;
|
||||
import net.minecraft.resources.data.PackMetadataSection;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -189,14 +185,14 @@ public class ClientModLoader
|
||||
return (packList, factory) -> clientPackFinder(modResourcePacks, packSetter, packList, factory);
|
||||
}
|
||||
|
||||
private static <T extends ResourcePackInfo> void clientPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ? super T> packSetter, Map<String, T> packList, ResourcePackInfo.IFactory<? extends T> factory) {
|
||||
private static <T extends ResourcePackInfo> void clientPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ? super T> packSetter, Consumer<T> consumer, ResourcePackInfo.IFactory<? extends T> factory) {
|
||||
List<DelegatableResourcePack> hiddenPacks = new ArrayList<>();
|
||||
for (Entry<ModFile, ? extends ModFileResourcePack> e : modResourcePacks.entrySet())
|
||||
{
|
||||
IModInfo mod = e.getKey().getModInfos().get(0);
|
||||
if (Objects.equals(mod.getModId(), "minecraft")) continue; // skip the minecraft "mod"
|
||||
final String name = "mod:" + mod.getModId();
|
||||
final T packInfo = ResourcePackInfo.createResourcePack(name, false, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM);
|
||||
final T packInfo = ResourcePackInfo.createResourcePack(name, false, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.field_232625_a_);
|
||||
if (packInfo == null) {
|
||||
// Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong
|
||||
ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey()));
|
||||
@@ -205,14 +201,14 @@ public class ClientModLoader
|
||||
packSetter.accept(e.getValue(), packInfo);
|
||||
LOGGER.debug(CORE, "Generating PackInfo named {} for mod file {}", name, e.getKey().getFilePath());
|
||||
if (mod.getOwningFile().showAsResourcePack()) {
|
||||
packList.put(name, packInfo);
|
||||
consumer.accept(packInfo);
|
||||
} else {
|
||||
hiddenPacks.add(e.getValue());
|
||||
}
|
||||
}
|
||||
final T packInfo = ResourcePackInfo.createResourcePack("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources",
|
||||
new PackMetadataSection(new TranslationTextComponent("fml.resources.modresources", hiddenPacks.size()), 5),
|
||||
hiddenPacks), factory, ResourcePackInfo.Priority.BOTTOM);
|
||||
packList.put("mod_resources", packInfo);
|
||||
hiddenPacks), factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.field_232625_a_);
|
||||
consumer.accept(packInfo);
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,11 @@ import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.text.ITextProperties;
|
||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
@@ -239,9 +240,9 @@ public class GuiUtils
|
||||
cachedTooltipStack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static void drawHoveringText(List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
|
||||
public static void drawHoveringText(MatrixStack mStack, List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
|
||||
{
|
||||
drawHoveringText(textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, DEFAULT_BACKGROUND_COLOR, DEFAULT_BORDER_COLOR_START, DEFAULT_BORDER_COLOR_END, font);
|
||||
drawHoveringText(mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, DEFAULT_BACKGROUND_COLOR, DEFAULT_BORDER_COLOR_START, DEFAULT_BORDER_COLOR_END, font);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,23 +264,24 @@ public class GuiUtils
|
||||
* between the start and end values.
|
||||
* @param font the font for drawing the text in the tooltip box
|
||||
*/
|
||||
public static void drawHoveringText(List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
||||
public static void drawHoveringText(MatrixStack mStack, List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
||||
int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, FontRenderer font)
|
||||
{
|
||||
drawHoveringText(cachedTooltipStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, backgroundColor, borderColorStart, borderColorEnd, font);
|
||||
drawHoveringText(cachedTooltipStack, mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, backgroundColor, borderColorStart, borderColorEnd, font);
|
||||
}
|
||||
|
||||
public static void drawHoveringText(@Nonnull final ItemStack stack, List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
|
||||
public static void drawHoveringText(@Nonnull final ItemStack stack, MatrixStack mStack, List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
|
||||
{
|
||||
drawHoveringText(stack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, DEFAULT_BACKGROUND_COLOR, DEFAULT_BORDER_COLOR_START, DEFAULT_BORDER_COLOR_END, font);
|
||||
drawHoveringText(stack, mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, DEFAULT_BACKGROUND_COLOR, DEFAULT_BORDER_COLOR_START, DEFAULT_BORDER_COLOR_END, font);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this version if calling from somewhere where ItemStack context is available.
|
||||
*
|
||||
* @see #drawHoveringText(List, int, int, int, int, int, int, int, int, FontRenderer)
|
||||
* @see #drawHoveringText(MatrixStack, List, int, int, int, int, int, int, int, int, FontRenderer)
|
||||
*/
|
||||
public static void drawHoveringText(@Nonnull final ItemStack stack, List<String> textLines, int mouseX, int mouseY,
|
||||
//TODO, Validate rendering is the same as the original
|
||||
public static void drawHoveringText(@Nonnull final ItemStack stack, MatrixStack mStack, List<? extends ITextProperties> textLines, int mouseX, int mouseY,
|
||||
int screenWidth, int screenHeight, int maxTextWidth,
|
||||
int backgroundColor, int borderColorStart, int borderColorEnd, FontRenderer font)
|
||||
{
|
||||
@@ -299,9 +301,9 @@ public class GuiUtils
|
||||
RenderSystem.disableDepthTest();
|
||||
int tooltipTextWidth = 0;
|
||||
|
||||
for (String textLine : textLines)
|
||||
for (ITextProperties textLine : textLines)
|
||||
{
|
||||
int textLineWidth = font.getStringWidth(textLine);
|
||||
int textLineWidth = font.func_238414_a_(textLine);
|
||||
if (textLineWidth > tooltipTextWidth)
|
||||
tooltipTextWidth = textLineWidth;
|
||||
}
|
||||
@@ -332,17 +334,17 @@ public class GuiUtils
|
||||
if (needsWrap)
|
||||
{
|
||||
int wrappedTooltipWidth = 0;
|
||||
List<String> wrappedTextLines = new ArrayList<String>();
|
||||
List<ITextProperties> wrappedTextLines = new ArrayList<>();
|
||||
for (int i = 0; i < textLines.size(); i++)
|
||||
{
|
||||
String textLine = textLines.get(i);
|
||||
List<String> wrappedLine = font.listFormattedStringToWidth(textLine, tooltipTextWidth);
|
||||
ITextProperties textLine = textLines.get(i);
|
||||
List<ITextProperties> wrappedLine = font.func_238425_b_(textLine, tooltipTextWidth);
|
||||
if (i == 0)
|
||||
titleLinesCount = wrappedLine.size();
|
||||
|
||||
for (String line : wrappedLine)
|
||||
for (ITextProperties line : wrappedLine)
|
||||
{
|
||||
int lineWidth = font.getStringWidth(line);
|
||||
int lineWidth = font.func_238414_a_(line);
|
||||
if (lineWidth > wrappedTooltipWidth)
|
||||
wrappedTooltipWidth = lineWidth;
|
||||
wrappedTextLines.add(line);
|
||||
@@ -379,30 +381,31 @@ public class GuiUtils
|
||||
borderColorStart = colorEvent.getBorderStart();
|
||||
borderColorEnd = colorEvent.getBorderEnd();
|
||||
|
||||
drawGradientRect(zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor);
|
||||
drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(zLevel, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 3, tooltipY - 3, tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||
drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||
drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColorStart, borderColorStart);
|
||||
drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 2, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, borderColorEnd, borderColorEnd);
|
||||
mStack.push();
|
||||
Matrix4f mat = mStack.getLast().getMatrix();
|
||||
//TODO, lots of unnessesary GL calls here, we can buffer all these together.
|
||||
drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor);
|
||||
drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(mat, zLevel, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(mat, zLevel, tooltipX + tooltipTextWidth + 3, tooltipY - 3, tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||
drawGradientRect(mat, zLevel, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||
drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColorStart, borderColorStart);
|
||||
drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY + tooltipHeight + 2, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, borderColorEnd, borderColorEnd);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostBackground(stack, textLines, tooltipX, tooltipY, font, tooltipTextWidth, tooltipHeight));
|
||||
|
||||
IRenderTypeBuffer.Impl renderType = IRenderTypeBuffer.getImpl(Tessellator.getInstance().getBuffer());
|
||||
MatrixStack textStack = new MatrixStack();
|
||||
textStack.translate(0.0D, 0.0D, (double)zLevel);
|
||||
Matrix4f textLocation = textStack.getLast().getMatrix();
|
||||
mStack.translate(0.0D, 0.0D, zLevel);
|
||||
|
||||
int tooltipTop = tooltipY;
|
||||
|
||||
for (int lineNumber = 0; lineNumber < textLines.size(); ++lineNumber)
|
||||
{
|
||||
String line = textLines.get(lineNumber);
|
||||
ITextProperties line = textLines.get(lineNumber);
|
||||
if (line != null)
|
||||
font.renderString(line, (float)tooltipX, (float)tooltipY, -1, true, textLocation, renderType, false, 0, 15728880);
|
||||
font.func_238416_a_(line, (float)tooltipX, (float)tooltipY, -1, true, mat, renderType, false, 0, 15728880);
|
||||
|
||||
if (lineNumber + 1 == titleLinesCount)
|
||||
tooltipY += 2;
|
||||
@@ -411,6 +414,7 @@ public class GuiUtils
|
||||
}
|
||||
|
||||
renderType.finish();
|
||||
mStack.pop();
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostText(stack, textLines, tooltipX, tooltipTop, font, tooltipTextWidth, tooltipHeight));
|
||||
|
||||
@@ -419,7 +423,7 @@ public class GuiUtils
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawGradientRect(int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
|
||||
public static void drawGradientRect(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
|
||||
{
|
||||
float startAlpha = (float)(startColor >> 24 & 255) / 255.0F;
|
||||
float startRed = (float)(startColor >> 16 & 255) / 255.0F;
|
||||
@@ -430,33 +434,32 @@ public class GuiUtils
|
||||
float endGreen = (float)(endColor >> 8 & 255) / 255.0F;
|
||||
float endBlue = (float)(endColor & 255) / 255.0F;
|
||||
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.disableAlphaTest();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.shadeModel(GL11.GL_SMOOTH);
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
|
||||
buffer.pos(right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
|
||||
buffer.pos( left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
|
||||
buffer.pos( left, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
|
||||
buffer.pos(right, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
|
||||
buffer.pos(mat, right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
|
||||
buffer.pos(mat, left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
|
||||
buffer.pos(mat, left, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
|
||||
buffer.pos(mat, right, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
|
||||
tessellator.draw();
|
||||
|
||||
RenderSystem.shadeModel(GL11.GL_FLAT);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableTexture();
|
||||
}
|
||||
|
||||
public static void drawInscribedRect(int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight)
|
||||
public static void drawInscribedRect(MatrixStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight)
|
||||
{
|
||||
drawInscribedRect(x, y, boundsWidth, boundsHeight, rectWidth, rectHeight, true, true);
|
||||
drawInscribedRect(mStack, x, y, boundsWidth, boundsHeight, rectWidth, rectHeight, true, true);
|
||||
}
|
||||
|
||||
public static void drawInscribedRect(int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY)
|
||||
public static void drawInscribedRect(MatrixStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY)
|
||||
{
|
||||
if (rectWidth * boundsHeight > rectHeight * boundsWidth) {
|
||||
int h = boundsHeight;
|
||||
@@ -468,6 +471,6 @@ public class GuiUtils
|
||||
if (centerX) x += (w - boundsWidth) / 2;
|
||||
}
|
||||
|
||||
AbstractGui.blit(x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight);
|
||||
AbstractGui.func_238466_a_(mStack, x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight);
|
||||
}
|
||||
}
|
||||
@@ -1,103 +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.widget.Widget;
|
||||
|
||||
/**
|
||||
* 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 Widget widget;
|
||||
private long hoverStart;
|
||||
|
||||
public HoverChecker(int top, int bottom, int left, int right, int threshold)
|
||||
{
|
||||
this.top = top;
|
||||
this.bottom = bottom;
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
this.threshold = threshold;
|
||||
this.hoverStart = -1;
|
||||
}
|
||||
|
||||
public HoverChecker(Widget widget, int threshold)
|
||||
{
|
||||
this.widget = widget;
|
||||
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.
|
||||
*/
|
||||
public void updateBounds(int top, int bottom, int left, int right)
|
||||
{
|
||||
this.top = top;
|
||||
this.bottom = bottom;
|
||||
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.
|
||||
*/
|
||||
public boolean checkHover(int mouseX, int mouseY)
|
||||
{
|
||||
return checkHover(mouseX, mouseY, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public boolean checkHover(int mouseX, int mouseY, boolean canHover)
|
||||
{
|
||||
if (this.widget != null)
|
||||
{
|
||||
this.top = widget.y;
|
||||
this.bottom = widget.y + widget.getHeight();
|
||||
this.left = widget.x;
|
||||
this.right = widget.x + widget.getWidth();
|
||||
canHover = canHover && widget.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.
|
||||
*/
|
||||
public void resetHoverTimer()
|
||||
{
|
||||
hoverStart = -1;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
package net.minecraftforge.fml.client.gui.screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.fml.ForgeI18n;
|
||||
import net.minecraftforge.fml.StartupQuery;
|
||||
|
||||
@@ -32,16 +34,16 @@ public class ConfirmationScreen extends NotificationScreen
|
||||
@Override
|
||||
protected void addConfirmationButtons()
|
||||
{
|
||||
this.addButton(new Button(this.width / 2 - 104, this.height - PADDING - 20, 100, 20, ForgeI18n.parseMessage("gui.yes"), b ->
|
||||
this.func_230480_a_(new Button(this.field_230708_k_ / 2 - 104, this.field_230709_l_ - PADDING - 20, 100, 20, new StringTextComponent(ForgeI18n.parseMessage("gui.yes")), b ->
|
||||
{
|
||||
ConfirmationScreen.this.minecraft.currentScreen = null;
|
||||
ConfirmationScreen.this.field_230706_i_.currentScreen = null;
|
||||
query.setResult(true);
|
||||
query.finish();
|
||||
}
|
||||
));
|
||||
this.addButton(new Button(this.width / 2 + 4, this.height - PADDING - 20, 100, 20, ForgeI18n.parseMessage("gui.no"), b ->
|
||||
this.func_230480_a_(new Button(this.field_230708_k_ / 2 + 4, this.field_230709_l_ - PADDING - 20, 100, 20, new StringTextComponent(ForgeI18n.parseMessage("gui.no")), b ->
|
||||
{
|
||||
ConfirmationScreen.this.minecraft.currentScreen = null;
|
||||
ConfirmationScreen.this.field_230706_i_.currentScreen = null;
|
||||
query.setResult(false);
|
||||
query.finish();
|
||||
}
|
||||
|
||||
@@ -20,11 +20,14 @@
|
||||
package net.minecraftforge.fml.client.gui.screen;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.screen.ErrorScreen;
|
||||
import net.minecraft.client.gui.widget.list.ExtendedList;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.ITextProperties;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.ForgeI18n;
|
||||
@@ -50,8 +53,8 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
private final List<ModLoadingException> modLoadErrors;
|
||||
private final List<ModLoadingWarning> modLoadWarnings;
|
||||
private LoadingEntryList entryList;
|
||||
private String errorHeader;
|
||||
private String warningHeader;
|
||||
private ITextComponent errorHeader;
|
||||
private ITextComponent warningHeader;
|
||||
|
||||
public LoadingErrorScreen(LoadingFailedException loadingException, List<ModLoadingWarning> warnings)
|
||||
{
|
||||
@@ -63,95 +66,95 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
public void func_231160_c_()
|
||||
{
|
||||
super.init();
|
||||
this.buttons.clear();
|
||||
this.children.clear();
|
||||
super.func_231160_c_();
|
||||
this.field_230710_m_.clear();
|
||||
this.field_230705_e_.clear();
|
||||
|
||||
this.errorHeader = TextFormatting.RED + ForgeI18n.parseMessage("fml.loadingerrorscreen.errorheader", this.modLoadErrors.size()) + TextFormatting.RESET;
|
||||
this.warningHeader = TextFormatting.YELLOW + ForgeI18n.parseMessage("fml.loadingerrorscreen.warningheader", this.modLoadErrors.size()) + TextFormatting.RESET;
|
||||
this.errorHeader = new StringTextComponent(TextFormatting.RED + ForgeI18n.parseMessage("fml.loadingerrorscreen.errorheader", this.modLoadErrors.size()) + TextFormatting.RESET);
|
||||
this.warningHeader = new StringTextComponent(TextFormatting.YELLOW + ForgeI18n.parseMessage("fml.loadingerrorscreen.warningheader", this.modLoadErrors.size()) + TextFormatting.RESET);
|
||||
|
||||
int yOffset = this.modLoadErrors.isEmpty() ? 46 : 38;
|
||||
this.addButton(new ExtendedButton(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 ExtendedButton(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())));
|
||||
this.func_230480_a_(new ExtendedButton(50, this.field_230709_l_ - yOffset, this.field_230708_k_ / 2 - 55, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.open.mods.folder")), b -> Util.getOSType().openFile(modsDir.toFile())));
|
||||
this.func_230480_a_(new ExtendedButton(this.field_230708_k_ / 2 + 5, this.field_230709_l_ - yOffset, this.field_230708_k_ / 2 - 55, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName())), b -> Util.getOSType().openFile(logFile.toFile())));
|
||||
if (this.modLoadErrors.isEmpty()) {
|
||||
this.addButton(new ExtendedButton(this.width / 4, this.height - 24, this.width / 2, 20, ForgeI18n.parseMessage("fml.button.continue.launch"), b -> {
|
||||
this.func_230480_a_(new ExtendedButton(this.field_230708_k_ / 4, this.field_230709_l_ - 24, this.field_230708_k_ / 2, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.continue.launch")), b -> {
|
||||
ClientHooks.logMissingTextureErrors();
|
||||
this.minecraft.displayGuiScreen(null);
|
||||
this.field_230706_i_.displayGuiScreen(null);
|
||||
}));
|
||||
}
|
||||
|
||||
this.entryList = new LoadingEntryList(this, this.modLoadErrors, this.modLoadWarnings);
|
||||
this.children.add(this.entryList);
|
||||
this.setFocused(this.entryList);
|
||||
this.field_230705_e_.add(this.entryList);
|
||||
this.func_231035_a_(this.entryList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks)
|
||||
public void func_230430_a_(MatrixStack mStack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
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));
|
||||
this.func_230446_a_(mStack);
|
||||
this.entryList.func_230430_a_(mStack, mouseX, mouseY, partialTicks);
|
||||
drawMultiLineCenteredString(mStack, field_230712_o_, this.modLoadErrors.isEmpty() ? warningHeader : errorHeader, this.field_230708_k_ / 2, 10);
|
||||
this.field_230710_m_.forEach(button -> button.func_230430_a_(mStack, mouseX, mouseY, partialTicks));
|
||||
}
|
||||
|
||||
private void drawMultiLineCenteredString(FontRenderer fr, String str, int x, int y) {
|
||||
for (String s : fr.listFormattedStringToWidth(str, this.width)) {
|
||||
fr.drawStringWithShadow(s, (float) (x - fr.getStringWidth(s) / 2.0), y, 0xFFFFFF);
|
||||
private void drawMultiLineCenteredString(MatrixStack mStack, FontRenderer fr, ITextComponent str, int x, int y) {
|
||||
for (ITextProperties s : fr.func_238425_b_(str, this.field_230708_k_)) {
|
||||
fr.func_238407_a_(mStack, s, (float) (x - fr.func_238414_a_(s) / 2.0), y, 0xFFFFFF);
|
||||
y+=fr.FONT_HEIGHT;
|
||||
}
|
||||
}
|
||||
public static class LoadingEntryList extends ExtendedList<LoadingEntryList.LoadingMessageEntry> {
|
||||
LoadingEntryList(final LoadingErrorScreen parent, final List<ModLoadingException> errors, final List<ModLoadingWarning> warnings) {
|
||||
super(parent.minecraft, parent.width, parent.height, 35, parent.height - 50, 2 * parent.minecraft.fontRenderer.FONT_HEIGHT + 8);
|
||||
super(parent.field_230706_i_, parent.field_230708_k_, parent.field_230709_l_, 35, parent.field_230709_l_ - 50, 2 * parent.field_230706_i_.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())));
|
||||
func_230513_b_(new LoadingMessageEntry(parent.errorHeader, true));
|
||||
errors.forEach(e->func_230513_b_(new LoadingMessageEntry(new StringTextComponent(e.formatToString()))));
|
||||
if (both) {
|
||||
int maxChars = (this.width - 10) / parent.minecraft.fontRenderer.getStringWidth("-");
|
||||
addEntry(new LoadingMessageEntry("\n" + Strings.repeat("-", maxChars) + "\n"));
|
||||
addEntry(new LoadingMessageEntry(parent.warningHeader, true));
|
||||
int maxChars = (this.field_230670_d_ - 10) / parent.field_230706_i_.fontRenderer.getStringWidth("-");
|
||||
func_230513_b_(new LoadingMessageEntry(new StringTextComponent("\n" + Strings.repeat("-", maxChars) + "\n")));
|
||||
func_230513_b_(new LoadingMessageEntry(parent.warningHeader, true));
|
||||
}
|
||||
warnings.forEach(w->addEntry(new LoadingMessageEntry(w.formatToString())));
|
||||
warnings.forEach(w->func_230513_b_(new LoadingMessageEntry(new StringTextComponent(w.formatToString()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getScrollbarPosition()
|
||||
protected int func_230952_d_()
|
||||
{
|
||||
return this.getRight() - 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowWidth()
|
||||
public int func_230949_c_()
|
||||
{
|
||||
return this.width;
|
||||
return this.field_230670_d_;
|
||||
}
|
||||
|
||||
public class LoadingMessageEntry extends ExtendedList.AbstractListEntry<LoadingMessageEntry> {
|
||||
private final String message;
|
||||
private final ITextComponent message;
|
||||
private final boolean center;
|
||||
|
||||
LoadingMessageEntry(final String message) {
|
||||
LoadingMessageEntry(final ITextComponent message) {
|
||||
this(message, false);
|
||||
}
|
||||
|
||||
LoadingMessageEntry(final String message, final boolean center) {
|
||||
LoadingMessageEntry(final ITextComponent message, final boolean center) {
|
||||
this.message = Objects.requireNonNull(message);
|
||||
this.center = center;
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
public void func_230432_a_(MatrixStack mStack, 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);
|
||||
final List<ITextProperties> strings = font.func_238425_b_(message, LoadingEntryList.this.field_230670_d_);
|
||||
int y = top + 2;
|
||||
for (int i = 0; i < Math.min(strings.size(), 2); i++) {
|
||||
if (center)
|
||||
font.drawString(strings.get(i), left + (width / 2F) - font.getStringWidth(strings.get(i)) / 2F, y, 0xFFFFFF);
|
||||
font.func_238422_b_(mStack, strings.get(i), left + (field_230670_d_) - font.func_238414_a_(strings.get(i)) / 2F, y, 0xFFFFFF);
|
||||
else
|
||||
font.drawString(strings.get(i), left + 5, y, 0xFFFFFF);
|
||||
font.func_238422_b_(mStack, strings.get(i), left + 5, y, 0xFFFFFF);
|
||||
y += font.FONT_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.util.text.*;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -51,9 +53,6 @@ import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.client.gui.ScrollPanel;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.util.Size2i;
|
||||
@@ -91,8 +90,8 @@ public class ModListScreen extends Screen
|
||||
return compare(name1, name2);
|
||||
}
|
||||
|
||||
String getButtonText() {
|
||||
return I18n.format("fml.menu.mods."+StringUtils.toLowerCase(name()));
|
||||
ITextComponent getButtonText() {
|
||||
return new TranslationTextComponent("fml.menu.mods." + StringUtils.toLowerCase(name()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +130,7 @@ public class ModListScreen extends Screen
|
||||
class InfoPanel extends ScrollPanel {
|
||||
private ResourceLocation logoPath;
|
||||
private Size2i logoDims = new Size2i(0, 0);
|
||||
private List<ITextComponent> lines = Collections.emptyList();
|
||||
private List<ITextProperties> lines = Collections.emptyList();
|
||||
|
||||
InfoPanel(Minecraft mcIn, int widthIn, int heightIn, int topIn)
|
||||
{
|
||||
@@ -152,9 +151,9 @@ public class ModListScreen extends Screen
|
||||
this.lines = Collections.emptyList();
|
||||
}
|
||||
|
||||
private List<ITextComponent> resizeContent(List<String> lines)
|
||||
private List<ITextProperties> resizeContent(List<String> lines)
|
||||
{
|
||||
List<ITextComponent> ret = new ArrayList<ITextComponent>();
|
||||
List<ITextProperties> ret = new ArrayList<>();
|
||||
for (String line : lines)
|
||||
{
|
||||
if (line == null)
|
||||
@@ -167,7 +166,7 @@ public class ModListScreen extends Screen
|
||||
int maxTextLength = this.width - 12;
|
||||
if (maxTextLength >= 0)
|
||||
{
|
||||
ret.addAll(RenderComponentsUtil.splitText(chat, maxTextLength, ModListScreen.this.font, false, true));
|
||||
ret.addAll(field_230712_o_.func_238420_b_().func_238362_b_(chat, maxTextLength, Style.field_240709_b_));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -177,7 +176,7 @@ public class ModListScreen extends Screen
|
||||
public int getContentHeight()
|
||||
{
|
||||
int height = 50;
|
||||
height += (lines.size() * font.FONT_HEIGHT);
|
||||
height += (lines.size() * field_230712_o_.FONT_HEIGHT);
|
||||
if (height < this.bottom - this.top - 8)
|
||||
height = this.bottom - this.top - 8;
|
||||
return height;
|
||||
@@ -186,11 +185,11 @@ public class ModListScreen extends Screen
|
||||
@Override
|
||||
protected int getScrollAmount()
|
||||
{
|
||||
return font.FONT_HEIGHT * 3;
|
||||
return field_230712_o_.FONT_HEIGHT * 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawPanel(int entryRight, int relativeY, Tessellator tess, int mouseX, int mouseY)
|
||||
protected void drawPanel(MatrixStack mStack, int entryRight, int relativeY, Tessellator tess, int mouseX, int mouseY)
|
||||
{
|
||||
if (logoPath != null) {
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(logoPath);
|
||||
@@ -198,29 +197,29 @@ public class ModListScreen extends Screen
|
||||
RenderSystem.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
|
||||
int headerHeight = 50;
|
||||
GuiUtils.drawInscribedRect(left + PADDING, relativeY, width - (PADDING * 2), headerHeight, logoDims.width, logoDims.height, false, true);
|
||||
GuiUtils.drawInscribedRect(mStack, left + PADDING, relativeY, width - (PADDING * 2), headerHeight, logoDims.width, logoDims.height, false, true);
|
||||
relativeY += headerHeight + PADDING;
|
||||
}
|
||||
|
||||
for (ITextComponent line : lines)
|
||||
for (ITextProperties line : lines)
|
||||
{
|
||||
if (line != null)
|
||||
{
|
||||
RenderSystem.enableBlend();
|
||||
ModListScreen.this.font.drawStringWithShadow(line.getFormattedText(), left + PADDING, relativeY, 0xFFFFFF);
|
||||
ModListScreen.this.field_230712_o_.func_238407_a_(mStack, line, left + PADDING, relativeY, 0xFFFFFF);
|
||||
RenderSystem.disableAlphaTest();
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
relativeY += font.FONT_HEIGHT;
|
||||
relativeY += field_230712_o_.FONT_HEIGHT;
|
||||
}
|
||||
|
||||
final ITextComponent component = findTextLine(mouseX, mouseY);
|
||||
final Style component = findTextLine(mouseX, mouseY);
|
||||
if (component!=null) {
|
||||
ModListScreen.this.renderComponentHoverEffect(component, mouseX, mouseY);
|
||||
ModListScreen.this.func_238653_a_(mStack, component, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
private ITextComponent findTextLine(final int mouseX, final int mouseY) {
|
||||
private Style findTextLine(final int mouseX, final int mouseY) {
|
||||
double offset = (mouseY - top) + border + scrollDistance + 1;
|
||||
if (logoPath != null) {
|
||||
offset -= 50;
|
||||
@@ -228,35 +227,26 @@ public class ModListScreen extends Screen
|
||||
if (offset <= 0)
|
||||
return null;
|
||||
|
||||
int lineIdx = (int) (offset / font.FONT_HEIGHT);
|
||||
int lineIdx = (int) (offset / field_230712_o_.FONT_HEIGHT);
|
||||
if (lineIdx >= lines.size() || lineIdx < 1)
|
||||
return null;
|
||||
|
||||
ITextComponent line = lines.get(lineIdx-1);
|
||||
ITextProperties line = lines.get(lineIdx-1);
|
||||
if (line != null)
|
||||
{
|
||||
int k = left + border;
|
||||
for (ITextComponent part : line) {
|
||||
if (!(part instanceof StringTextComponent))
|
||||
continue;
|
||||
k += ModListScreen.this.font.getStringWidth(((StringTextComponent)part).getText());
|
||||
if (k >= mouseX)
|
||||
{
|
||||
return part;
|
||||
}
|
||||
}
|
||||
return field_230712_o_.func_238420_b_().func_238357_a_(line, mouseX);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(final double mouseX, final double mouseY, final int button) {
|
||||
final ITextComponent component = findTextLine((int) mouseX, (int) mouseY);
|
||||
public boolean func_231044_a_(final double mouseX, final double mouseY, final int button) {
|
||||
final Style component = findTextLine((int) mouseX, (int) mouseY);
|
||||
if (component != null) {
|
||||
ModListScreen.this.handleComponentClicked(component);
|
||||
ModListScreen.this.func_230455_a_(component);
|
||||
return true;
|
||||
}
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
return super.func_231044_a_(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -265,50 +255,50 @@ public class ModListScreen extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
public void func_231160_c_()
|
||||
{
|
||||
for (ModInfo mod : mods)
|
||||
{
|
||||
listWidth = Math.max(listWidth,getFontRenderer().getStringWidth(mod.getDisplayName()) + 10);
|
||||
listWidth = Math.max(listWidth,getFontRenderer().getStringWidth(MavenVersionStringHelper.artifactVersionToString(mod.getVersion())) + 5);
|
||||
}
|
||||
listWidth = Math.max(Math.min(listWidth, width/3), 100);
|
||||
listWidth = Math.max(Math.min(listWidth, field_230708_k_/3), 100);
|
||||
listWidth += listWidth % numButtons != 0 ? (numButtons - listWidth % numButtons) : 0;
|
||||
|
||||
int modInfoWidth = this.width - this.listWidth - (PADDING * 3);
|
||||
int modInfoWidth = this.field_230708_k_ - this.listWidth - (PADDING * 3);
|
||||
int doneButtonWidth = Math.min(modInfoWidth, 200);
|
||||
int y = this.height - 20 - PADDING;
|
||||
this.addButton(new Button(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20,
|
||||
I18n.format("gui.done"), b -> ModListScreen.this.onClose()));
|
||||
this.addButton(this.openModsFolderButton = new Button(6, y, this.listWidth, 20,
|
||||
I18n.format("fml.menu.mods.openmodsfolder"), b -> Util.getOSType().openFile(FMLPaths.MODSDIR.get().toFile())));
|
||||
int y = this.field_230709_l_ - 20 - PADDING;
|
||||
this.func_230480_a_(new Button(((listWidth + PADDING + this.field_230708_k_ - doneButtonWidth) / 2), y, doneButtonWidth, 20,
|
||||
new TranslationTextComponent("gui.done"), b -> ModListScreen.this.func_231175_as__()));
|
||||
this.func_230480_a_(this.openModsFolderButton = new Button(6, y, this.listWidth, 20,
|
||||
new TranslationTextComponent("fml.menu.mods.openmodsfolder"), b -> Util.getOSType().openFile(FMLPaths.MODSDIR.get().toFile())));
|
||||
y -= 20 + PADDING;
|
||||
this.addButton(this.configButton = new Button(6, y, this.listWidth, 20,
|
||||
I18n.format("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig()));
|
||||
this.configButton.active = false;
|
||||
this.func_230480_a_(this.configButton = new Button(6, y, this.listWidth, 20,
|
||||
new TranslationTextComponent("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig()));
|
||||
this.configButton.field_230693_o_ = false;
|
||||
|
||||
y -= 14 + PADDING + 1;
|
||||
search = new TextFieldWidget(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, I18n.format("fml.menu.mods.search"));
|
||||
search = new TextFieldWidget(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, new TranslationTextComponent("fml.menu.mods.search"));
|
||||
|
||||
int fullButtonHeight = PADDING + 20 + PADDING;
|
||||
this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.y - getFontRenderer().FONT_HEIGHT - PADDING);
|
||||
this.modList.setLeftPos(6);
|
||||
this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.field_230691_m_ - getFontRenderer().FONT_HEIGHT - PADDING);
|
||||
this.modList.func_230959_g_(6);
|
||||
|
||||
this.modInfo = new InfoPanel(this.minecraft, modInfoWidth, this.height - PADDING - fullButtonHeight, PADDING);
|
||||
this.modInfo = new InfoPanel(this.field_230706_i_, modInfoWidth, this.field_230709_l_ - PADDING - fullButtonHeight, PADDING);
|
||||
|
||||
children.add(search);
|
||||
children.add(modList);
|
||||
children.add(modInfo);
|
||||
field_230705_e_.add(search);
|
||||
field_230705_e_.add(modList);
|
||||
field_230705_e_.add(modInfo);
|
||||
search.setFocused2(false);
|
||||
search.setCanLoseFocus(true);
|
||||
|
||||
final int width = listWidth / numButtons;
|
||||
int x = PADDING;
|
||||
addButton(SortType.NORMAL.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL)));
|
||||
func_230480_a_(SortType.NORMAL.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL)));
|
||||
x += width + buttonMargin;
|
||||
addButton(SortType.A_TO_Z.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.A_TO_Z.getButtonText(), b -> resortMods(SortType.A_TO_Z)));
|
||||
func_230480_a_(SortType.A_TO_Z.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.A_TO_Z.getButtonText(), b -> resortMods(SortType.A_TO_Z)));
|
||||
x += width + buttonMargin;
|
||||
addButton(SortType.Z_TO_A.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.Z_TO_A.getButtonText(), b -> resortMods(SortType.Z_TO_A)));
|
||||
func_230480_a_(SortType.Z_TO_A.button = new Button(x, PADDING, width - buttonMargin, 20, SortType.Z_TO_A.getButtonText(), b -> resortMods(SortType.Z_TO_A)));
|
||||
resortMods(SortType.NORMAL);
|
||||
updateCache();
|
||||
}
|
||||
@@ -318,7 +308,7 @@ public class ModListScreen extends Screen
|
||||
if (selected == null) return;
|
||||
try
|
||||
{
|
||||
ConfigGuiHandler.getGuiFactoryFor(selected.getInfo()).map(f->f.apply(this.minecraft, this)).ifPresent(newScreen -> this.minecraft.displayGuiScreen(newScreen));
|
||||
ConfigGuiHandler.getGuiFactoryFor(selected.getInfo()).map(f->f.apply(this.field_230706_i_, this)).ifPresent(newScreen -> this.field_230706_i_.displayGuiScreen(newScreen));
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
@@ -327,10 +317,10 @@ public class ModListScreen extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
public void func_231023_e_()
|
||||
{
|
||||
search.tick();
|
||||
modList.setSelected(selected);
|
||||
modList.func_241215_a_(selected);
|
||||
|
||||
if (!search.getText().equals(lastFilterText))
|
||||
{
|
||||
@@ -345,7 +335,7 @@ public class ModListScreen extends Screen
|
||||
modList.refreshList();
|
||||
if (selected != null)
|
||||
{
|
||||
selected = modList.children().stream().filter(e -> e.getInfo() == selected.getInfo()).findFirst().orElse(null);
|
||||
selected = modList.func_231039_at__().stream().filter(e -> e.getInfo() == selected.getInfo()).findFirst().orElse(null);
|
||||
updateCache();
|
||||
}
|
||||
sorted = true;
|
||||
@@ -371,33 +361,33 @@ public class ModListScreen extends Screen
|
||||
for (SortType sort : SortType.values())
|
||||
{
|
||||
if (sort.button != null)
|
||||
sort.button.active = sortType != sort;
|
||||
sort.button.field_230693_o_ = sortType != sort;
|
||||
}
|
||||
sorted = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks)
|
||||
public void func_230430_a_(MatrixStack mStack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.modList.render(mouseX, mouseY, partialTicks);
|
||||
this.modList.func_230430_a_(mStack, mouseX, mouseY, partialTicks);
|
||||
if (this.modInfo != null)
|
||||
this.modInfo.render(mouseX, mouseY, partialTicks);
|
||||
this.modInfo.func_230430_a_(mStack, mouseX, mouseY, partialTicks);
|
||||
|
||||
String text = I18n.format("fml.menu.mods.search");
|
||||
int x = modList.getLeft() + ((modList.getRight() - modList.getLeft()) / 2) - (getFontRenderer().getStringWidth(text) / 2);
|
||||
getFontRenderer().drawString(text, x, search.y - getFontRenderer().FONT_HEIGHT, 0xFFFFFF);
|
||||
this.search.render(mouseX, mouseY, partialTicks);
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
ITextComponent text = new TranslationTextComponent("fml.menu.mods.search");
|
||||
int x = modList.getLeft() + ((modList.getRight() - modList.getLeft()) / 2) - (getFontRenderer().func_238414_a_(text) / 2);
|
||||
getFontRenderer().func_238422_b_(mStack, text, x, search.field_230691_m_ - getFontRenderer().FONT_HEIGHT, 0xFFFFFF);
|
||||
this.search.func_230430_a_(mStack, mouseX , mouseY, partialTicks);
|
||||
super.func_230430_a_(mStack, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
public Minecraft getMinecraftInstance()
|
||||
{
|
||||
return minecraft;
|
||||
return field_230706_i_;
|
||||
}
|
||||
|
||||
public FontRenderer getFontRenderer()
|
||||
{
|
||||
return font;
|
||||
return field_230712_o_;
|
||||
}
|
||||
|
||||
public void setSelected(ModListWidget.ModEntry entry)
|
||||
@@ -409,18 +399,18 @@ public class ModListScreen extends Screen
|
||||
private void updateCache()
|
||||
{
|
||||
if (selected == null) {
|
||||
this.configButton.active = false;
|
||||
this.configButton.field_230693_o_ = false;
|
||||
this.modInfo.clearInfo();
|
||||
return;
|
||||
}
|
||||
ModInfo selectedMod = selected.getInfo();
|
||||
this.configButton.active = ConfigGuiHandler.getGuiFactoryFor(selectedMod).isPresent();
|
||||
this.configButton.field_230693_o_ = ConfigGuiHandler.getGuiFactoryFor(selectedMod).isPresent();
|
||||
List<String> lines = new ArrayList<>();
|
||||
VersionChecker.CheckResult vercheck = VersionChecker.getResult(selectedMod);
|
||||
|
||||
Pair<ResourceLocation, Size2i> logoData = selectedMod.getLogoFile().map(logoFile->
|
||||
{
|
||||
TextureManager tm = this.minecraft.getTextureManager();
|
||||
TextureManager tm = this.field_230706_i_.getTextureManager();
|
||||
final ModFileResourcePack resourcePack = ResourcePackLoader.getResourcePackFor(selectedMod.getModId())
|
||||
.orElse(ResourcePackLoader.getResourcePackFor("forge").
|
||||
orElseThrow(()->new RuntimeException("Can't find forge, WHAT!")));
|
||||
@@ -487,12 +477,12 @@ public class ModListScreen extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(Minecraft mc, int width, int height)
|
||||
public void func_231152_a_(Minecraft mc, int width, int height)
|
||||
{
|
||||
String s = this.search.getText();
|
||||
SortType sort = this.sortType;
|
||||
ModListWidget.ModEntry selected = this.selected;
|
||||
this.init(mc, width, height);
|
||||
this.func_231158_b_(mc, width, height);
|
||||
this.search.setText(s);
|
||||
this.selected = selected;
|
||||
if (!this.search.getText().isEmpty())
|
||||
@@ -503,8 +493,8 @@ public class ModListScreen extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose()
|
||||
public void func_231175_as__()
|
||||
{
|
||||
this.minecraft.displayGuiScreen(this.parentScreen);
|
||||
this.field_230706_i_.displayGuiScreen(this.parentScreen);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package net.minecraftforge.fml.client.gui.screen;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -41,22 +42,22 @@ public class NotificationScreen extends Screen
|
||||
protected int getContentHeight()
|
||||
{
|
||||
int height = 0;
|
||||
height += (textLines.length * font.FONT_HEIGHT) + 4;
|
||||
height += (textLines.length * field_230712_o_.FONT_HEIGHT) + 4;
|
||||
if (height < this.height - 50)
|
||||
height = this.height - 50;
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawPanel(int entryRight, int relativeY, Tessellator tess, int mouseX, int mouseY)
|
||||
protected void drawPanel(MatrixStack mStack, int entryRight, int relativeY, Tessellator tess, int mouseX, int mouseY)
|
||||
{
|
||||
drawCenteredLines(relativeY, textLines);
|
||||
drawCenteredLines(mStack, relativeY, textLines);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getScrollAmount()
|
||||
{
|
||||
return font.FONT_HEIGHT * 3;
|
||||
return field_230712_o_.FONT_HEIGHT * 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,53 +81,53 @@ public class NotificationScreen extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
public void func_231160_c_()
|
||||
{
|
||||
super.init();
|
||||
int panelY = PADDING + headerLines.length * font.FONT_HEIGHT + PADDING;
|
||||
int panelHeight = this.height - PADDING - 20 - panelY;
|
||||
super.func_231160_c_();
|
||||
int panelY = PADDING + headerLines.length * field_230712_o_.FONT_HEIGHT + PADDING;
|
||||
int panelHeight = this.field_230709_l_ - PADDING - 20 - panelY;
|
||||
if (!action.isEmpty()) {
|
||||
panelHeight = panelHeight - font.FONT_HEIGHT - PADDING;
|
||||
panelHeight = panelHeight - field_230712_o_.FONT_HEIGHT - PADDING;
|
||||
}
|
||||
textPanel = new TextPanel(this.minecraft, this.width - (PADDING * 2), panelHeight, panelY, PADDING);
|
||||
this.children.add(textPanel);
|
||||
textPanel = new TextPanel(this.field_230706_i_, this.field_230708_k_ - (PADDING * 2), panelHeight, panelY, PADDING);
|
||||
this.field_230705_e_.add(textPanel);
|
||||
addConfirmationButtons();
|
||||
}
|
||||
|
||||
protected void addConfirmationButtons() {
|
||||
this.buttons.add(new Button(this.width / 2 - 100, this.height - PADDING - 20, 200, 20, I18n.format("gui.done"), b -> {
|
||||
NotificationScreen.this.minecraft.displayGuiScreen(null);
|
||||
this.field_230710_m_.add(new Button(this.field_230708_k_ / 2 - 100, this.field_230709_l_ - PADDING - 20, 200, 20, new TranslationTextComponent("gui.done"), b -> {
|
||||
NotificationScreen.this.field_230706_i_.displayGuiScreen(null);
|
||||
query.finish();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks)
|
||||
public void func_230430_a_(MatrixStack mStack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.renderBackground();
|
||||
this.func_230446_a_(mStack);
|
||||
|
||||
drawCenteredLines(PADDING, headerLines);
|
||||
drawCenteredLines(mStack, PADDING, headerLines);
|
||||
|
||||
if (textPanel != null)
|
||||
{
|
||||
textPanel.render(mouseX, mouseY, partialTicks);
|
||||
textPanel.func_230430_a_(mStack, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
if (!action.isEmpty())
|
||||
{
|
||||
drawCenteredString(font, action, this.width / 2, this.height - PADDING - 20 - font.FONT_HEIGHT, -1);
|
||||
func_238471_a_(mStack, field_230712_o_, action, this.field_230708_k_ / 2, this.field_230709_l_ - PADDING - 20 - field_230712_o_.FONT_HEIGHT, -1);
|
||||
}
|
||||
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
super.func_230430_a_(mStack, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
protected void drawCenteredLines(int yStart, String... lines)
|
||||
protected void drawCenteredLines(MatrixStack mStack, int yStart, String... lines)
|
||||
{
|
||||
for (String line : lines)
|
||||
{
|
||||
if (!line.isEmpty())
|
||||
this.drawCenteredString(font, line, this.width / 2, yStart, 0xFFFFFF);
|
||||
yStart += font.FONT_HEIGHT;
|
||||
this.func_238471_a_(mStack, field_230712_o_, line, this.field_230708_k_ / 2, yStart, 0xFFFFFF);
|
||||
yStart += field_230712_o_.FONT_HEIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,12 @@
|
||||
|
||||
package net.minecraftforge.fml.client.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
/**
|
||||
@@ -35,7 +39,7 @@ import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
*/
|
||||
public class ExtendedButton extends Button
|
||||
{
|
||||
public ExtendedButton(int xPos, int yPos, int width, int height, String displayString, IPressable handler)
|
||||
public ExtendedButton(int xPos, int yPos, int width, int height, ITextComponent displayString, IPressable handler)
|
||||
{
|
||||
super(xPos, yPos, width, height, displayString, handler);
|
||||
}
|
||||
@@ -44,24 +48,25 @@ public class ExtendedButton extends Button
|
||||
* Draws this button to the screen.
|
||||
*/
|
||||
@Override
|
||||
public void renderButton(int mouseX, int mouseY, float partial)
|
||||
public void func_230431_b_(MatrixStack mStack, int mouseX, int mouseY, float partial)
|
||||
{
|
||||
if (this.visible)
|
||||
if (this.field_230694_p_)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
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(WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset());
|
||||
this.renderBg(mc, mouseX, mouseY);
|
||||
this.field_230692_n_ = mouseX >= this.field_230690_l_ && mouseY >= this.field_230691_m_ && mouseX < this.field_230690_l_ + this.field_230688_j_ && mouseY < this.field_230691_m_ + this.field_230689_k_;
|
||||
int k = this.func_230989_a_(this.func_230449_g_());
|
||||
GuiUtils.drawContinuousTexturedBox(field_230687_i_, this.field_230690_l_, this.field_230691_m_, 0, 46 + k * 20, this.field_230688_j_, this.field_230689_k_, 200, 20, 2, 3, 2, 2, this.func_230927_p_());
|
||||
this.func_230441_a_(mStack, mc, mouseX, mouseY);
|
||||
|
||||
String buttonText = this.getMessage();
|
||||
int strWidth = mc.fontRenderer.getStringWidth(buttonText);
|
||||
ITextComponent buttonText = this.func_230442_c_();
|
||||
int strWidth = mc.fontRenderer.func_238414_a_(buttonText);
|
||||
int ellipsisWidth = mc.fontRenderer.getStringWidth("...");
|
||||
|
||||
if (strWidth > width - 6 && strWidth > ellipsisWidth)
|
||||
buttonText = mc.fontRenderer.trimStringToWidth(buttonText, width - 6 - ellipsisWidth).trim() + "...";
|
||||
if (strWidth > field_230688_j_ - 6 && strWidth > ellipsisWidth)
|
||||
//TODO, srg names make it hard to figure out how to append to an ITextProperties from this trim operation, wraping this in StringTextComponent is kinda dirty.
|
||||
buttonText = new StringTextComponent(mc.fontRenderer.func_238417_a_(buttonText, field_230688_j_ - 6 - ellipsisWidth).getString() + "...");
|
||||
|
||||
this.drawCenteredString(mc.fontRenderer, buttonText, this.x + this.width / 2, this.y + (this.height - 8) / 2, getFGColor());
|
||||
this.func_238472_a_(mStack, mc.fontRenderer, buttonText, this.field_230690_l_ + this.field_230688_j_ / 2, this.field_230691_m_ + (this.field_230689_k_ - 8) / 2, getFGColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,14 @@
|
||||
|
||||
package net.minecraftforge.fml.client.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.widget.list.ExtendedList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.fml.client.gui.screen.ModListScreen;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import net.minecraftforge.fml.MavenVersionStringHelper;
|
||||
@@ -42,33 +45,33 @@ public class ModListWidget extends ExtendedList<ModListWidget.ModEntry>
|
||||
|
||||
public ModListWidget(ModListScreen parent, int listWidth, int top, int bottom)
|
||||
{
|
||||
super(parent.getMinecraftInstance(), listWidth, parent.height, top, bottom, parent.getFontRenderer().FONT_HEIGHT * 2 + 8);
|
||||
super(parent.getMinecraftInstance(), listWidth, parent.field_230709_l_, top, bottom, parent.getFontRenderer().FONT_HEIGHT * 2 + 8);
|
||||
this.parent = parent;
|
||||
this.listWidth = listWidth;
|
||||
this.refreshList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getScrollbarPosition()
|
||||
protected int func_230952_d_()
|
||||
{
|
||||
return this.listWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowWidth()
|
||||
public int func_230949_c_()
|
||||
{
|
||||
return this.listWidth;
|
||||
}
|
||||
|
||||
public void refreshList() {
|
||||
this.clearEntries();
|
||||
parent.buildModList(this::addEntry, mod->new ModEntry(mod, this.parent));
|
||||
this.func_230963_j_();
|
||||
parent.buildModList(this::func_230513_b_, mod->new ModEntry(mod, this.parent));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBackground()
|
||||
protected void func_230433_a_(MatrixStack mStack)
|
||||
{
|
||||
this.parent.renderBackground();
|
||||
this.parent.func_230446_a_(mStack);
|
||||
}
|
||||
|
||||
public class ModEntry extends ExtendedList.AbstractListEntry<ModEntry> {
|
||||
@@ -81,30 +84,30 @@ public class ModListWidget extends ExtendedList<ModListWidget.ModEntry>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks)
|
||||
public void func_230432_a_(MatrixStack mStack, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks)
|
||||
{
|
||||
String name = stripControlCodes(modInfo.getDisplayName());
|
||||
String version = stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion()));
|
||||
ITextComponent name = new StringTextComponent(stripControlCodes(modInfo.getDisplayName()));
|
||||
ITextComponent version = new StringTextComponent(stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion())));
|
||||
VersionChecker.CheckResult vercheck = VersionChecker.getResult(modInfo);
|
||||
FontRenderer font = this.parent.getFontRenderer();
|
||||
font.drawString(font.trimStringToWidth(name, listWidth),left + 3, top + 2, 0xFFFFFF);
|
||||
font.drawString(font.trimStringToWidth(version, listWidth), left + 3 , top + 2 + font.FONT_HEIGHT, 0xCCCCCC);
|
||||
font.func_238422_b_(mStack, font.func_238417_a_(name, listWidth),left + 3, top + 2, 0xFFFFFF);
|
||||
font.func_238422_b_(mStack, font.func_238417_a_(version, listWidth), left + 3 , top + 2 + font.FONT_HEIGHT, 0xCCCCCC);
|
||||
if (vercheck.status.shouldDraw())
|
||||
{
|
||||
//TODO: Consider adding more icons for visualization
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(VERSION_CHECK_ICONS);
|
||||
RenderSystem.color4f(1, 1, 1, 1);
|
||||
RenderSystem.pushMatrix();
|
||||
AbstractGui.blit(getLeft() + width - 12, top + entryHeight / 4, vercheck.status.getSheetOffset() * 8, (vercheck.status.isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
|
||||
AbstractGui.func_238463_a_(mStack, getLeft() + field_230670_d_ - 12, top + entryHeight / 4, vercheck.status.getSheetOffset() * 8, (vercheck.status.isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_)
|
||||
public boolean func_231044_a_(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_)
|
||||
{
|
||||
parent.setSelected(this);
|
||||
ModListWidget.this.setSelected(this);
|
||||
ModListWidget.this.func_241215_a_(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
|
||||
package net.minecraftforge.fml.client.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -34,7 +37,7 @@ public class Slider extends ExtendedButton
|
||||
/** The value of this slider control. */
|
||||
public double sliderValue = 1.0F;
|
||||
|
||||
public String dispString = "";
|
||||
public ITextComponent dispString;
|
||||
|
||||
/** Is this slider control being dragged. */
|
||||
public boolean dragging = false;
|
||||
@@ -47,16 +50,16 @@ public class Slider extends ExtendedButton
|
||||
@Nullable
|
||||
public ISlider parent = null;
|
||||
|
||||
public String suffix = "";
|
||||
public ITextComponent suffix;
|
||||
|
||||
public boolean drawString = true;
|
||||
|
||||
public Slider(int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, IPressable handler)
|
||||
public Slider(int xPos, int yPos, int width, int height, ITextComponent prefix, ITextComponent suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, IPressable handler)
|
||||
{
|
||||
this(xPos, yPos, width, height, prefix, suf, minVal, maxVal, currentVal, showDec, drawStr, handler, null);
|
||||
}
|
||||
|
||||
public Slider(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)
|
||||
public Slider(int xPos, int yPos, int width, int height, ITextComponent prefix, ITextComponent suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, IPressable handler, @Nullable ISlider par)
|
||||
{
|
||||
super(xPos, yPos, width, height, prefix, handler);
|
||||
minValue = minVal;
|
||||
@@ -79,16 +82,16 @@ public class Slider extends ExtendedButton
|
||||
precision = 0;
|
||||
}
|
||||
|
||||
setMessage(dispString + val + suffix);
|
||||
func_238482_a_(new StringTextComponent("").func_230529_a_(dispString).func_240702_b_(val).func_230529_a_(suffix));
|
||||
|
||||
drawString = drawStr;
|
||||
if(!drawString)
|
||||
setMessage("");
|
||||
func_238482_a_(new StringTextComponent(""));
|
||||
}
|
||||
|
||||
public Slider(int xPos, int yPos, String displayStr, double minVal, double maxVal, double currentVal, IPressable handler, ISlider par)
|
||||
public Slider(int xPos, int yPos, ITextComponent displayStr, double minVal, double maxVal, double currentVal, IPressable handler, ISlider par)
|
||||
{
|
||||
this(xPos, yPos, 150, 20, displayStr, "", minVal, maxVal, currentVal, true, true, handler, par);
|
||||
this(xPos, yPos, 150, 20, displayStr, new StringTextComponent(""), minVal, maxVal, currentVal, true, true, handler, par);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +99,7 @@ public class Slider extends ExtendedButton
|
||||
* this button.
|
||||
*/
|
||||
@Override
|
||||
public int getYImage(boolean par1)
|
||||
public int func_230989_a_(boolean par1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -105,17 +108,17 @@ public class Slider extends ExtendedButton
|
||||
* Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e).
|
||||
*/
|
||||
@Override
|
||||
protected void renderBg(Minecraft par1Minecraft, int par2, int par3)
|
||||
protected void func_230441_a_(MatrixStack mStack, Minecraft par1Minecraft, int par2, int par3)
|
||||
{
|
||||
if (this.visible)
|
||||
if (this.field_230694_p_)
|
||||
{
|
||||
if (this.dragging)
|
||||
{
|
||||
this.sliderValue = (par2 - (this.x + 4)) / (float)(this.width - 8);
|
||||
this.sliderValue = (par2 - (this.field_230690_l_ + 4)) / (float)(this.field_230688_j_ - 8);
|
||||
updateSlider();
|
||||
}
|
||||
|
||||
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.getBlitOffset());
|
||||
GuiUtils.drawContinuousTexturedBox(field_230687_i_, this.field_230690_l_ + (int)(this.sliderValue * (float)(this.field_230688_j_ - 8)), this.field_230691_m_, 0, 66, 8, this.field_230689_k_, 200, 20, 2, 3, 2, 2, this.func_230927_p_());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,9 +127,9 @@ public class Slider extends ExtendedButton
|
||||
* e).
|
||||
*/
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY)
|
||||
public void func_230982_a_(double mouseX, double mouseY)
|
||||
{
|
||||
this.sliderValue = (mouseX - (this.x + 4)) / (this.width - 8);
|
||||
this.sliderValue = (mouseX - (this.field_230690_l_ + 4)) / (this.field_230688_j_ - 8);
|
||||
updateSlider();
|
||||
this.dragging = true;
|
||||
}
|
||||
@@ -173,7 +176,7 @@ public class Slider extends ExtendedButton
|
||||
|
||||
if(drawString)
|
||||
{
|
||||
setMessage(dispString + val + suffix);
|
||||
func_238482_a_(new StringTextComponent("").func_230529_a_(dispString).func_240702_b_(val).func_230529_a_(suffix));
|
||||
}
|
||||
|
||||
if (parent != null)
|
||||
@@ -186,7 +189,7 @@ public class Slider extends ExtendedButton
|
||||
* Fired when the mouse button is released. Equivalent of MouseListener.mouseReleased(MouseEvent e).
|
||||
*/
|
||||
@Override
|
||||
public void onRelease(double mouseX, double mouseY)
|
||||
public void func_231000_a__(double mouseX, double mouseY)
|
||||
{
|
||||
this.dragging = false;
|
||||
}
|
||||
|
||||
@@ -19,10 +19,12 @@
|
||||
|
||||
package net.minecraftforge.fml.client.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
/**
|
||||
@@ -35,7 +37,7 @@ public class UnicodeGlyphButton extends ExtendedButton
|
||||
public String glyph;
|
||||
public float glyphScale;
|
||||
|
||||
public UnicodeGlyphButton(int xPos, int yPos, int width, int height, String displayString, String glyph, float glyphScale, IPressable handler)
|
||||
public UnicodeGlyphButton(int xPos, int yPos, int width, int height, ITextComponent displayString, String glyph, float glyphScale, IPressable handler)
|
||||
{
|
||||
super(xPos, yPos, width, height, displayString, handler);
|
||||
this.glyph = glyph;
|
||||
@@ -43,37 +45,38 @@ public class UnicodeGlyphButton extends ExtendedButton
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partial)
|
||||
public void func_230430_a_(MatrixStack mStack, int mouseX, int mouseY, float partial)
|
||||
{
|
||||
if (this.visible)
|
||||
if (this.field_230694_p_)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
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.getBlitOffset());
|
||||
this.renderBg(mc, mouseX, mouseY);
|
||||
this.field_230692_n_ = mouseX >= this.field_230690_l_ && mouseY >= this.field_230691_m_ && mouseX < this.field_230690_l_ + this.field_230688_j_ && mouseY < this.field_230691_m_ + this.field_230689_k_;
|
||||
int k = this.func_230989_a_(this.field_230692_n_);
|
||||
GuiUtils.drawContinuousTexturedBox(Button.field_230687_i_, this.field_230690_l_, this.field_230691_m_, 0, 46 + k * 20, this.field_230688_j_, this.field_230689_k_, 200, 20, 2, 3, 2, 2, this.func_230927_p_());
|
||||
this.func_230441_a_(mStack, mc, mouseX, mouseY);
|
||||
|
||||
String buttonText = this.getMessage();
|
||||
ITextComponent buttonText = this.func_230442_c_();
|
||||
int glyphWidth = (int) (mc.fontRenderer.getStringWidth(glyph) * glyphScale);
|
||||
int strWidth = mc.fontRenderer.getStringWidth(buttonText);
|
||||
int strWidth = mc.fontRenderer.func_238414_a_(buttonText);
|
||||
int ellipsisWidth = mc.fontRenderer.getStringWidth("...");
|
||||
int totalWidth = strWidth + glyphWidth;
|
||||
|
||||
if (totalWidth > width - 6 && totalWidth > ellipsisWidth)
|
||||
buttonText = mc.fontRenderer.trimStringToWidth(buttonText, width - 6 - ellipsisWidth).trim() + "...";
|
||||
if (totalWidth > field_230688_j_ - 6 && totalWidth > ellipsisWidth)
|
||||
buttonText = new StringTextComponent(mc.fontRenderer.func_238417_a_(buttonText, field_230688_j_ - 6 - ellipsisWidth).getString().trim() + "...") ;
|
||||
|
||||
strWidth = mc.fontRenderer.getStringWidth(buttonText);
|
||||
strWidth = mc.fontRenderer.func_238414_a_(buttonText);
|
||||
totalWidth = glyphWidth + strWidth;
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.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), getFGColor());
|
||||
RenderSystem.popMatrix();
|
||||
mStack.push();
|
||||
mStack.scale(glyphScale, glyphScale, 1.0F);
|
||||
this.func_238472_a_(mStack, mc.fontRenderer, new StringTextComponent(glyph),
|
||||
(int) (((this.field_230690_l_ + (this.field_230688_j_ / 2) - (strWidth / 2)) / glyphScale) - (glyphWidth / (2 * glyphScale)) + 2),
|
||||
(int) (((this.field_230691_m_ + ((this.field_230689_k_ - 8) / glyphScale) / 2) - 1) / glyphScale), getFGColor());
|
||||
mStack.pop();
|
||||
|
||||
this.func_238472_a_(mStack, mc.fontRenderer, buttonText, (int) (this.field_230690_l_ + (this.field_230688_j_ / 2) + (glyphWidth / glyphScale)),
|
||||
this.field_230691_m_ + (this.field_230689_k_ - 8) / 2, getFGColor());
|
||||
|
||||
this.drawCenteredString(mc.fontRenderer, buttonText, (int) (this.x + (this.width / 2) + (glyphWidth / glyphScale)),
|
||||
this.y + (this.height - 8) / 2, getFGColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.client.model.animation.Animation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
@@ -33,10 +32,11 @@ import net.minecraftforge.event.TickEvent;
|
||||
|
||||
public class BasicEventHooks
|
||||
{
|
||||
public static void firePlayerChangedDimensionEvent(PlayerEntity player, DimensionType fromDim, DimensionType toDim)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim));
|
||||
}
|
||||
//TODO Dimensions..
|
||||
// public static void firePlayerChangedDimensionEvent(PlayerEntity player, DimensionType fromDim, DimensionType toDim)
|
||||
// {
|
||||
// MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim));
|
||||
// }
|
||||
|
||||
public static void firePlayerLoggedIn(PlayerEntity player)
|
||||
{
|
||||
|
||||
@@ -32,11 +32,9 @@ import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.FuzzedBiomeMagnifier;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.ModDimension;
|
||||
import net.minecraftforge.fml.LogicalSidedProvider;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
@@ -79,7 +77,7 @@ public class FMLPlayMessages
|
||||
this.pitch = (byte) MathHelper.floor(e.rotationPitch * 256.0F / 360.0F);
|
||||
this.yaw = (byte) MathHelper.floor(e.rotationYaw * 256.0F / 360.0F);
|
||||
this.headYaw = (byte) (e.getRotationYawHead() * 256.0F / 360.0F);
|
||||
Vec3d vec3d = e.getMotion();
|
||||
Vector3d vec3d = e.getMotion();
|
||||
double d1 = MathHelper.clamp(vec3d.x, -3.9D, 3.9D);
|
||||
double d2 = MathHelper.clamp(vec3d.y, -3.9D, 3.9D);
|
||||
double d3 = MathHelper.clamp(vec3d.z, -3.9D, 3.9D);
|
||||
@@ -311,7 +309,8 @@ public class FMLPlayMessages
|
||||
}
|
||||
}
|
||||
|
||||
public static class DimensionInfoMessage
|
||||
//TODO Dimensions..
|
||||
/*public static class DimensionInfoMessage
|
||||
{
|
||||
private ResourceLocation dimName;
|
||||
private boolean skylight;
|
||||
@@ -365,5 +364,5 @@ public class FMLPlayMessages
|
||||
contextSupplier.get().enqueueWork(()-> NetworkHooks.addCachedDimensionType(message.makeDummyDimensionType(), message.dimName));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -26,13 +26,8 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.fml.common.thread.EffectiveSide;
|
||||
import net.minecraftforge.registries.ClearableRegistry;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -112,13 +107,14 @@ public class NetworkHooks
|
||||
FMLMCRegisterPacketHandler.INSTANCE.sendRegistry(manager, NetworkDirection.valueOf(direction));
|
||||
}
|
||||
|
||||
public synchronized static void sendDimensionDataPacket(NetworkManager manager, ServerPlayerEntity player) {
|
||||
//TODO Dimensions..
|
||||
/* public synchronized static void sendDimensionDataPacket(NetworkManager manager, ServerPlayerEntity player) {
|
||||
// don't send vanilla dims
|
||||
if (player.dimension.isVanilla()) return;
|
||||
// don't sent to local - we already have a valid dim registry locally
|
||||
if (manager.isLocalChannel()) return;
|
||||
FMLNetworkConstants.playChannel.sendTo(new FMLPlayMessages.DimensionInfoMessage(player.dimension), manager, NetworkDirection.PLAY_TO_CLIENT);
|
||||
}
|
||||
}*/
|
||||
|
||||
public static void handleClientLoginSuccess(NetworkManager manager) {
|
||||
if (manager == null || manager.channel() == null) throw new NullPointerException("ARGH! Network Manager is null (" + manager != null ? "CHANNEL" : "MANAGER"+")" );
|
||||
@@ -212,16 +208,4 @@ public class NetworkHooks
|
||||
player.openContainer.addListener(player);
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerContainerEvent.Open(player, c));
|
||||
}
|
||||
|
||||
// internal tracking map for custom dimensions received from servers for use on client.
|
||||
private static Int2ObjectMap<DimensionType> trackingMap = new Int2ObjectOpenHashMap<>();
|
||||
public static DimensionType getDummyDimType(final int dimension) {
|
||||
return trackingMap.computeIfAbsent(dimension, id -> DimensionType.getById(id));
|
||||
}
|
||||
|
||||
static void addCachedDimensionType(final DimensionType dimensionType, final ResourceLocation dimName) {
|
||||
trackingMap.put(dimensionType.getId(), dimensionType);
|
||||
final ClearableRegistry<DimensionType> dimtypereg = (ClearableRegistry<DimensionType>) Registry.DIMENSION_TYPE;
|
||||
dimtypereg.register(dimensionType.getId(), dimName, dimensionType);
|
||||
}
|
||||
}
|
||||
@@ -98,11 +98,12 @@ class NetworkInitialization {
|
||||
consumer(FMLPlayMessages.OpenContainer::handle).
|
||||
add();
|
||||
|
||||
playChannel.messageBuilder(FMLPlayMessages.DimensionInfoMessage.class, 2)
|
||||
.decoder(FMLPlayMessages.DimensionInfoMessage::decode)
|
||||
.encoder(FMLPlayMessages.DimensionInfoMessage::encode)
|
||||
.consumer(FMLPlayMessages.DimensionInfoMessage::handle)
|
||||
.add();
|
||||
//TODO Dimensions..
|
||||
// playChannel.messageBuilder(FMLPlayMessages.DimensionInfoMessage.class, 2)
|
||||
// .decoder(FMLPlayMessages.DimensionInfoMessage::decode)
|
||||
// .encoder(FMLPlayMessages.DimensionInfoMessage::encode)
|
||||
// .consumer(FMLPlayMessages.DimensionInfoMessage::handle)
|
||||
// .add();
|
||||
|
||||
return playChannel;
|
||||
}
|
||||
|
||||
@@ -25,9 +25,10 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.server.ServerChunkProvider;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.LogicalSidedProvider;
|
||||
|
||||
@@ -55,7 +56,7 @@ public class PacketDistributor<T> {
|
||||
* <br/>
|
||||
* {@link #with(Supplier)} DimensionType
|
||||
*/
|
||||
public static final PacketDistributor<DimensionType> DIMENSION = new PacketDistributor<>(PacketDistributor::playerListDimConsumer, NetworkDirection.PLAY_TO_CLIENT);
|
||||
public static final PacketDistributor<RegistryKey<World>> DIMENSION = new PacketDistributor<>(PacketDistributor::playerListDimConsumer, NetworkDirection.PLAY_TO_CLIENT);
|
||||
/**
|
||||
* Send to everyone near the {@link TargetPoint} specified in the Supplier
|
||||
* <br/>
|
||||
@@ -106,7 +107,7 @@ public class PacketDistributor<T> {
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final double r2;
|
||||
private final DimensionType dim;
|
||||
private final RegistryKey<World> dim;
|
||||
|
||||
/**
|
||||
* A target point with excluded entity
|
||||
@@ -118,7 +119,7 @@ public class PacketDistributor<T> {
|
||||
* @param r2 Radius
|
||||
* @param dim DimensionType
|
||||
*/
|
||||
public TargetPoint(final ServerPlayerEntity excluded, final double x, final double y, final double z, final double r2, final DimensionType dim) {
|
||||
public TargetPoint(final ServerPlayerEntity excluded, final double x, final double y, final double z, final double r2, final RegistryKey<World> dim) {
|
||||
this.excluded = excluded;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -135,7 +136,7 @@ public class PacketDistributor<T> {
|
||||
* @param r2 Radius
|
||||
* @param dim DimensionType
|
||||
*/
|
||||
public TargetPoint(final double x, final double y, final double z, final double r2, final DimensionType dim) {
|
||||
public TargetPoint(final double x, final double y, final double z, final double r2, final RegistryKey<World> dim) {
|
||||
this.excluded = null;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -153,7 +154,7 @@ public class PacketDistributor<T> {
|
||||
* @param dim DimensionType
|
||||
* @return A TargetPoint supplier
|
||||
*/
|
||||
public static Supplier<TargetPoint> p(double x, double y, double z, double r2, DimensionType dim) {
|
||||
public static Supplier<TargetPoint> p(double x, double y, double z, double r2, RegistryKey<World> dim) {
|
||||
TargetPoint tp = new TargetPoint(x, y, z, r2, dim);
|
||||
return ()->tp;
|
||||
}
|
||||
@@ -215,8 +216,8 @@ public class PacketDistributor<T> {
|
||||
private Consumer<IPacket<?>> playerConsumer(final Supplier<ServerPlayerEntity> entityPlayerMPSupplier) {
|
||||
return p -> entityPlayerMPSupplier.get().connection.netManager.sendPacket(p);
|
||||
}
|
||||
private Consumer<IPacket<?>> playerListDimConsumer(final Supplier<DimensionType> dimensionTypeSupplier) {
|
||||
return p->getServer().getPlayerList().sendPacketToAllPlayersInDimension(p, dimensionTypeSupplier.get());
|
||||
private Consumer<IPacket<?>> playerListDimConsumer(final Supplier<RegistryKey<World>> dimensionTypeSupplier) {
|
||||
return p->getServer().getPlayerList().func_232642_a_(p, dimensionTypeSupplier.get());
|
||||
}
|
||||
|
||||
private Consumer<IPacket<?>> playerListAll(final Supplier<Void> voidSupplier) {
|
||||
|
||||
@@ -104,7 +104,7 @@ public class DelegatingResourcePack extends ResourcePack
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
public void close()
|
||||
{
|
||||
synchronized(delegates)
|
||||
{
|
||||
|
||||
@@ -134,7 +134,7 @@ public class ModFileResourcePack extends DelegatableResourcePack
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
public void close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package net.minecraftforge.fml.packs;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -29,6 +28,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -92,7 +92,7 @@ public class ResourcePackLoader
|
||||
}
|
||||
|
||||
public interface IPackInfoFinder<T extends ResourcePackInfo> {
|
||||
void addPackInfosToMap(Map<String, T> packList, ResourcePackInfo.IFactory<T> factory);
|
||||
void addPackInfos(Consumer<T> consumer, ResourcePackInfo.IFactory<T> factory);
|
||||
}
|
||||
|
||||
// SO GROSS - DON'T @ me bro
|
||||
@@ -105,9 +105,9 @@ public class ResourcePackLoader
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ResourcePackInfo> void addPackInfosToMap(Map<String, T> packList, ResourcePackInfo.IFactory<T> factory)
|
||||
public <T extends ResourcePackInfo> void func_230230_a_(Consumer<T> consumer, ResourcePackInfo.IFactory<T> factory)
|
||||
{
|
||||
wrapped.addPackInfosToMap(packList, factory);
|
||||
wrapped.addPackInfos(consumer, factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,15 +80,16 @@ public class LanguageHook
|
||||
|
||||
private static void loadLanguage(String langName, MinecraftServer server) {
|
||||
String langFile = String.format("lang/%s.json", langName);
|
||||
server.getResourceManager().getResourceNamespaces().forEach(namespace -> {
|
||||
try {
|
||||
ResourceLocation langResource = new ResourceLocation(namespace, langFile);
|
||||
loadLocaleData(server.getResourceManager().getAllResources(langResource));
|
||||
} catch (FileNotFoundException fnfe) {
|
||||
} catch (Exception exception) {
|
||||
LOGGER.warn("Skipped language file: {}:{}", namespace, langFile, exception);
|
||||
}
|
||||
});
|
||||
//TODO
|
||||
// server.getResourceManager().getResourceNamespaces().forEach(namespace -> {
|
||||
// try {
|
||||
// ResourceLocation langResource = new ResourceLocation(namespace, langFile);
|
||||
// loadLocaleData(server.getResourceManager().getAllResources(langResource));
|
||||
// } catch (FileNotFoundException fnfe) {
|
||||
// } catch (Exception exception) {
|
||||
// LOGGER.warn("Skipped language file: {}:{}", namespace, langFile, exception);
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,10 @@ import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.resources.IPackNameDecorator;
|
||||
import net.minecraft.world.storage.FolderNames;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
@@ -70,12 +73,13 @@ public class ServerLifecycleHooks
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Marker SERVERHOOKS = MarkerManager.getMarker("SERVERHOOKS");
|
||||
private static final FolderNames SERVERCONFIG = new FolderNames("serverconfig");
|
||||
private static volatile CountDownLatch exitLatch = null;
|
||||
private static MinecraftServer currentServer;
|
||||
|
||||
private static Path getServerConfigPath(final MinecraftServer server)
|
||||
{
|
||||
final Path serverConfig = server.getActiveAnvilConverter().getFile(server.getFolderName(), "serverconfig").toPath();
|
||||
final Path serverConfig = server.func_240776_a_(SERVERCONFIG);
|
||||
FileUtils.getOrCreateDirectory(serverConfig, "serverconfig");
|
||||
return serverConfig;
|
||||
}
|
||||
@@ -207,13 +211,13 @@ public class ServerLifecycleHooks
|
||||
return (packList, factory) -> serverPackFinder(modResourcePacks, packSetter, packList, factory);
|
||||
}
|
||||
|
||||
private static <T extends ResourcePackInfo> void serverPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ? super T> packSetter, Map<String, T> packList, ResourcePackInfo.IFactory<? extends T> factory) {
|
||||
private static <T extends ResourcePackInfo> void serverPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ? super T> packSetter, Consumer<T> consumer, ResourcePackInfo.IFactory<? extends T> factory) {
|
||||
for (Entry<ModFile, ? extends ModFileResourcePack> e : modResourcePacks.entrySet())
|
||||
{
|
||||
IModInfo mod = e.getKey().getModInfos().get(0);
|
||||
if (Objects.equals(mod.getModId(), "minecraft")) continue; // skip the minecraft "mod"
|
||||
final String name = "mod:" + mod.getModId();
|
||||
final T packInfo = ResourcePackInfo.createResourcePack(name, true, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM);
|
||||
final T packInfo = ResourcePackInfo.createResourcePack(name, true, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.field_232625_a_);
|
||||
if (packInfo == null) {
|
||||
// Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong
|
||||
ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey()));
|
||||
@@ -221,7 +225,7 @@ public class ServerLifecycleHooks
|
||||
}
|
||||
packSetter.accept(e.getValue(), packInfo);
|
||||
LOGGER.debug(CORE, "Generating PackInfo named {} for mod file {}", name, e.getKey().getFilePath());
|
||||
packList.put(name, packInfo);
|
||||
consumer.accept(packInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user