Skip to content

Commit 8216415

Browse files
committed
Updated AltGUI, PlayerESP, SpearAssist
1 parent fc0a052 commit 8216415

6 files changed

Lines changed: 260 additions & 39 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,8 @@ Examples:
10231023
- Added toggle for unique colors for each player (shared with Breadcrumbs)
10241024
- Added box fill with transparency slider
10251025
- Added static color option
1026+
- Added rainbow color option
1027+
- Added much thicker tracer lines (max 10px)
10261028
- Added glow outlines as an option
10271029
- Added Line of Sight Detection (LOS)
10281030
- When you're spotted ESP and tracer will turn a bold red regardless of distance or color settings

src/main/java/net/wurstclient/altgui/AltGuiScreen.java

Lines changed: 105 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ private int getSearchHeight()
200200

201201
private float getRightSettingsWidthScale()
202202
{
203-
return Math.max(0.2F, cfg().getSettingsWidth());
203+
return Math.max(0.05F, cfg().getSettingsWidth());
204204
}
205205

206206
private float getRightSettingsHeightScale()
207207
{
208-
return Math.max(0.2F, cfg().getSettingsHeight());
208+
return Math.max(0.05F, cfg().getSettingsHeight());
209209
}
210210

211211
private int scaleRightSettingWidth(int value)
@@ -218,6 +218,13 @@ private int scaleRightSettingHeight(int value)
218218
return Math.max(1, Math.round(value * getRightSettingsHeightScale()));
219219
}
220220

