Skip to content

Commit da277f7

Browse files
committed
Updated to 26.1.2, Changed Multiplayer Menu Buttons, Adjustable PacketHUD Position
1 parent 43d3b12 commit da277f7

File tree

8 files changed

+146
-40
lines changed

8 files changed

+146
-40
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Overview
66

7-
- This is a rewrite of the original **UI-Utils 2.4.0**, migrated to Mojang mappings (mojmap) which was ported out of [Wurst-7-CevAPI](https://github.com/cev-api/Wurst7-CevAPI) and then bumped to **Minecraft 26.1** and put into a standalone mod.
7+
- This is a rewrite of the original **UI-Utils 2.4.0**, migrated to Mojang mappings (mojmap) which was ported out of [Wurst-7-CevAPI](https://github.com/cev-api/Wurst7-CevAPI) and then bumped to **Minecraft 26.x** and put into a standalone mod.
88
- On top of classic UI-Utils quality-of-life features, this build adds advanced packet tooling, command scanning and expanded UI controls.
99
- This application is designed and presented for people already familiar with UI-Utils. There will be no explanations or guide on how to use it in-game, you can instead find that [here](https://github.com/ui-utils/docs/blob/main/OverlayOverview.md).
1010
- If you are looking for a **1.21.11** version you can find that [here](https://github.com/cev-api/UI-Utils-CevAPI).
@@ -21,7 +21,7 @@ Artifacts land in `build/libs/`.
2121

2222
## Getting Started
2323

24-
1. Install Fabric Loader and Fabric API for your Minecraft 26.1 installation.
24+
1. Install Fabric Loader and Fabric API for your Minecraft 26.x installation.
2525
2. Drop the built jar from `build/libs/` into your `mods/` folder.
2626
3. Launch Minecraft. Open any container — the UI‑Utils toolbox appears on the left.
2727

@@ -76,6 +76,7 @@ Artifacts land in `build/libs/`.
7676
- `888 IN / 999 OUT`
7777
- ` 20 QUEUED` (only shown when queue > 0)
7878
- HUD color is configurable in Settings
79+
- Positionable to all four corners
7980
- Themed UI‑Utils buttons
8081
- Colored button renderer is used across UI‑Utils screens and injected buttons
8182
- Removes mixed vanilla/colored button look

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
org.gradle.jvmargs=-Xmx4G
22
org.gradle.parallel=true
33

4-
minecraft_version=26.1
4+
minecraft_version=26.1.2
55
loader_version=0.18.4
6-
fabric_version=0.143.14+26.1
6+
fabric_version=0.145.4+26.1.2
77

8-
mod_version=26.1.0
9-
release_version=v0.2
8+
mod_version=26.1.2
9+
release_version=v0.3
1010
maven_group=com.ui_utils
1111
archives_base_name=ui_utils_26x_cevapi

src/mojmap/java/com/ui_utils/mixin/MultiplayerScreenMixin.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.ui_utils.uiutils.UiUtils;
44
import com.ui_utils.uiutils.UiUtilsSettings;
55
import com.ui_utils.uiutils.UiUtilsState;
6+
import net.minecraft.client.gui.components.Button;
67
import net.minecraft.client.gui.screens.Screen;
78
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
89
import net.minecraft.network.chat.Component;
@@ -24,28 +25,29 @@ private MultiplayerScreenMixin(Component title) {
2425
}
2526

2627
int x = 8;
27-
int w = 170;
28+
int w = 200;
2829
int h = 20;
2930
int y2 = this.height - h - 8;
3031
int y1 = y2 - h - 4;
3132

32-
33-
addRenderableWidget(UiUtils.styledButton(
34-
"Bypass Resource Pack: " + (UiUtilsSettings.get().bypassResourcePack ? "ON" : "OFF"),
33+
addRenderableWidget(Button.builder(
34+
Component.literal("Bypass Resource Pack: "
35+
+ (UiUtilsSettings.get().bypassResourcePack ? "ON" : "OFF")),
3536
b -> {
3637
UiUtilsSettings.get().bypassResourcePack = !UiUtilsSettings.get().bypassResourcePack;
3738
UiUtilsSettings.save();
3839
b.setMessage(Component.literal("Bypass Resource Pack: "
3940
+ (UiUtilsSettings.get().bypassResourcePack ? "ON" : "OFF")));
40-
}, x, y1, w, h));
41+
}).bounds(x, y1, w, h).build());
4142

42-
addRenderableWidget(UiUtils.styledButton(
43-
"Force Deny: " + (UiUtilsSettings.get().resourcePackForceDeny ? "ON" : "OFF"),
43+
addRenderableWidget(Button.builder(
44+
Component.literal("Force Deny: "
45+
+ (UiUtilsSettings.get().resourcePackForceDeny ? "ON" : "OFF")),
4446
b -> {
4547
UiUtilsSettings.get().resourcePackForceDeny = !UiUtilsSettings.get().resourcePackForceDeny;
4648
UiUtilsSettings.save();
4749
b.setMessage(Component.literal("Force Deny: "
4850
+ (UiUtilsSettings.get().resourcePackForceDeny ? "ON" : "OFF")));
49-
}, x, y2, w, h));
51+
}).bounds(x, y2, w, h).build());
5052
}
5153
}

