mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 22:44:32 +00:00
Forge 1.19
* Bump pack.mcmeta formats * 1.19 biome modifiers * Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable * Add docs and package-info to client extension interfaces package * Move RenderBlockOverlayEvent hooks to ForgeHooksClient * Add package-infos to client events package * Rename SoundLoadEvent to SoundEngineLoadEvent This reduces confusion from consumers which may think the name SoundLoadEvent refers to an individual sound being loaded rather than the sound engine. * Document and change SoundLoadEvent to fire on mod bus Previously, it fired on both the mod bus and the Forge bus, which is confusing for consumers. * Delete SoundSetupEvent Looking at its original implementation shows that there isn't an appropriate place in the new sound code to reinsert the event, and the place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent. * Perform some cleanup on client events - Removed nullable annotations from ClientPlayerNetworkEvent - Renamed #getPartialTicks methods to #getPartialTick, to be consistent with vanilla's naming of the partial tick - Cleanup documentation to remove line breaks, use the spelling 'cancelled' over 'canceled', and improve docs on existing and new methods. * Remove EntityEvent.CanUpdate Closes MinecraftForge/MinecraftForge#6394 * Switch to Jetbrains nullability annotations * New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent * Remove ForgeWorldPresetScreens * Remove IForgeRegistryEntry * Remove use of List<Throwable> in FML's CompletableFutures * Add docs to mod loading stages, stages, and phases * Gradle 7.4.2 * Use SLF4J in FMLLoader and other subprojects * Switch dynamic versions in subprojects to pinned ones * Switch ForgeRoot and MDK to FG plugin markers * Configure Forge javadoc task The task now uses a custom stylesheet with MCForge elements, and configured to combine the generation from the four FML subprojects (fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project into the javadoc output. * Update docs/md files, for 1.19 update and the move away from IRC to Discord. * Make "Potentially dangerous alternative prefix" a debug warning, not info. Co-authored-by: Curle <[email protected]> Co-authored-by: sciwhiz12 <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
1 parent
270e778ac5
commit
4ed9117799
1485 files changed
+14960
-15446
No files matched your search
@@ -45,12 +45,11 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ForgeIngameGui extends Gui
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -319,7 +318,7 @@ public class ForgeIngameGui extends Gui
|
||||
|
||||
public ForgeIngameGui(Minecraft mc)
|
||||
{
|
||||
super(mc);
|
||||
super(mc, mc.getItemRenderer());
|
||||
debugOverlay = new ForgeDebugScreenOverlay(mc);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -11,11 +11,9 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.screens.ErrorScreen;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraftforge.common.ForgeI18n;
|
||||
import net.minecraftforge.fml.LoadingFailedException;
|
||||
@@ -46,7 +44,7 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
|
||||
public LoadingErrorScreen(LoadingFailedException loadingException, List<ModLoadingWarning> warnings, final File dumpedLocation)
|
||||
{
|
||||
super(new TextComponent("Loading Error"), null);
|
||||
super(Component.literal("Loading Error"), null);
|
||||
this.modLoadWarnings = warnings;
|
||||
this.modLoadErrors = loadingException == null ? Collections.emptyList() : loadingException.getErrors();
|
||||
this.modsDir = FMLPaths.MODSDIR.get();
|
||||
@@ -60,18 +58,18 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
super.init();
|
||||
this.clearWidgets();
|
||||
|
||||
this.errorHeader = new TextComponent(ChatFormatting.RED + ForgeI18n.parseMessage("fml.loadingerrorscreen.errorheader", this.modLoadErrors.size()) + ChatFormatting.RESET);
|
||||
this.warningHeader = new TextComponent(ChatFormatting.YELLOW + ForgeI18n.parseMessage("fml.loadingerrorscreen.warningheader", this.modLoadErrors.size()) + ChatFormatting.RESET);
|
||||
this.errorHeader = Component.literal(ChatFormatting.RED + ForgeI18n.parseMessage("fml.loadingerrorscreen.errorheader", this.modLoadErrors.size()) + ChatFormatting.RESET);
|
||||
this.warningHeader = Component.literal(ChatFormatting.YELLOW + ForgeI18n.parseMessage("fml.loadingerrorscreen.warningheader", this.modLoadErrors.size()) + ChatFormatting.RESET);
|
||||
|
||||
int yOffset = 46;
|
||||
this.addRenderableWidget(new ExtendedButton(50, this.height - yOffset, this.width / 2 - 55, 20, new TextComponent(ForgeI18n.parseMessage("fml.button.open.mods.folder")), b -> Util.getPlatform().openFile(modsDir.toFile())));
|
||||
this.addRenderableWidget(new ExtendedButton(this.width / 2 + 5, this.height - yOffset, this.width / 2 - 55, 20, new TextComponent(ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName())), b -> Util.getPlatform().openFile(logFile.toFile())));
|
||||
this.addRenderableWidget(new ExtendedButton(50, this.height - yOffset, this.width / 2 - 55, 20, Component.literal(ForgeI18n.parseMessage("fml.button.open.mods.folder")), b -> Util.getPlatform().openFile(modsDir.toFile())));
|
||||
this.addRenderableWidget(new ExtendedButton(this.width / 2 + 5, this.height - yOffset, this.width / 2 - 55, 20, Component.literal(ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName())), b -> Util.getPlatform().openFile(logFile.toFile())));
|
||||
if (this.modLoadErrors.isEmpty()) {
|
||||
this.addRenderableWidget(new ExtendedButton(this.width / 4, this.height - 24, this.width / 2, 20, new TextComponent(ForgeI18n.parseMessage("fml.button.continue.launch")), b -> {
|
||||
this.addRenderableWidget(new ExtendedButton(this.width / 4, this.height - 24, this.width / 2, 20, Component.literal(ForgeI18n.parseMessage("fml.button.continue.launch")), b -> {
|
||||
this.minecraft.setScreen(null);
|
||||
}));
|
||||
} else {
|
||||
this.addRenderableWidget(new ExtendedButton(this.width / 4, this.height - 24, this.width / 2, 20, new TextComponent(ForgeI18n.parseMessage("fml.button.open.file", dumpedLocation.getFileName())), b -> Util.getPlatform().openFile(dumpedLocation.toFile())));
|
||||
this.addRenderableWidget(new ExtendedButton(this.width / 4, this.height - 24, this.width / 2, 20, Component.literal(ForgeI18n.parseMessage("fml.button.open.file", dumpedLocation.getFileName())), b -> Util.getPlatform().openFile(dumpedLocation.toFile())));
|
||||
}
|
||||
|
||||
this.entryList = new LoadingEntryList(this, this.modLoadErrors, this.modLoadWarnings);
|
||||
@@ -100,13 +98,13 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
boolean both = !errors.isEmpty() && !warnings.isEmpty();
|
||||
if (both)
|
||||
addEntry(new LoadingMessageEntry(parent.errorHeader, true));
|
||||
errors.forEach(e->addEntry(new LoadingMessageEntry(new TextComponent(e.formatToString()))));
|
||||
errors.forEach(e->addEntry(new LoadingMessageEntry(Component.literal(e.formatToString()))));
|
||||
if (both) {
|
||||
int maxChars = (this.width - 10) / parent.minecraft.font.width("-");
|
||||
addEntry(new LoadingMessageEntry(new TextComponent("\n" + Strings.repeat("-", maxChars) + "\n")));
|
||||
addEntry(new LoadingMessageEntry(Component.literal("\n" + Strings.repeat("-", maxChars) + "\n")));
|
||||
addEntry(new LoadingMessageEntry(parent.warningHeader, true));
|
||||
}
|
||||
warnings.forEach(w->addEntry(new LoadingMessageEntry(new TextComponent(w.formatToString()))));
|
||||
warnings.forEach(w->addEntry(new LoadingMessageEntry(Component.literal(w.formatToString()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,7 +134,7 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
|
||||
@Override
|
||||
public Component getNarration() {
|
||||
return new TranslatableComponent("narrator.select", message);
|
||||
return Component.translatable("narrator.select", message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,7 +57,6 @@ import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
||||
public class ModListScreen extends Screen
|
||||
{
|
||||
@@ -79,7 +78,7 @@ public class ModListScreen extends Screen
|
||||
}
|
||||
|
||||
Component getButtonText() {
|
||||
return new TranslatableComponent("fml.menu.mods." + StringUtils.toLowerCase(name()));
|
||||
return Component.translatable("fml.menu.mods." + StringUtils.toLowerCase(name()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +105,7 @@ public class ModListScreen extends Screen
|
||||
|
||||
public ModListScreen(Screen parentScreen)
|
||||
{
|
||||
super(new TranslatableComponent("fml.menu.mods.title"));
|
||||
super(Component.translatable("fml.menu.mods.title"));
|
||||
this.parentScreen = parentScreen;
|
||||
this.mods = Collections.unmodifiableList(ModList.get().getMods());
|
||||
this.unsortedMods = Collections.unmodifiableList(this.mods);
|
||||
@@ -263,12 +262,12 @@ public class ModListScreen extends Screen
|
||||
int y = this.height - 20 - PADDING;
|
||||
int fullButtonHeight = PADDING + 20 + PADDING;
|
||||
|
||||
doneButton = new Button(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20, new TranslatableComponent("gui.done"), b -> ModListScreen.this.onClose());
|
||||
openModsFolderButton = new Button(6, y, this.listWidth, 20, new TranslatableComponent("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile()));
|
||||
doneButton = new Button(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20, Component.translatable("gui.done"), b -> ModListScreen.this.onClose());
|
||||
openModsFolderButton = new Button(6, y, this.listWidth, 20, Component.translatable("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile()));
|
||||
y -= 20 + PADDING;
|
||||
configButton = new Button(6, y, this.listWidth, 20, new TranslatableComponent("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig());
|
||||
configButton = new Button(6, y, this.listWidth, 20, Component.translatable("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig());
|
||||
y -= 14 + PADDING;
|
||||
search = new EditBox(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, new TranslatableComponent("fml.menu.mods.search"));
|
||||
search = new EditBox(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, Component.translatable("fml.menu.mods.search"));
|
||||
|
||||
this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.y - getFontRenderer().lineHeight - PADDING);
|
||||
this.modList.setLeftPos(6);
|
||||
@@ -366,7 +365,7 @@ public class ModListScreen extends Screen
|
||||
if (this.modInfo != null)
|
||||
this.modInfo.render(poseStack, mouseX, mouseY, partialTick);
|
||||
|
||||
Component text = new TranslatableComponent("fml.menu.mods.search");
|
||||
Component text = Component.translatable("fml.menu.mods.search");
|
||||
int x = modList.getLeft() + ((modList.getRight() - modList.getLeft()) / 2) - (getFontRenderer().width(text) / 2);
|
||||
this.search.render(poseStack, mouseX , mouseY, partialTick);
|
||||
super.render(poseStack, mouseX, mouseY, partialTick);
|
||||
|
||||
@@ -47,8 +47,6 @@ import net.minecraft.network.chat.HoverEvent.Action;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.chat.TextColor;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraftforge.common.ForgeI18n;
|
||||
@@ -105,9 +103,9 @@ public class ModMismatchDisconnectedScreen extends Screen
|
||||
this.addRenderableWidget(new MismatchInfoPanel(minecraft, listWidth, listHeight, (this.height - this.listHeight) / 2, listLeft));
|
||||
|
||||
int buttonWidth = Math.min(210, this.width / 2 - 20);
|
||||
this.addRenderableWidget(new Button(Math.max(this.width / 4 - buttonWidth / 2, listLeft), upperButtonHeight, buttonWidth, 20, new TextComponent(ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName())), button -> Util.getPlatform().openFile(logFile.toFile())));
|
||||
this.addRenderableWidget(new Button(Math.min(this.width * 3 / 4 - buttonWidth / 2, listLeft + listWidth - buttonWidth), upperButtonHeight, buttonWidth, 20, new TextComponent(ForgeI18n.parseMessage("fml.button.open.mods.folder")), button -> Util.getPlatform().openFile(modsDir.toFile())));
|
||||
this.addRenderableWidget(new Button((this.width - buttonWidth) / 2, lowerButtonHeight, buttonWidth, 20, new TranslatableComponent("gui.toMenu"), button -> this.minecraft.setScreen(this.parent)));
|
||||
this.addRenderableWidget(new Button(Math.max(this.width / 4 - buttonWidth / 2, listLeft), upperButtonHeight, buttonWidth, 20, Component.literal(ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName())), button -> Util.getPlatform().openFile(logFile.toFile())));
|
||||
this.addRenderableWidget(new Button(Math.min(this.width * 3 / 4 - buttonWidth / 2, listLeft + listWidth - buttonWidth), upperButtonHeight, buttonWidth, 20, Component.literal(ForgeI18n.parseMessage("fml.button.open.mods.folder")), button -> Util.getPlatform().openFile(modsDir.toFile())));
|
||||
this.addRenderableWidget(new Button((this.width - buttonWidth) / 2, lowerButtonHeight, buttonWidth, 20, Component.translatable("gui.toMenu"), button -> this.minecraft.setScreen(this.parent)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,36 +136,36 @@ public class ModMismatchDisconnectedScreen extends Screen
|
||||
if (!missingModData.isEmpty())
|
||||
{
|
||||
//The header of the section, colored in gray
|
||||
rawTable.add(Pair.of(new TextComponent(ForgeI18n.parseMessage(mismatchedDataFromServer ? "fml.modmismatchscreen.missingmods.server" : "fml.modmismatchscreen.missingmods.client")).withStyle(ChatFormatting.GRAY), null));
|
||||
rawTable.add(Pair.of(Component.literal(ForgeI18n.parseMessage(mismatchedDataFromServer ? "fml.modmismatchscreen.missingmods.server" : "fml.modmismatchscreen.missingmods.client")).withStyle(ChatFormatting.GRAY), null));
|
||||
//This table section contains the mod name and mod version of each mod that has a missing remote counterpart (if the mod is missing on the server, the client mod version is displayed, and vice versa)
|
||||
rawTable.add(Pair.of(new TextComponent(ForgeI18n.parseMessage("fml.modmismatchscreen.table.modname")).withStyle(ChatFormatting.UNDERLINE), Pair.of("", ForgeI18n.parseMessage(mismatchedDataFromServer ? "fml.modmismatchscreen.table.youhave" : "fml.modmismatchscreen.table.youneed"))));
|
||||
rawTable.add(Pair.of(Component.literal(ForgeI18n.parseMessage("fml.modmismatchscreen.table.modname")).withStyle(ChatFormatting.UNDERLINE), Pair.of("", ForgeI18n.parseMessage(mismatchedDataFromServer ? "fml.modmismatchscreen.table.youhave" : "fml.modmismatchscreen.table.youneed"))));
|
||||
int i = 0;
|
||||
for (ResourceLocation mod : missingModData) {
|
||||
rawTable.add(Pair.of(toModNameComponent(mod, presentModData.get(mod).getLeft(), i), Pair.of("", presentModData.getOrDefault(mod, Pair.of("", "")).getRight())));
|
||||
if (++i >= 10) {
|
||||
//If too many missing mod entries are present, append a line referencing how to see the full list and stop rendering any more entries
|
||||
rawTable.add(Pair.of(new TextComponent(ForgeI18n.parseMessage("fml.modmismatchscreen.additional", missingModData.size() - i)).withStyle(ChatFormatting.ITALIC), Pair.of("", "")));
|
||||
rawTable.add(Pair.of(Component.literal(ForgeI18n.parseMessage("fml.modmismatchscreen.additional", missingModData.size() - i)).withStyle(ChatFormatting.ITALIC), Pair.of("", "")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
rawTable.add(Pair.of(new TextComponent(" "), null)); //padding
|
||||
rawTable.add(Pair.of(Component.literal(" "), null)); //padding
|
||||
}
|
||||
if (!mismatchedModData.isEmpty())
|
||||
{
|
||||
//The header of the table section, colored in gray
|
||||
rawTable.add(Pair.of(new TextComponent(ForgeI18n.parseMessage("fml.modmismatchscreen.mismatchedmods")).withStyle(ChatFormatting.GRAY), null));
|
||||
rawTable.add(Pair.of(Component.literal(ForgeI18n.parseMessage("fml.modmismatchscreen.mismatchedmods")).withStyle(ChatFormatting.GRAY), null));
|
||||
//This table section contains the mod name and both mod versions of each mod that has a mismatching client and server version
|
||||
rawTable.add(Pair.of(new TextComponent(ForgeI18n.parseMessage("fml.modmismatchscreen.table.modname")).withStyle(ChatFormatting.UNDERLINE), Pair.of(ForgeI18n.parseMessage(mismatchedDataFromServer ? "fml.modmismatchscreen.table.youhave" : "fml.modmismatchscreen.table.serverhas"), ForgeI18n.parseMessage(mismatchedDataFromServer ? "fml.modmismatchscreen.table.serverhas" : "fml.modmismatchscreen.table.youhave"))));
|
||||
rawTable.add(Pair.of(Component.literal(ForgeI18n.parseMessage("fml.modmismatchscreen.table.modname")).withStyle(ChatFormatting.UNDERLINE), Pair.of(ForgeI18n.parseMessage(mismatchedDataFromServer ? "fml.modmismatchscreen.table.youhave" : "fml.modmismatchscreen.table.serverhas"), ForgeI18n.parseMessage(mismatchedDataFromServer ? "fml.modmismatchscreen.table.serverhas" : "fml.modmismatchscreen.table.youhave"))));
|
||||
int i = 0;
|
||||
for (Map.Entry<ResourceLocation, String> modData : mismatchedModData.entrySet()) {
|
||||
rawTable.add(Pair.of(toModNameComponent(modData.getKey(), presentModData.get(modData.getKey()).getLeft(), i), Pair.of(presentModData.getOrDefault(modData.getKey(), Pair.of("", "")).getRight(), modData.getValue())));
|
||||
if (++i >= 10) {
|
||||
//If too many mismatched mod entries are present, append a line referencing how to see the full list and stop rendering any more entries
|
||||
rawTable.add(Pair.of(new TextComponent(ForgeI18n.parseMessage("fml.modmismatchscreen.additional", mismatchedModData.size() - i)).withStyle(ChatFormatting.ITALIC), Pair.of("", "")));
|
||||
rawTable.add(Pair.of(Component.literal(ForgeI18n.parseMessage("fml.modmismatchscreen.additional", mismatchedModData.size() - i)).withStyle(ChatFormatting.ITALIC), Pair.of("", "")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
rawTable.add(Pair.of(new TextComponent(" "), null)); //padding
|
||||
rawTable.add(Pair.of(Component.literal(" "), null)); //padding
|
||||
}
|
||||
|
||||
this.lineTable = rawTable.stream().flatMap(p -> splitLineToWidth(p.getKey(), p.getValue()).stream()).collect(Collectors.toList());
|
||||
@@ -187,8 +185,8 @@ public class ModMismatchDisconnectedScreen extends Screen
|
||||
int versionColumns = versions == null ? 0 : (versions.getLeft().isEmpty() ? (versions.getRight().isEmpty() ? 0 : 1) : 2);
|
||||
int adaptedNameWidth = nameWidth + versionWidth * (2 - versionColumns) - 4; //the name width may be expanded when the version column string is missing
|
||||
List<FormattedCharSequence> nameLines = font.split(name, adaptedNameWidth);
|
||||
List<FormattedCharSequence> clientVersionLines = font.split(new TextComponent(versions != null ? versions.getLeft() : "").setStyle(style), versionWidth - 4);
|
||||
List<FormattedCharSequence> serverVersionLines = font.split(new TextComponent(versions != null ? versions.getRight() : "").setStyle(style), versionWidth - 4);
|
||||
List<FormattedCharSequence> clientVersionLines = font.split(Component.literal(versions != null ? versions.getLeft() : "").setStyle(style), versionWidth - 4);
|
||||
List<FormattedCharSequence> serverVersionLines = font.split(Component.literal(versions != null ? versions.getRight() : "").setStyle(style), versionWidth - 4);
|
||||
List<Pair<FormattedCharSequence, Pair<FormattedCharSequence, FormattedCharSequence>>> splitLines = new ArrayList<>();
|
||||
int rowsOccupied = Math.max(nameLines.size(), Math.max(clientVersionLines.size(), serverVersionLines.size()));
|
||||
for (int i = 0; i < rowsOccupied; i++) {
|
||||
@@ -209,8 +207,8 @@ public class ModMismatchDisconnectedScreen extends Screen
|
||||
{
|
||||
String modId = id.getNamespace();
|
||||
String tooltipId = id.getPath().isEmpty() ? id.getNamespace() : id.toString();
|
||||
return new TextComponent(modName).withStyle(color % 2 == 0 ? ChatFormatting.GOLD : ChatFormatting.YELLOW)
|
||||
.withStyle(s -> s.withHoverEvent(new HoverEvent(Action.SHOW_TEXT, new TextComponent(tooltipId + (!presentModUrls.getOrDefault(modId, "").isEmpty() ? "\n" + ForgeI18n.parseMessage("fml.modmismatchscreen.homepage") : "")))))
|
||||
return Component.literal(modName).withStyle(color % 2 == 0 ? ChatFormatting.GOLD : ChatFormatting.YELLOW)
|
||||
.withStyle(s -> s.withHoverEvent(new HoverEvent(Action.SHOW_TEXT, Component.literal(tooltipId + (!presentModUrls.getOrDefault(modId, "").isEmpty() ? "\n" + ForgeI18n.parseMessage("fml.modmismatchscreen.homepage") : "")))))
|
||||
.withStyle(s -> s.withClickEvent(!presentModUrls.getOrDefault(modId, "").isEmpty() ? new ClickEvent(ClickEvent.Action.OPEN_URL, presentModUrls.get(modId)) : null));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.loading.FMLConfig;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
@@ -32,7 +32,7 @@ public class NotificationModUpdateScreen extends Screen
|
||||
|
||||
public NotificationModUpdateScreen(Button modButton)
|
||||
{
|
||||
super(new TranslatableComponent("forge.menu.updatescreen.title"));
|
||||
super(Component.translatable("forge.menu.updatescreen.title"));
|
||||
this.modButton = modButton;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ package net.minecraftforge.client.gui;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -23,7 +23,7 @@ public class OverlayRegistry
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayBottom(@Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
public static synchronized IIngameOverlay registerOverlayBottom(@NotNull String displayName, @NotNull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(-1, null, displayName, overlay);
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class OverlayRegistry
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayBelow(@Nonnull IIngameOverlay other, @Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
public static synchronized IIngameOverlay registerOverlayBelow(@NotNull IIngameOverlay other, @NotNull String displayName, @NotNull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(-1, other, displayName, overlay);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class OverlayRegistry
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayAbove(@Nonnull IIngameOverlay other, @Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
public static synchronized IIngameOverlay registerOverlayAbove(@NotNull IIngameOverlay other, @NotNull String displayName, @NotNull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(1, other, displayName, overlay);
|
||||
}
|
||||
@@ -61,12 +61,12 @@ public class OverlayRegistry
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayTop(@Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
public static synchronized IIngameOverlay registerOverlayTop(@NotNull String displayName, @NotNull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(1, null, displayName, overlay);
|
||||
}
|
||||
|
||||
private static IIngameOverlay registerOverlay(int sort, @Nullable IIngameOverlay other, @Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
private static IIngameOverlay registerOverlay(int sort, @Nullable IIngameOverlay other, @NotNull String displayName, @NotNull IIngameOverlay overlay)
|
||||
{
|
||||
OverlayEntry entry = overlays.get(overlay);
|
||||
|
||||
@@ -108,7 +108,7 @@ public class OverlayRegistry
|
||||
* @param overlay The overlay object to enable or disable
|
||||
* @param enable The new state
|
||||
*/
|
||||
public static synchronized void enableOverlay(@Nonnull IIngameOverlay overlay, boolean enable)
|
||||
public static synchronized void enableOverlay(@NotNull IIngameOverlay overlay, boolean enable)
|
||||
{
|
||||
OverlayEntry entry = overlays.get(overlay);
|
||||
if (entry != null)
|
||||
@@ -123,7 +123,7 @@ public class OverlayRegistry
|
||||
* @return The registration entry for this overlay.
|
||||
*/
|
||||
@Nullable
|
||||
public static synchronized OverlayEntry getEntry(@Nonnull IIngameOverlay overlay)
|
||||
public static synchronized OverlayEntry getEntry(@NotNull IIngameOverlay overlay)
|
||||
{
|
||||
return overlays.get(overlay);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraftforge.client.gui.GuiUtils;
|
||||
|
||||
/**
|
||||
@@ -46,7 +45,7 @@ public class ExtendedButton extends Button
|
||||
|
||||
if (strWidth > width - 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 TextComponent(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString() + "...");
|
||||
buttonText = Component.literal(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString() + "...");
|
||||
|
||||
drawCenteredString(poseStack, mc.font, buttonText, this.x + this.width / 2, this.y + (this.height - 8) / 2, getFGColor());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package net.minecraftforge.client.gui.widget;
|
||||
|
||||
import net.minecraft.client.gui.components.AbstractSliderButton;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
@@ -47,7 +46,7 @@ public class ForgeSlider extends AbstractSliderButton
|
||||
*/
|
||||
public ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, double stepSize, int precision, boolean drawString)
|
||||
{
|
||||
super(x, y, width, height, TextComponent.EMPTY, 0D);
|
||||
super(x, y, width, height, Component.empty(), 0D);
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
this.minValue = minValue;
|
||||
@@ -207,11 +206,11 @@ public class ForgeSlider extends AbstractSliderButton
|
||||
{
|
||||
if (this.drawString)
|
||||
{
|
||||
this.setMessage(new TextComponent("").append(prefix).append(this.getValueString()).append(suffix));
|
||||
this.setMessage(Component.literal("").append(prefix).append(this.getValueString()).append(suffix));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setMessage(TextComponent.EMPTY);
|
||||
this.setMessage(Component.empty());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,10 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraftforge.client.gui.ModListScreen;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import net.minecraftforge.common.util.MavenVersionStringHelper;
|
||||
@@ -73,14 +71,14 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry>
|
||||
|
||||
@Override
|
||||
public Component getNarration() {
|
||||
return new TranslatableComponent("narrator.select", modInfo.getDisplayName());
|
||||
return Component.translatable("narrator.select", modInfo.getDisplayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTick)
|
||||
{
|
||||
Component name = new TextComponent(stripControlCodes(modInfo.getDisplayName()));
|
||||
Component version = new TextComponent(stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion())));
|
||||
Component name = Component.literal(stripControlCodes(modInfo.getDisplayName()));
|
||||
Component version = Component.literal(stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion())));
|
||||
VersionChecker.CheckResult vercheck = VersionChecker.getResult(modInfo);
|
||||
Font font = this.parent.getFontRenderer();
|
||||
font.draw(poseStack, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(name, listWidth))), left + 3, top + 2, 0xFFFFFF);
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraftforge.client.gui.GuiUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This class is blatantly stolen from iChunUtils with permission.
|
||||
*
|
||||
* @deprecated This class has a few issues,
|
||||
* mainly <a href="https://github.com/MinecraftForge/MinecraftForge/issues/8485">MinecraftForge/MinecraftForge#8485</a>.
|
||||
* Use {@link ForgeSlider} instead.
|
||||
*
|
||||
* @author iChun
|
||||
*/
|
||||
@Deprecated(since = "1.18.2", forRemoval = true)
|
||||
public class Slider extends ExtendedButton
|
||||
{
|
||||
/** The value of this slider control. */
|
||||
public double sliderValue = 1.0F;
|
||||
|
||||
public Component dispString;
|
||||
|
||||
/** Is this slider control being dragged. */
|
||||
public boolean dragging = false;
|
||||
public boolean showDecimal = true;
|
||||
|
||||
public double minValue = 0.0D;
|
||||
public double maxValue = 5.0D;
|
||||
public int precision = 1;
|
||||
|
||||
@Nullable
|
||||
public ISlider parent = null;
|
||||
|
||||
public Component suffix;
|
||||
|
||||
public boolean drawString = true;
|
||||
|
||||
public Slider(int xPos, int yPos, int width, int height, Component prefix, Component suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, OnPress 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, Component prefix, Component suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, OnPress handler, @Nullable ISlider par)
|
||||
{
|
||||
super(xPos, yPos, width, height, prefix, handler);
|
||||
minValue = minVal;
|
||||
maxValue = maxVal;
|
||||
sliderValue = (currentVal - minValue) / (maxValue - minValue);
|
||||
dispString = prefix;
|
||||
parent = par;
|
||||
suffix = suf;
|
||||
showDecimal = showDec;
|
||||
String val;
|
||||
|
||||
if (showDecimal)
|
||||
{
|
||||
val = Double.toString(sliderValue * (maxValue - minValue) + minValue);
|
||||
precision = Math.min(val.substring(val.indexOf(".") + 1).length(), 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
val = Integer.toString((int)Math.round(sliderValue * (maxValue - minValue) + minValue));
|
||||
precision = 0;
|
||||
}
|
||||
|
||||
setMessage(new TextComponent("").append(dispString).append(val).append(suffix));
|
||||
|
||||
drawString = drawStr;
|
||||
if(!drawString)
|
||||
setMessage(new TextComponent(""));
|
||||
}
|
||||
|
||||
public Slider(int xPos, int yPos, Component displayStr, double minVal, double maxVal, double currentVal, OnPress handler, ISlider par)
|
||||
{
|
||||
this(xPos, yPos, 150, 20, displayStr, new TextComponent(""), minVal, maxVal, currentVal, true, true, handler, par);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 0 if the button is disabled, 1 if the mouse is NOT hovering over this button and 2 if it IS hovering over
|
||||
* this button.
|
||||
*/
|
||||
@Override
|
||||
public int getYImage(boolean par1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e).
|
||||
*/
|
||||
@Override
|
||||
protected void renderBg(PoseStack poseStack, Minecraft minecraft, int par2, int par3)
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
if (this.dragging)
|
||||
{
|
||||
this.sliderValue = (par2 - (this.x + 4)) / (float)(this.width - 8);
|
||||
updateSlider();
|
||||
}
|
||||
|
||||
GuiUtils.drawContinuousTexturedBox(poseStack, 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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the mouse has been pressed on this control. Equivalent of MouseListener.mousePressed(MouseEvent
|
||||
* e).
|
||||
*/
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY)
|
||||
{
|
||||
this.sliderValue = (mouseX - (this.x + 4)) / (this.width - 8);
|
||||
updateSlider();
|
||||
this.dragging = true;
|
||||
}
|
||||
|
||||
public void updateSlider()
|
||||
{
|
||||
if (this.sliderValue < 0.0F)
|
||||
{
|
||||
this.sliderValue = 0.0F;
|
||||
}
|
||||
|
||||
if (this.sliderValue > 1.0F)
|
||||
{
|
||||
this.sliderValue = 1.0F;
|
||||
}
|
||||
|
||||
String val;
|
||||
|
||||
if (showDecimal)
|
||||
{
|
||||
val = Double.toString(sliderValue * (maxValue - minValue) + minValue);
|
||||
|
||||
if (val.substring(val.indexOf(".") + 1).length() > precision)
|
||||
{
|
||||
val = val.substring(0, val.indexOf(".") + precision + 1);
|
||||
|
||||
if (val.endsWith("."))
|
||||
{
|
||||
val = val.substring(0, val.indexOf(".") + precision);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (val.substring(val.indexOf(".") + 1).length() < precision)
|
||||
{
|
||||
val = val + "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
val = Integer.toString((int)Math.round(sliderValue * (maxValue - minValue) + minValue));
|
||||
}
|
||||
|
||||
if(drawString)
|
||||
{
|
||||
setMessage(new TextComponent("").append(dispString).append(val).append(suffix));
|
||||
}
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
parent.onChangeSliderValue(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the mouse button is released. Equivalent of MouseListener.mouseReleased(MouseEvent e).
|
||||
*/
|
||||
@Override
|
||||
public void onRelease(double mouseX, double mouseY)
|
||||
{
|
||||
this.dragging = false;
|
||||
}
|
||||
|
||||
public int getValueInt()
|
||||
{
|
||||
return (int)Math.round(sliderValue * (maxValue - minValue) + minValue);
|
||||
}
|
||||
|
||||
public double getValue()
|
||||
{
|
||||
return sliderValue * (maxValue - minValue) + minValue;
|
||||
}
|
||||
|
||||
public void setValue(double d)
|
||||
{
|
||||
this.sliderValue = (d - minValue) / (maxValue - minValue);
|
||||
}
|
||||
|
||||
public static interface ISlider
|
||||
{
|
||||
void onChangeSliderValue(Slider slider);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraftforge.client.gui.GuiUtils;
|
||||
|
||||
/**
|
||||
@@ -47,14 +46,14 @@ public class UnicodeGlyphButton extends ExtendedButton
|
||||
int totalWidth = strWidth + glyphWidth;
|
||||
|
||||
if (totalWidth > width - 6 && totalWidth > ellipsisWidth)
|
||||
buttonText = new TextComponent(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString().trim() + "...") ;
|
||||
buttonText = Component.literal(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString().trim() + "...") ;
|
||||
|
||||
strWidth = mc.font.width(buttonText);
|
||||
totalWidth = glyphWidth + strWidth;
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.scale(glyphScale, glyphScale, 1.0F);
|
||||
this.drawCenteredString(poseStack, mc.font, new TextComponent(glyph),
|
||||
this.drawCenteredString(poseStack, mc.font, Component.literal(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());
|
||||
poseStack.popPose();
|
||||
|
||||
Reference in new issue
Block a user