221+
private int getMinimumReadableUiRowHeight()
222+
{
223+
Font font = minecraft != null ? minecraft.font : null;
224+
int textH = font == null ? 9 : Math.max(1, scaledFontHeight(font));
225+
return Math.max(10, textH + 2);
226+
}
227+
221228
private int getSettingsValueColumnWidth(int rowX1, int rowX2)
222229
{
223230
int min = scaleRightSettingWidth(120);
@@ -348,7 +355,7 @@ public void render(GuiGraphics context, int mouseX, int mouseY,
348355
hoverTooltip = "";
349356
syncFontManager();
350357
int bg =
351-
withAlpha(cfg().getBackgroundColor(), cfg().getUiOpacity() * 0.86F);
358+
withAlpha(cfg().getBackgroundColor(), cfg().getBackgroundOpacity());
352359
int panel = withAlpha(cfg().getPanelColor(), cfg().getUiOpacity());
353360

354361
context.fill(0, 0, width, height, bg);
@@ -362,13 +369,49 @@ public void render(GuiGraphics context, int mouseX, int mouseY,
362369

363370
if(searchBox != null)
364371
{
365-
searchBox.setTextColor(cfg().getTextColor());
366-
searchBox.render(context, mouseX, mouseY, partialTicks);
372+
renderSearchBoxText(context);
367373
}
368374

369375
renderTooltip(context);
370376
}
371377

378+
private void renderSearchBoxText(GuiGraphics context)
379+
{
380+
if(searchBox == null)
381+
return;
382+
383+
Font font = minecraft.font;
384+
int x1 = searchBox.getX();
385+
int y1 = searchBox.getY();
386+
int x2 = x1 + searchBox.getWidth();
387+
int y2 = y1 + searchBox.getHeight();
388+
int padX =
389+
Math.max(6, Math.round(4F * Math.max(0.25F, cfg().getFontScale())));
390+
int textY = centeredTextY(font, y1, y2);
391+
int maxTextW = Math.max(1, (x2 - x1) - padX * 2);
392+
393+
String value = searchBox.getValue();
394+
boolean focused = searchBox.isFocused();
395+
boolean empty = value == null || value.isBlank();
396+
String baseText =
397+
empty && !focused ? "search" : (value == null ? "" : value);
398+
String drawText = trimToWidth(font, baseText, maxTextW);
399+
int textColor = empty && !focused ? cfg().getMutedTextColor()
400+
: cfg().getTextColor();
401+
402+
drawStringScaled(context, font, drawText, x1 + padX, textY, textColor,
403+
false);
404+
405+
if(focused && (minecraft.gui.getGuiTicks() / 6) % 2 == 0)
406+
{
407+
int caretX = x1 + padX + scaledFontWidth(font, drawText);
408+
int caretTop = textY;
409+
int caretBottom = textY + Math.max(1, scaledFontHeight(font));
410+
context.fill(caretX, caretTop, caretX + 1, caretBottom,
411+
withAlpha(cfg().getTextColor(), cfg().getUiOpacity()));
412+
}
413+
}
414+
372415
private void renderHeader(GuiGraphics context)
373416
{
374417
Font font = minecraft.font;
@@ -668,7 +711,6 @@ private void renderSettingRow(GuiGraphics context, Font font, int mouseX,
668711

669712
if(!valueText.isEmpty())
670713
{
671-
valueText = trimToWidth(font, valueText, valueBoxW - valuePad * 2);
672714
int valuePadY = getPillPadding(font, y2 - y1);
673715
int valueY1 = y1 + valuePadY;
674716
int valueY2 = y2 - valuePadY;
@@ -705,8 +747,8 @@ && cfg().isFillColorValuesEnabled())
705747
context.fill(valueX1, valueY1, valueX2, valueY2,
706748
getValueBadgeColor(row.setting(), valueText));
707749
}
708-
drawCenteredStringScaledInBox(context, font, valueText, valueX1,
709-
valueY1, valueX2, valueY2, valueTextColor);
750+
drawMarqueeStringScaledInBox(context, font, valueText, valueX1,
751+
valueY1, valueX2, valueY2, valueTextColor, valuePad);
710752

711753
if(row.setting() instanceof ColorSetting color
712754
&& !cfg().isFillColorValuesEnabled())
@@ -743,6 +785,8 @@ private void renderUiSettingsPanel(GuiGraphics context, int mouseX,
743785
int y = uiMenuY + 24;
744786
y = renderUiSlider(context, font, "UI opacity",
745787
cfg().getUiOpacitySetting(), y, mouseX, mouseY);
788+
y = renderUiSlider(context, font, "Background opacity",
789+
cfg().getBackgroundOpacitySetting(), y, mouseX, mouseY);
746790
y = renderUiSlider(context, font, "Settings width",
747791
cfg().getSettingsWidthSetting(), y, mouseX, mouseY);
748792
y = renderUiSlider(context, font, "Settings height",
@@ -796,7 +840,8 @@ private void renderUiSettingsPanel(GuiGraphics context, int mouseX,
796840
private int renderUiSlider(GuiGraphics context, Font font, String label,
797841
SliderSetting slider, int y, int mouseX, int mouseY)
798842
{
799-
int rowH = scaleRightSettingHeight(14);
843+
int rowH = Math.max(getMinimumReadableUiRowHeight(),
844+
scaleRightSettingHeight(14));
800845
int x1 = uiMenuX + 8;
801846
int x2 = uiMenuX + uiMenuW - 8;
802847
int trackX1 = uiMenuX + scaleRightSettingWidth(144);
@@ -820,7 +865,8 @@ private int renderUiSlider(GuiGraphics context, Font font, String label,
820865
private int renderUiToggle(GuiGraphics context, Font font, String label,
821866
CheckboxSetting setting, int y, int mouseX, int mouseY)
822867
{
823-
int rowH = scaleRightSettingHeight(14);
868+
int rowH = Math.max(getMinimumReadableUiRowHeight(),
869+
scaleRightSettingHeight(14));
824870
int x1 = uiMenuX + 8;
825871
int x2 = uiMenuX + uiMenuW - 8;
826872
boolean hovered = isInside(mouseX, mouseY, x1, y, x2, y + rowH);
@@ -846,7 +892,8 @@ private int renderUiToggle(GuiGraphics context, Font font, String label,
846892
private int renderUiColor(GuiGraphics context, Font font, String label,
847893
ColorSetting color, int y, int mouseX, int mouseY)
848894
{
849-
int rowH = scaleRightSettingHeight(13);
895+
int rowH = Math.max(getMinimumReadableUiRowHeight(),
896+
scaleRightSettingHeight(13));
850897
int x1 = uiMenuX + 8;
851898
int x2 = uiMenuX + uiMenuW - 8;
852899
boolean hovered = isInside(mouseX, mouseY, x1, y, x2, y + rowH);
@@ -874,6 +921,8 @@ private boolean handleUiSettingsClick(double mouseX, double mouseY,
874921
int y = uiMenuY + 24;
875922
y = handleUiSliderClick(cfg().getUiOpacitySetting(), mouseX, mouseY, y,
876923
button);
924+
y = handleUiSliderClick(cfg().getBackgroundOpacitySetting(), mouseX,
925+
mouseY, y, button);
877926
y = handleUiSliderClick(cfg().getSettingsWidthSetting(), mouseX, mouseY,
878927
y, button);
879928
y = handleUiSliderClick(cfg().getSettingsHeightSetting(), mouseX,
@@ -927,7 +976,8 @@ private boolean handleUiSettingsClick(double mouseX, double mouseY,
927976
private int handleUiSliderClick(SliderSetting slider, double mouseX,
928977
double mouseY, int y, int button)
929978
{
930-
int rowH = scaleRightSettingHeight(14);
979+
int rowH = Math.max(getMinimumReadableUiRowHeight(),
980+
scaleRightSettingHeight(14));
931981
int x1 = uiMenuX + 8;
932982
int x2 = uiMenuX + uiMenuW - 8;
933983
int trackX1 = uiMenuX + scaleRightSettingWidth(144);
@@ -950,7 +1000,8 @@ private int handleUiSliderClick(SliderSetting slider, double mouseX,
9501000
private int handleUiColorClick(ColorSetting setting, double mouseX,
9511001
double mouseY, int y)
9521002
{
953-
int rowH = scaleRightSettingHeight(13);
1003+
int rowH = Math.max(getMinimumReadableUiRowHeight(),
1004+
scaleRightSettingHeight(13));
9541005
int x1 = uiMenuX + 8;
9551006
int x2 = uiMenuX + uiMenuW - 8;
9561007
if(isInside(mouseX, mouseY, x1, y, x2, y + rowH))
@@ -961,7 +1012,8 @@ private int handleUiColorClick(ColorSetting setting, double mouseX,
9611012
private int handleUiToggleClick(CheckboxSetting setting, double mouseX,
9621013
double mouseY, int y)
9631014
{
964-
int rowH = scaleRightSettingHeight(14);
1015+
int rowH = Math.max(getMinimumReadableUiRowHeight(),
1016+
scaleRightSettingHeight(14));
9651017
int x1 = uiMenuX + 8;
9661018
int x2 = uiMenuX + uiMenuW - 8;
9671019
if(isInside(mouseX, mouseY, x1, y, x2, y + rowH))
@@ -1620,7 +1672,7 @@ private void appendSettingRows(List<SettingRow> rows, Feature owner,
16201672
? Math.max(4,
16211673
Math.round(cfg().getRowHeight()
16221674
* getRightSettingsHeightScale() / 2F))
1623-
: Math.max(12, Math.round(
1675+
: Math.max(cfg().getMinimumRowHeight(), Math.round(
16241676
cfg().getRowHeight() * getRightSettingsHeightScale()));
16251677
rows.add(new SettingRow(owner, setting, depth, h));
16261678

@@ -1805,6 +1857,7 @@ private String normalizeDisplayValue(String value)
18051857
private boolean isStyleSlider(SliderSetting slider)
18061858
{
18071859
return slider == cfg().getUiOpacitySetting()
1860+
|| slider == cfg().getBackgroundOpacitySetting()
18081861
|| slider == cfg().getTooltipOpacitySetting()
18091862
|| slider == cfg().getSettingsWidthSetting()
18101863
|| slider == cfg().getSettingsHeightSetting()
@@ -2006,6 +2059,43 @@ private void drawCenteredStringScaledInBox(GuiGraphics context, Font font,
20062059
drawStringScaled(context, font, text, x, y, color, false);
20072060
}
20082061

2062+
private void drawMarqueeStringScaledInBox(GuiGraphics context, Font font,
2063+
String text, int x1, int y1, int x2, int y2, int color, int padX)
2064+
{
2065+
if(text == null || text.isEmpty())
2066+
return;
2067+
2068+
int innerX1 = x1 + Math.max(0, padX);
2069+
int innerX2 = x2 - Math.max(0, padX);
2070+
if(innerX2 <= innerX1)
2071+
return;
2072+
2073+
int innerW = innerX2 - innerX1;
2074+
int textW = Math.max(1, scaledFontWidth(font, text));
2075+
int textH = Math.max(1, scaledFontHeight(font));
2076+
int y = Math.round((y1 + y2) * 0.5F - textH * 0.5F);
2077+
2078+
if(textW <= innerW)
2079+
{
2080+
int x = Math.round((x1 + x2) * 0.5F - textW * 0.5F);
2081+
drawStringScaled(context, font, text, x, y, color, false);
2082+
return;
2083+
}
2084+
2085+
int overflow = textW - innerW;
2086+
int ticks = minecraft != null && minecraft.gui != null
2087+
? minecraft.gui.getGuiTicks()
2088+
: (int)(System.currentTimeMillis() / 50L);
2089+
float cycle = 220F;
2090+
float phase = (ticks % (int)cycle) / cycle;
2091+
float pingPong = phase <= 0.5F ? phase * 2F : (1F - phase) * 2F;
2092+
int x = innerX1 - Math.round(overflow * pingPong);
2093+
2094+
context.enableScissor(innerX1, y1, innerX2, y2);
2095+
drawStringScaled(context, font, text, x, y, color, false);
2096+
context.disableScissor();
2097+
}
2098+
20092099
@Override
20102100
public void renderBackground(GuiGraphics context, int mouseX, int mouseY,
20112101
float deltaTicks)

src/main/java/net/wurstclient/hacks/AltGuiHack.java

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import net.wurstclient.DontBlock;
1313
import net.wurstclient.SearchTags;
14+
import net.wurstclient.Category;
1415
import net.wurstclient.altgui.AltGuiFontManager;
1516
import net.wurstclient.altgui.AltGuiScreen;
1617
import net.wurstclient.hack.DontSaveState;
@@ -50,22 +51,24 @@ public final class AltGuiHack extends Hack
5051

5152
private final SliderSetting uiOpacity = new SliderSetting("UI opacity",
5253
0.82, 0.25, 1, 0.01, ValueDisplay.PERCENTAGE);
54+
private final SliderSetting backgroundOpacity = new SliderSetting(
55+
"Background opacity", 0.70, 0, 1, 0.01, ValueDisplay.PERCENTAGE);
5356
private final SliderSetting tooltipOpacity = new SliderSetting(
5457
"Tooltip opacity", 0.86, 0.1, 1, 0.01, ValueDisplay.PERCENTAGE);
5558
private final SliderSetting settingsWidth = new SliderSetting(
56-
"Settings width", 0.7, 0.2, 1.0, 0.02, ValueDisplay.DECIMAL);
59+
"Settings width", 0.7, 0.05, 1.0, 0.01, ValueDisplay.DECIMAL);
5760
private final SliderSetting settingsHeight = new SliderSetting(
58-
"Settings height", 0.7, 0.2, 1.0, 0.02, ValueDisplay.DECIMAL);
61+
"Settings height", 0.7, 0.05, 1.0, 0.01, ValueDisplay.DECIMAL);
5962
private final SliderSetting widthPercent = new SliderSetting("Window width",
6063
0.96, 0.5, 1, 0.01, ValueDisplay.PERCENTAGE);
6164
private final SliderSetting heightPercent = new SliderSetting(
6265
"Window height", 0.92, 0.5, 1, 0.01, ValueDisplay.PERCENTAGE);
6366
private final SliderSetting categoryHeight = new SliderSetting(
64-
"Category height", 16, 12, 32, 1, ValueDisplay.INTEGER);
67+
"Category height", 16, 8, 32, 1, ValueDisplay.INTEGER);
6568
private final SliderSetting categoryWidth = new SliderSetting(
66-
"Category width", 110, 70, 240, 1, ValueDisplay.INTEGER);
69+
"Category width", 110, 40, 240, 1, ValueDisplay.INTEGER);
6770
private final SliderSetting rowHeight =
68-
new SliderSetting("Row height", 18, 14, 30, 1, ValueDisplay.INTEGER);
71+
new SliderSetting("Row height", 18, 8, 30, 1, ValueDisplay.INTEGER);
6972
private final SliderSetting fontScale = new SliderSetting("Font scale", 1.0,
7073
0.3, 1.8, 0.05, ValueDisplay.DECIMAL);
7174
private final EnumSetting<FontSmoothing> fontSmoothing = new EnumSetting<>(
@@ -117,6 +120,7 @@ public AltGuiHack()
117120
addSetting(enabledColor);
118121
addSetting(disabledColor);
119122
addSetting(uiOpacity);
123+
addSetting(backgroundOpacity);
120124
addSetting(tooltipOpacity);
121125
addSetting(settingsWidth);
122126
addSetting(settingsHeight);
@@ -207,6 +211,11 @@ public float getUiOpacity()
207211
return uiOpacity.getValueF();
208212
}
209213

214+
public float getBackgroundOpacity()
215+
{
216+
return backgroundOpacity.getValueF();
217+
}
218+
210219
public float getTooltipOpacity()
211220
{
212221
return tooltipOpacity.getValueF();
@@ -234,12 +243,12 @@ public double getHeightPercent()
234243

235244
public int getCategoryWidth()
236245
{
237-
return categoryWidth.getValueI();
246+
return Math.max(categoryWidth.getValueI(), getMinimumCategoryWidth());
238247
}
239248

240249
public int getCategoryHeight()
241250
{
242-
return categoryHeight.getValueI();
251+
return Math.max(categoryHeight.getValueI(), getMinimumCategoryHeight());
243252
}
244253

245254
public int getRowHeight()
@@ -297,6 +306,11 @@ public SliderSetting getUiOpacitySetting()
297306
return uiOpacity;
298307
}
299308

309+
public SliderSetting getBackgroundOpacitySetting()
310+
{
311+
return backgroundOpacity;
312+
}
313+
300314
public SliderSetting getTooltipOpacitySetting()
301315
{
302316
return tooltipOpacity;
@@ -436,15 +450,46 @@ public int getMinimumRowHeight()
436450
cachedMinScale = scale;
437451
cachedMinSmoothing = smoothing;
438452
cachedMinFamily = family;
439-
cachedMinRowHeight = Math.max(14, scaledTextHeight + 4);
453+
cachedMinRowHeight = Math.max(10, scaledTextHeight + 4);
440454
return cachedMinRowHeight;
441455
}
442456

457+
public int getMinimumCategoryHeight()
458+
{
459+
AltGuiFontManager manager = AltGuiFontManager.getInstance();
460+
manager.setSmoothingFactor(getFontSmoothingFactor());
461+
manager.setActiveFont(getSelectedFontFamily());
462+
int lineHeight =
463+
MC != null && MC.font != null ? manager.getLineHeight(MC.font) : 9;
464+
int scaledTextHeight = (int)Math.ceil(lineHeight * getFontScale());
465+
return Math.max(10, scaledTextHeight + 4);
466+
}
467+
468+
public int getMinimumCategoryWidth()
469+
{
470+
AltGuiFontManager manager = AltGuiFontManager.getInstance();
471+
manager.setSmoothingFactor(getFontSmoothingFactor());
472+
manager.setActiveFont(getSelectedFontFamily());
473+
int maxTextWidth = manager.getTextWidth(MC.font, "Client Settings");
474+
maxTextWidth =
475+
Math.max(maxTextWidth, manager.getTextWidth(MC.font, "Enabled"));
476+
for(Category category : Category.values())
477+
maxTextWidth = Math.max(maxTextWidth,
478+
manager.getTextWidth(MC.font, category.getName()));
479+
return Math.max(40, (int)Math.ceil(maxTextWidth * getFontScale()) + 20);
480+
}
481+
443482
public void enforceNoClipLayout()
444483
{
445484
int minRowHeight = getMinimumRowHeight();
446485
if(rowHeight.getValueI() < minRowHeight)
447486
rowHeight.setValue(minRowHeight);
487+
int minCategoryHeight = getMinimumCategoryHeight();
488+
if(categoryHeight.getValueI() < minCategoryHeight)
489+
categoryHeight.setValue(minCategoryHeight);
490+
int minCategoryWidth = getMinimumCategoryWidth();
491+
if(categoryWidth.getValueI() < minCategoryWidth)
492+
categoryWidth.setValue(minCategoryWidth);
448493
}
449494

450495
public void resetStyle()
@@ -458,6 +503,7 @@ public void resetStyle()
458503
enabledColor.setColor(enabledColor.getDefaultColor());
459504
disabledColor.setColor(disabledColor.getDefaultColor());
460505
uiOpacity.setValue(uiOpacity.getDefaultValue());
506+
backgroundOpacity.setValue(backgroundOpacity.getDefaultValue());
461507
tooltipOpacity.setValue(tooltipOpacity.getDefaultValue());
462508
settingsWidth.setValue(settingsWidth.getDefaultValue());
463509
settingsHeight.setValue(settingsHeight.getDefaultValue());

0 commit comments

Comments
 (0)