src/mojmap/java/com/ui_utils/uiutils/PacketHud.java

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,27 @@ public static void incOutgoing() {
3434
}
3535

3636
public static void render(GuiGraphicsExtractor g) {
37-
if (!UiUtilsSettings.get().packetHudEnabled)
37+
UiUtilsSettings.PacketHudPosition position = UiUtilsSettings.get().packetHudPosition;
38+
if (!position.isEnabled())
3839
return;
3940
Minecraft mc = Minecraft.getInstance();
4041
if (mc.level == null)
4142
return; // only in-game like Wurst's HUDs
4243
int sw = mc.getWindow().getGuiScaledWidth();
43-
int xRight = sw - 6;
44-
int y = 6;
44+
int sh = mc.getWindow().getGuiScaledHeight();
4545
int queued = com.ui_utils.uiutils.UiUtilsState.delayedUiPackets.size();
46-
boolean delaying = com.ui_utils.uiutils.UiUtilsState.delayUiPackets;
4746
String l1 = rateIn + " IN / " + rateOut + " OUT";
4847
String l2 = queued > 0 ? " " + queued + " QUEUED" : "";
4948
int w1 = mc.font.width(l1);
5049
int w2 = l2.isEmpty() ? 0 : mc.font.width(l2);
5150
int color = 0xFF000000 | (UiUtilsSettings.get().packetHudColor & 0xFFFFFF);
52-
g.text(mc.font, l1, xRight - w1, y, color, false);
53-
if(!l2.isEmpty())
54-
g.text(mc.font, l2, xRight - w2, y + 10, color, false);
51+
drawHud(g, mc.font, l1, l2, w1, w2, color, sw, sh, position);
5552
}
5653

