LexManos committed 2023-12-06 10:38:20 -08:00
1 parent 6f9f0f0cfa
commit d2367d81fc
456 files changed
+2432 -2933

No files matched your search

@@ -18,7 +18,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandRuntimeException;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.synchronization.SuggestionProviders;
@@ -156,16 +155,11 @@ public class ClientCommandHandler
ClientCommandSourceStack source = getSource();
try
{
try {
commands.execute(reader, source);
}
catch (CommandRuntimeException execution)// Probably thrown by the command
{
Minecraft.getInstance().player.sendSystemMessage(Component.literal("").append(execution.getComponent()).withStyle(ChatFormatting.RED));
}
catch (CommandSyntaxException syntax)// Usually thrown by the CommandDispatcher
{
//} catch (CommandRuntimeException execution) { // Probably thrown by the command
// Minecraft.getInstance().player.sendSystemMessage(Component.literal("").append(execution.getComponent()).withStyle(ChatFormatting.RED));
} catch (CommandSyntaxException syntax) {
if (syntax.getType() == CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand() || syntax.getType() == CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument())
{
// in case of unknown command, let the server try and handle it
@@ -89,7 +89,7 @@ public class LoadingErrorScreen extends ErrorScreen {
public static class LoadingEntryList extends ObjectSelectionList<LoadingEntryList.LoadingMessageEntry> {
LoadingEntryList(final LoadingErrorScreen parent, final List<ModLoadingException> errors, final List<ModLoadingWarning> warnings) {
super(Objects.requireNonNull(parent.minecraft), parent.width, parent.height, 35, parent.height - 50,
super(Objects.requireNonNull(parent.minecraft), parent.width, parent.height, 35,
Math.max(
errors.stream().mapToInt(error -> parent.font.split(Component.literal(error.getMessage() != null ? error.getMessage() : ""), parent.width - 20).size()).max().orElse(0),
warnings.stream().mapToInt(warning -> parent.font.split(Component.literal(warning.formatToString() != null ? warning.formatToString() : ""), parent.width - 20).size()).max().orElse(0)
@@ -270,7 +270,7 @@ public class ModListScreen extends Screen
search = new EditBox(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, Component.translatable("fml.menu.mods.search"));
this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.getY() - getFontRenderer().lineHeight - PADDING);
this.modList.setLeftPos(6);
this.modList.setX(6);
this.modInfo = new InfoPanel(this.minecraft, modInfoWidth, this.height - PADDING - fullButtonHeight, PADDING);
this.addRenderableWidget(modList);
@@ -365,7 +365,7 @@ public class ModListScreen extends Screen
this.modInfo.render(guiGraphics, mouseX, mouseY, partialTick);
Component text = Component.translatable("fml.menu.mods.search");
int x = modList.getLeft() + ((modList.getRight() - modList.getLeft()) / 2) - (getFontRenderer().width(text) / 2);
int x = modList.getX() + (modList.getWidth() / 2) - (getFontRenderer().width(text) / 2);
this.search.render(guiGraphics, mouseX , mouseY, partialTick);
super.render(guiGraphics, mouseX, mouseY, partialTick);
guiGraphics.drawString(getFontRenderer(), text.getVisualOrderText(), x, search.getY() - getFontRenderer().lineHeight, 0xFFFFFF, false);
@@ -16,6 +16,7 @@ import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.util.StringUtil;
@@ -351,7 +352,7 @@ public class ForgeGui extends Gui {
if (time >= 120500L)
listR.add(I18n.get("demo.demoExpired"));
else
listR.add(I18n.get("demo.remainingTime", StringUtil.formatTickDuration((int) (120500L - time))));
listR.add(I18n.get("demo.remainingTime", StringUtil.formatTickDuration((int)(120500L - this.minecraft.level.getGameTime()), this.minecraft.level.tickRateManager().tickrate())));
}
var forgeOverlay = (OverlayAccess)debugOverlay;
@@ -30,7 +30,7 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry>
public ModListWidget(ModListScreen parent, int listWidth, int top, int bottom)
{
super(parent.getMinecraftInstance(), listWidth, parent.height, top, bottom, parent.getFontRenderer().lineHeight * 2 + 8);
super(parent.getMinecraftInstance(), listWidth, parent.height, top, parent.getFontRenderer().lineHeight * 2 + 8);
this.parent = parent;
this.listWidth = listWidth;
this.refreshList();
@@ -53,11 +53,13 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry>
parent.buildModList(this::addEntry, mod->new ModEntry(mod, this.parent));
}
/*
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
this.parent.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
super.render(guiGraphics, mouseX, mouseY, partialTicks);
}
*/
public class ModEntry extends ObjectSelectionList.Entry<ModEntry> {
private final IModInfo modInfo;
@@ -87,7 +89,7 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry>
//TODO: Consider adding more icons for visualization
RenderSystem.setShaderColor(1, 1, 1, 1);
guiGraphics.pose().pushPose();
guiGraphics.blit(VERSION_CHECK_ICONS, getLeft() + width - 12, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
guiGraphics.blit(VERSION_CHECK_ICONS, getX() + width - 12, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
guiGraphics.pose().popPose();
}
}
@@ -1,62 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.client.gui.widget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
/**
* This class provides a button that shows a string glyph at the beginning. The glyph can be scaled using the glyphScale parameter.
*
* @author bspkrs
*/
public class UnicodeGlyphButton extends ExtendedButton
{
public String glyph;
public float glyphScale;
public UnicodeGlyphButton(int xPos, int yPos, int width, int height, Component displayString, String glyph, float glyphScale, OnPress handler)
{
super(xPos, yPos, width, height, displayString, handler);
this.glyph = glyph;
this.glyphScale = glyphScale;
}
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
{
if (this.visible)
{
Minecraft mc = Minecraft.getInstance();
this.isHovered = mouseX >= this.getX() && mouseY >= this.getY() && mouseX < this.getX() + this.width && mouseY < this.getY() + this.height;
guiGraphics.blitSprite(SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight());
Component buttonText = this.createNarrationMessage();
int glyphWidth = (int) (mc.font.width(glyph) * glyphScale);
int strWidth = mc.font.width(buttonText);
int ellipsisWidth = mc.font.width("...");
int totalWidth = strWidth + glyphWidth;
if (totalWidth > width - 6 && totalWidth > ellipsisWidth)
buttonText = Component.literal(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString().trim() + "...") ;
strWidth = mc.font.width(buttonText);
totalWidth = glyphWidth + strWidth;
guiGraphics.pose().pushPose();
guiGraphics.pose().scale(glyphScale, glyphScale, 1.0F);
guiGraphics.drawCenteredString(mc.font, Component.literal(glyph),
(int) (((this.getX() + (this.width / 2) - (strWidth / 2)) / glyphScale) - (glyphWidth / (2 * glyphScale)) + 2),
(int) (((this.getY() + ((this.height - 8) / glyphScale) / 2) - 1) / glyphScale), getFGColor());
guiGraphics.pose().popPose();
guiGraphics.drawCenteredString(mc.font, buttonText, (int) (this.getX() + (this.width / 2) + (glyphWidth / glyphScale)),
this.getY() + (this.height - 8) / 2, getFGColor());
}
}
}