mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 03:49:14 +00:00
Initial 1.16.2 Update
This commit is contained in:
1 parent
a3c4ffd2c1
commit
fe43088c96
233 files changed
+1644
-2297
No files matched your search
@@ -41,7 +41,6 @@ import org.apache.logging.log4j.Logger;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
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.data.PackMetadataSection;
|
||||
@@ -80,7 +79,7 @@ public class ClientModLoader
|
||||
private static LoadingFailedException error;
|
||||
private static EarlyLoaderGUI earlyLoaderGUI;
|
||||
|
||||
public static void begin(final Minecraft minecraft, final ResourcePackList<ClientResourcePackInfo> defaultResourcePacks, final IReloadableResourceManager mcResourceManager, DownloadingPackFinder metadataSerializer)
|
||||
public static void begin(final Minecraft minecraft, final ResourcePackList defaultResourcePacks, final IReloadableResourceManager mcResourceManager, DownloadingPackFinder metadataSerializer)
|
||||
{
|
||||
// force log4j to shutdown logging in a shutdown hook. This is because we disable default shutdown hook so the server properly logs it's shutdown
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(LogManager::shutdown));
|
||||
@@ -184,18 +183,18 @@ public class ClientModLoader
|
||||
return loading;
|
||||
}
|
||||
|
||||
private static <T extends ResourcePackInfo> ResourcePackLoader.IPackInfoFinder<T> buildPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ? super T> packSetter) {
|
||||
private static ResourcePackLoader.IPackInfoFinder buildPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ResourcePackInfo> packSetter) {
|
||||
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, Consumer<T> consumer, ResourcePackInfo.IFactory<? extends T> factory) {
|
||||
private static void clientPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ResourcePackInfo> packSetter, Consumer<ResourcePackInfo> consumer, ResourcePackInfo.IFactory 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, IPackNameDecorator.field_232625_a_);
|
||||
final ResourcePackInfo 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()));
|
||||
@@ -209,7 +208,7 @@ public class ClientModLoader
|
||||
hiddenPacks.add(e.getValue());
|
||||
}
|
||||
}
|
||||
final T packInfo = ResourcePackInfo.createResourcePack("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources",
|
||||
final ResourcePackInfo 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, IPackNameDecorator.field_232625_a_);
|
||||
consumer.accept(packInfo);
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IReorderingProcessor;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.text.ITextProperties;
|
||||
@@ -240,7 +241,8 @@ public class GuiUtils
|
||||
cachedTooltipStack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static void drawHoveringText(MatrixStack mStack, List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
|
||||
/*
|
||||
public static void drawHoveringText(MatrixStack mStack, List<? extends IReorderingProcessor> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
|
||||
{
|
||||
drawHoveringText(mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, DEFAULT_BACKGROUND_COLOR, DEFAULT_BORDER_COLOR_START, DEFAULT_BORDER_COLOR_END, font);
|
||||
}
|
||||
@@ -263,8 +265,8 @@ public class GuiUtils
|
||||
* @param borderColorEnd The ending color of the box border. The border color will be smoothly interpolated
|
||||
* between the start and end values.
|
||||
* @param font the font for drawing the text in the tooltip box
|
||||
*/
|
||||
public static void drawHoveringText(MatrixStack mStack, List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
||||
* /
|
||||
public static void drawHoveringText(MatrixStack mStack, List<? extends IReorderingProcessor> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
||||
int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, FontRenderer font)
|
||||
{
|
||||
drawHoveringText(cachedTooltipStack, mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, backgroundColor, borderColorStart, borderColorEnd, font);
|
||||
@@ -279,9 +281,9 @@ public class GuiUtils
|
||||
* Use this version if calling from somewhere where ItemStack context is available.
|
||||
*
|
||||
* @see #drawHoveringText(MatrixStack, List, int, int, int, int, int, int, int, int, FontRenderer)
|
||||
*/
|
||||
* /
|
||||
//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,
|
||||
public static void drawHoveringText(@Nonnull final ItemStack stack, MatrixStack mStack, List<? extends IReorderingProcessor> textLines, int mouseX, int mouseY,
|
||||
int screenWidth, int screenHeight, int maxTextWidth,
|
||||
int backgroundColor, int borderColorStart, int borderColorEnd, FontRenderer font)
|
||||
{
|
||||
@@ -301,7 +303,7 @@ public class GuiUtils
|
||||
RenderSystem.disableDepthTest();
|
||||
int tooltipTextWidth = 0;
|
||||
|
||||
for (ITextProperties textLine : textLines)
|
||||
for (IReorderingProcessor textLine : textLines)
|
||||
{
|
||||
int textLineWidth = font.func_238414_a_(textLine);
|
||||
if (textLineWidth > tooltipTextWidth)
|
||||
@@ -422,6 +424,7 @@ public class GuiUtils
|
||||
RenderSystem.enableRescaleNormal();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public static void drawGradientRect(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@ 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.IReorderingProcessor;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.ITextProperties;
|
||||
@@ -100,8 +101,8 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
}
|
||||
|
||||
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);
|
||||
for (IReorderingProcessor s : fr.func_238425_b_(str, this.field_230708_k_)) {
|
||||
fr.func_238407_a_(mStack, s, (float) (x - fr.func_243245_a(s) / 2.0), y, 0xFFFFFF);
|
||||
y+=fr.FONT_HEIGHT;
|
||||
}
|
||||
}
|
||||
@@ -148,11 +149,11 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
@Override
|
||||
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<ITextProperties> strings = font.func_238425_b_(message, LoadingEntryList.this.field_230670_d_);
|
||||
final List<IReorderingProcessor> 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.func_238422_b_(mStack, strings.get(i), left + (field_230670_d_) - font.func_238414_a_(strings.get(i)) / 2F, y, 0xFFFFFF);
|
||||
font.func_238422_b_(mStack, strings.get(i), left + (field_230670_d_) - font.func_243245_a(strings.get(i)) / 2F, y, 0xFFFFFF);
|
||||
else
|
||||
font.func_238422_b_(mStack, strings.get(i), left + 5, y, 0xFFFFFF);
|
||||
y += font.FONT_HEIGHT;
|
||||
|
||||
@@ -51,6 +51,7 @@ import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.IReorderingProcessor;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraftforge.client.gui.ScrollPanel;
|
||||
@@ -130,7 +131,7 @@ public class ModListScreen extends Screen
|
||||
class InfoPanel extends ScrollPanel {
|
||||
private ResourceLocation logoPath;
|
||||
private Size2i logoDims = new Size2i(0, 0);
|
||||
private List<ITextProperties> lines = Collections.emptyList();
|
||||
private List<IReorderingProcessor> lines = Collections.emptyList();
|
||||
|
||||
InfoPanel(Minecraft mcIn, int widthIn, int heightIn, int topIn)
|
||||
{
|
||||
@@ -151,9 +152,9 @@ public class ModListScreen extends Screen
|
||||
this.lines = Collections.emptyList();
|
||||
}
|
||||
|
||||
private List<ITextProperties> resizeContent(List<String> lines)
|
||||
private List<IReorderingProcessor> resizeContent(List<String> lines)
|
||||
{
|
||||
List<ITextProperties> ret = new ArrayList<>();
|
||||
List<IReorderingProcessor> ret = new ArrayList<>();
|
||||
for (String line : lines)
|
||||
{
|
||||
if (line == null)
|
||||
@@ -166,7 +167,7 @@ public class ModListScreen extends Screen
|
||||
int maxTextLength = this.width - 12;
|
||||
if (maxTextLength >= 0)
|
||||
{
|
||||
ret.addAll(field_230712_o_.func_238420_b_().func_238362_b_(chat, maxTextLength, Style.field_240709_b_));
|
||||
ret.addAll(LanguageMap.getInstance().func_244260_a(field_230712_o_.func_238420_b_().func_238362_b_(chat, maxTextLength, Style.field_240709_b_)));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -201,7 +202,7 @@ public class ModListScreen extends Screen
|
||||
relativeY += headerHeight + PADDING;
|
||||
}
|
||||
|
||||
for (ITextProperties line : lines)
|
||||
for (IReorderingProcessor line : lines)
|
||||
{
|
||||
if (line != null)
|
||||
{
|
||||
@@ -231,10 +232,10 @@ public class ModListScreen extends Screen
|
||||
if (lineIdx >= lines.size() || lineIdx < 1)
|
||||
return null;
|
||||
|
||||
ITextProperties line = lines.get(lineIdx-1);
|
||||
IReorderingProcessor line = lines.get(lineIdx-1);
|
||||
if (line != null)
|
||||
{
|
||||
return field_230712_o_.func_238420_b_().func_238357_a_(line, mouseX);
|
||||
return field_230712_o_.func_238420_b_().func_243239_a(line, mouseX);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -375,7 +376,7 @@ public class ModListScreen extends Screen
|
||||
|
||||
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);
|
||||
getFontRenderer().func_238422_b_(mStack, text.func_241878_f(), 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);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ExtendedButton extends Button
|
||||
//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.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());
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,8 @@ 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.ITextProperties;
|
||||
import net.minecraft.util.text.LanguageMap;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.fml.client.gui.screen.ModListScreen;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
@@ -90,8 +92,8 @@ public class ModListWidget extends ExtendedList<ModListWidget.ModEntry>
|
||||
ITextComponent version = new StringTextComponent(stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion())));
|
||||
VersionChecker.CheckResult vercheck = VersionChecker.getResult(modInfo);
|
||||
FontRenderer font = this.parent.getFontRenderer();
|
||||
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);
|
||||
font.func_238422_b_(mStack, LanguageMap.getInstance().func_241870_a(ITextProperties.func_240655_a_(font.func_238417_a_(name, listWidth))), left + 3, top + 2, 0xFFFFFF);
|
||||
font.func_238422_b_(mStack, LanguageMap.getInstance().func_241870_a(ITextProperties.func_240655_a_(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
|
||||
|
||||
@@ -36,6 +36,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import net.minecraft.resources.IPackFinder;
|
||||
import net.minecraft.resources.ResourcePackInfo;
|
||||
import net.minecraft.resources.ResourcePackInfo.IFactory;
|
||||
import net.minecraft.resources.ResourcePackList;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
@@ -44,7 +45,7 @@ import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||
public class ResourcePackLoader
|
||||
{
|
||||
private static Map<ModFile, ModFileResourcePack> modResourcePacks;
|
||||
private static ResourcePackList<?> resourcePackList;
|
||||
private static ResourcePackList resourcePackList;
|
||||
|
||||
public static Optional<ModFileResourcePack> getResourcePackFor(String modId)
|
||||
{
|
||||
@@ -52,7 +53,7 @@ public class ResourcePackLoader
|
||||
map(ModFileInfo::getFile).map(mf->modResourcePacks.get(mf));
|
||||
}
|
||||
|
||||
public static <T extends ResourcePackInfo> void loadResourcePacks(ResourcePackList<T> resourcePacks, BiFunction<Map<ModFile, ? extends ModFileResourcePack>, BiConsumer<? super ModFileResourcePack, T>, IPackInfoFinder> packFinder) {
|
||||
public static void loadResourcePacks(ResourcePackList resourcePacks, BiFunction<Map<ModFile, ? extends ModFileResourcePack>, BiConsumer<? super ModFileResourcePack, ResourcePackInfo>, IPackInfoFinder> packFinder) {
|
||||
resourcePackList = resourcePacks;
|
||||
modResourcePacks = ModList.get().getModFiles().stream().
|
||||
filter(mf->!Objects.equals(mf.getModLoader(),"minecraft")).
|
||||
@@ -96,8 +97,8 @@ public class ResourcePackLoader
|
||||
};
|
||||
}
|
||||
|
||||
public interface IPackInfoFinder<T extends ResourcePackInfo> {
|
||||
void addPackInfos(Consumer<T> consumer, ResourcePackInfo.IFactory<T> factory);
|
||||
public interface IPackInfoFinder {
|
||||
void addPackInfos(Consumer<ResourcePackInfo> consumer, IFactory factory);
|
||||
}
|
||||
|
||||
// SO GROSS - DON'T @ me bro
|
||||
@@ -110,7 +111,7 @@ public class ResourcePackLoader
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ResourcePackInfo> void func_230230_a_(Consumer<T> consumer, ResourcePackInfo.IFactory<T> factory)
|
||||
public void func_230230_a_(Consumer<ResourcePackInfo> consumer, IFactory factory)
|
||||
{
|
||||
wrapped.addPackInfos(consumer, factory);
|
||||
}
|
||||
|
||||
@@ -214,17 +214,17 @@ public class ServerLifecycleHooks
|
||||
|
||||
//INTERNAL MODDERS DO NOT USE
|
||||
@Deprecated
|
||||
public static <T extends ResourcePackInfo> ResourcePackLoader.IPackInfoFinder<T> buildPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ? super T> packSetter) {
|
||||
public static ResourcePackLoader.IPackInfoFinder buildPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ResourcePackInfo> packSetter) {
|
||||
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, Consumer<T> consumer, ResourcePackInfo.IFactory<? extends T> factory) {
|
||||
private static void serverPackFinder(Map<ModFile, ? extends ModFileResourcePack> modResourcePacks, BiConsumer<? super ModFileResourcePack, ResourcePackInfo> packSetter, Consumer<ResourcePackInfo> consumer, ResourcePackInfo.IFactory 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, IPackNameDecorator.field_232625_a_);
|
||||
final ResourcePackInfo 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()));
|
||||
|
||||
Reference in new issue
Block a user