5754
// Render path that accepts the runtime GuiGraphics instance without importing it
5855
public static void renderAny(Object graphics) {
59-
if (!UiUtilsSettings.get().packetHudEnabled)
56+
UiUtilsSettings.PacketHudPosition position = UiUtilsSettings.get().packetHudPosition;
57+
if (!position.isEnabled())
6058
return;
6159
Minecraft mc = Minecraft.getInstance();
6260
if (mc.level == null)
@@ -67,8 +65,7 @@ public static void renderAny(Object graphics) {
6765
String l2 = queued > 0 ? " " + queued + " QUEUED" : "";
6866

6967
int sw = mc.getWindow().getGuiScaledWidth();
70-
int xRight = sw - 6;
71-
int y = 6;
68+
int sh = mc.getWindow().getGuiScaledHeight();
7269
Font font = mc.font;
7370
int w1 = font.width(l1);
7471
int w2 = l2.isEmpty() ? 0 : font.width(l2);
@@ -79,19 +76,51 @@ public static void renderAny(Object graphics) {
7976
Class<?> gg = Class.forName("net.minecraft.client.gui.GuiGraphics");
8077
if (gg.isInstance(graphics)) {
8178
java.lang.reflect.Method draw = gg.getMethod("drawString", Font.class, String.class, int.class, int.class, int.class, boolean.class);
82-
draw.invoke(graphics, font, l1, xRight - w1, y, color, false);
83-
if(!l2.isEmpty())
84-
draw.invoke(graphics, font, l2, xRight - w2, y + 10, color, false);
79+
drawHud(graphics, draw, font, l1, l2, w1, w2, color, sw, sh, position);
8580
return;
8681
}
8782
} catch (Throwable ignored) {
8883
// Fall back silently
8984
}
9085

9186
if (graphics instanceof GuiGraphicsExtractor ge) {
92-
ge.text(font, l1, xRight - w1, y, color, false);
93-
if(!l2.isEmpty())
94-
ge.text(font, l2, xRight - w2, y + 10, color, false);
87+
drawHud(ge, font, l1, l2, w1, w2, color, sw, sh, position);
9588
}
9689
}
90+
91+
private static void drawHud(GuiGraphicsExtractor g, Font font, String l1,
92+
String l2, int w1, int w2, int color, int sw, int sh,
93+
UiUtilsSettings.PacketHudPosition position) {
94+
int xLeft = 6;
95+
int xRight = sw - 6;
96+
boolean right = position == UiUtilsSettings.PacketHudPosition.TOP_RIGHT
97+
|| position == UiUtilsSettings.PacketHudPosition.BOTTOM_RIGHT;
98+
boolean bottom = position == UiUtilsSettings.PacketHudPosition.BOTTOM_LEFT
99+
|| position == UiUtilsSettings.PacketHudPosition.BOTTOM_RIGHT;
100+
int x1 = right ? xRight - w1 : xLeft;
101+
int x2 = right ? xRight - w2 : xLeft;
102+
int y1 = bottom && !l2.isEmpty() ? sh - 6 - 20 : (bottom ? sh - 6 - 10 : 6);
103+
int y2 = bottom && !l2.isEmpty() ? sh - 6 - 10 : 16;
104+
g.text(font, l1, x1, y1, color, false);
105+
if (!l2.isEmpty())
106+
g.text(font, l2, x2, y2, color, false);
107+
}
108+
109+
private static void drawHud(Object graphics, java.lang.reflect.Method draw,
110+
Font font, String l1, String l2, int w1, int w2, int color, int sw,
111+
int sh, UiUtilsSettings.PacketHudPosition position) throws Exception {
112+
int xLeft = 6;
113+
int xRight = sw - 6;
114+
boolean right = position == UiUtilsSettings.PacketHudPosition.TOP_RIGHT
115+
|| position == UiUtilsSettings.PacketHudPosition.BOTTOM_RIGHT;
116+
boolean bottom = position == UiUtilsSettings.PacketHudPosition.BOTTOM_LEFT
117+
|| position == UiUtilsSettings.PacketHudPosition.BOTTOM_RIGHT;
118+
int x1 = right ? xRight - w1 : xLeft;
119+
int x2 = right ? xRight - w2 : xLeft;
120+
int y1 = bottom && !l2.isEmpty() ? sh - 6 - 20 : (bottom ? sh - 6 - 10 : 6);
121+
int y2 = bottom && !l2.isEmpty() ? sh - 6 - 10 : 16;
122+
draw.invoke(graphics, font, l1, x1, y1, color, false);
123+
if (!l2.isEmpty())
124+
draw.invoke(graphics, font, l2, x2, y2, color, false);
125+
}
97126
}

src/mojmap/java/com/ui_utils/uiutils/UiUtilsCommandSystem.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,34 @@ private static String openSettings() {
210210

211211
private static String packetHud(String args) {
212212
String mode = args == null ? "" : args.trim().toLowerCase(Locale.ROOT);
213-
if(mode.isBlank() || mode.equals("toggle"))
214-
UiUtilsSettings.get().packetHudEnabled = !UiUtilsSettings.get().packetHudEnabled;
213+
if(mode.isBlank() || mode.equals("toggle") || mode.equals("cycle"))
214+
UiUtilsSettings.get().packetHudPosition =
215+
UiUtilsSettings.get().packetHudPosition.next();
215216
else if(mode.equals("on"))
216-
UiUtilsSettings.get().packetHudEnabled = true;
217+
UiUtilsSettings.get().packetHudPosition =
218+
UiUtilsSettings.PacketHudPosition.TOP_LEFT;
217219
else if(mode.equals("off"))
218-
UiUtilsSettings.get().packetHudEnabled = false;
220+
UiUtilsSettings.get().packetHudPosition =
221+
UiUtilsSettings.PacketHudPosition.OFF;
222+
else if(mode.equals("topleft"))
223+
UiUtilsSettings.get().packetHudPosition =
224+
UiUtilsSettings.PacketHudPosition.TOP_LEFT;
225+
else if(mode.equals("topright"))
226+
UiUtilsSettings.get().packetHudPosition =
227+
UiUtilsSettings.PacketHudPosition.TOP_RIGHT;
228+
else if(mode.equals("bottomleft"))
229+
UiUtilsSettings.get().packetHudPosition =
230+
UiUtilsSettings.PacketHudPosition.BOTTOM_LEFT;
231+
else if(mode.equals("bottomright"))
232+
UiUtilsSettings.get().packetHudPosition =
233+
UiUtilsSettings.PacketHudPosition.BOTTOM_RIGHT;
219234
else
220-
return PREFIX + "Usage: packethud <on|off|toggle>";
235+
return PREFIX + "Usage: packethud <cycle|toggle|on|off|topleft|topright|bottomleft|bottomright>";
236+
UiUtilsSettings.get().packetHudEnabled =
237+
UiUtilsSettings.get().packetHudPosition.isEnabled();
221238
UiUtilsSettings.save();
222239
return PREFIX + "Packet HUD: "
223-
+ (UiUtilsSettings.get().packetHudEnabled ? "ON" : "OFF");
240+
+ UiUtilsSettings.get().packetHudPosition.label();
224241
}
225242

226243
private static String delay(String args) {

src/mojmap/java/com/ui_utils/uiutils/UiUtilsSettings.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ public static void load() {
3333

3434
try (Reader reader = Files.newBufferedReader(SETTINGS_PATH)) {
3535
Data loaded = GSON.fromJson(reader, Data.class);
36+
if (loaded != null && !loaded.packetHudEnabled
37+
&& loaded.packetHudPosition == PacketHudPosition.TOP_LEFT) {
38+
loaded.packetHudPosition = PacketHudPosition.OFF;
39+
}
40+
if (loaded != null) {
41+
loaded.packetHudEnabled = loaded.packetHudPosition.isEnabled();
42+
}
3643
data = loaded != null ? loaded : new Data();
3744
} catch (Exception e) {
3845
LOGGER.warn("Failed to load UI Utils settings, using defaults.", e);
@@ -58,6 +65,7 @@ public static final class Data {
5865
public String restoreKey = "key.keyboard.v";
5966
public String packetToolsKey = "key.keyboard.p";
6067
public boolean packetHudEnabled = true;
68+
public PacketHudPosition packetHudPosition = PacketHudPosition.TOP_LEFT;
6169
public int packetHudColor = 0xFFFFFF;
6270
public String delayToggleKey = "key.keyboard.o";
6371
public String disconnectMethod = "QUIT";
@@ -86,4 +94,36 @@ public static final class Data {
8694
public String commandScannerDontSendFilter = "";
8795
public String commandScannerPacketCommands = "I Love Cevapcici!";
8896
}
97+
98+
public enum PacketHudPosition {
99+
TOP_LEFT("Top left"),
100+
TOP_RIGHT("Top right"),
101+
BOTTOM_LEFT("Bottom left"),
102+
BOTTOM_RIGHT("Bottom right"),
103+
OFF("Off");
104+
105+
private final String label;
106+
107+
PacketHudPosition(String label) {
108+
this.label = label;
109+
}
110+
111+
public String label() {
112+
return label;
113+
}
114+
115+
public PacketHudPosition next() {
116+
return switch (this) {
117+
case TOP_LEFT -> TOP_RIGHT;
118+
case TOP_RIGHT -> BOTTOM_LEFT;
119+
case BOTTOM_LEFT -> BOTTOM_RIGHT;
120+
case BOTTOM_RIGHT -> OFF;
121+
case OFF -> TOP_LEFT;
122+
};
123+
}
124+
125+
public boolean isEnabled() {
126+
return this != OFF;
127+
}
128+
}
89129
}

src/mojmap/java/com/ui_utils/uiutils/UiUtilsSettingsScreen.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public final class UiUtilsSettingsScreen extends Screen {
2121
private EditBox selectedColorHexField;
2222

2323
private UiUtilsColoredButton overlayModeButton;
24+
private UiUtilsColoredButton packetHudButton;
2425
private UiUtilsColoredButton disconnectMethodButton;
2526
private UiUtilsColoredButton timeoutSecondsButton;
2627
private UiUtilsColoredButton timeoutLagMethodButton;
@@ -64,9 +65,9 @@ protected void init() {
6465
b -> cycleOverlayMode(), left, y, 205, rowH));
6566
refreshOverlayModeLabel();
6667

67-
addRenderableWidget(makeToggleButton(left + 215, y, 205, rowH,
68-
"Packet HUD", () -> UiUtilsSettings.get().packetHudEnabled,
69-
v -> UiUtilsSettings.get().packetHudEnabled = v));
68+
packetHudButton = addRenderableWidget(UiUtils.styledButton("",
69+
b -> cyclePacketHudPosition(), left + 215, y, 205, rowH));
70+
refreshPacketHudLabel();
7071
y += rowH + gap;
7172

7273
addRenderableWidget(makeToggleButton(left, y, panelWidth, rowH,
@@ -254,6 +255,22 @@ private void refreshOverlayModeLabel() {
254255
.setMessage(Component.literal("Slot overlay: " + mode.name()));
255256
}
256257

258+
private void cyclePacketHudPosition() {
259+
UiUtilsSettings.get().packetHudPosition =
260+
UiUtilsSettings.get().packetHudPosition.next();
261+
UiUtilsSettings.get().packetHudEnabled =
262+
UiUtilsSettings.get().packetHudPosition.isEnabled();
263+
UiUtilsSettings.save();
264+
refreshPacketHudLabel();
265+
}
266+
267+
private void refreshPacketHudLabel() {
268+
if(packetHudButton == null)
269+
return;
270+
packetHudButton.setMessage(Component.literal(
271+
"Packet HUD: " + UiUtilsSettings.get().packetHudPosition.label()));
272+
}
273+
257274
private void cycleColorTarget() {
258275
ColorTarget[] targets = ColorTarget.values();
259276
int next = (selectedTarget.ordinal() + 1) % targets.length;

src/mojmap/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"depends": {
2727
"fabricloader": ">=0.18.0",
2828
"fabric-api": "*",
29-
"minecraft": "~26.1",
29+
"minecraft": ">=26.1 <26.1.3",
3030
"java": ">=25"
3131
},
3232
"custom": {

0 commit comments

Comments
 (0)