Skip to content

Commit 40c1ce6

Browse files
committed
Updated AutoSign
1 parent dc02e19 commit 40c1ce6

4 files changed

Lines changed: 60 additions & 43 deletions

File tree

src/main/java/net/wurstclient/hack/HackList.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ public final class HackList implements UpdateListener
122122
public final CriticalsHack criticalsHack = new CriticalsHack();
123123
public final CrystalAuraHack crystalAuraHack = new CrystalAuraHack();
124124
public final DerpHack derpHack = new DerpHack();
125-
public final TunnelHoleStairEspHack tunnelHoleStairEspHack = new TunnelHoleStairEspHack();
125+
public final TunnelHoleStairEspHack tunnelHoleStairEspHack =
126+
new TunnelHoleStairEspHack();
126127
public final DolphinHack dolphinHack = new DolphinHack();
127128
public final ElytraFlightHack elytraFlightHack = new ElytraFlightHack();
128129
public final ElytraInfoHack elytraInfoHack = new ElytraInfoHack();

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

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -181,20 +181,19 @@ public String[] getSignText()
181181
}
182182
}
183183

184-
// If we already captured a template from the first edited sign while
185-
// the
186-
// hack is enabled, use that for subsequent signs.
187-
if(signText != null)
188-
return signText;
189-
190-
// Otherwise fall back to the persisted preset, if any.
191-
String preset = presetText.getValue();
192-
if(preset == null || preset.isEmpty())
193-
return null;
194-
195-
String[] wrapped = wrapToSign(preset);
196-
return wrapped == null ? null : wrapped;
197-
}
184+
// Next, prefer the persisted preset text from the GUI text box.
185+
// This lets text changes apply immediately without toggling the hack.
186+
String preset = presetText.getValue();
187+
if(preset == null || preset.isEmpty())
188+
{
189+
// If no preset text is configured, use the first manually edited
190+
// sign as a temporary template while the hack stays enabled.
191+
return signText;
192+
}
193+
194+
String[] wrapped = wrapToSign(preset);
195+
return wrapped == null ? null : wrapped;
196+
}
198197

199198
public void setSignText(String[] signText)
200199
{
@@ -407,7 +406,7 @@ public void onUpdate()
407406
}
408407

409408
String[] oldText = readSign(signEntity);
410-
if(linesMatch(oldText, newText))
409+
if(signHasDesiredText(signEntity, newText))
411410
{
412411
auraTimer = Math.max(1, auraDelay.getValueI());
413412
return;
@@ -481,6 +480,19 @@ private boolean linesMatch(String[] current, String[] desired)
481480
return true;
482481
}
483482

483+
private boolean signHasDesiredText(SignBlockEntity sign, String[] desired)
484+
{
485+
if(sign == null || desired == null)
486+
return false;
487+
488+
String[] front = readSign(sign.getFrontText());
489+
if(linesMatch(front, desired))
490+
return true;
491+
492+
String[] back = readSign(sign.getBackText());
493+
return linesMatch(back, desired);
494+
}
495+
484496
private boolean canUseHandNoClip()
485497
{
486498
if(!auraThroughWalls.isChecked())
@@ -492,15 +504,15 @@ private boolean canUseHandNoClip()
492504

493505
private String[] readSign(SignBlockEntity sign)
494506
{
495-
String[] lines = new String[MAX_LINES];
496507
if(sign == null)
497-
{
498-
for(int i = 0; i < MAX_LINES; i++)
499-
lines[i] = "";
500-
return lines;
501-
}
508+
return readSign((SignText)null);
502509

503-
SignText signText = sign.getFrontText();
510+
return readSign(sign.getFrontText());
511+
}
512+
513+
private String[] readSign(SignText signText)
514+
{
515+
String[] lines = new String[MAX_LINES];
504516
for(int i = 0; i < MAX_LINES; i++)
505517
{
506518
net.minecraft.network.chat.Component component =

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,18 @@ private void updatePing(BlockPos pos, String kind, String oldId,
288288
ping.lastOldId = oldId;
289289
ping.lastNewId = newId;
290290

291-
if(chatAlerts.isChecked() && now - ping.lastAlertMs >= 300L)
292-
{
293-
int distanceBlocks =
294-
(int)Math.round(Math.sqrt(ping.pos.distToCenterSqr(
295-
MC.player.getX(), MC.player.getY(), MC.player.getZ())));
296-
String rangeSuffix = onlyBeyondPlayerEspRange.isChecked()
297-
? String.format(" (%db away, outside %.0fb).", distanceBlocks,
298-
PLAYER_ESP_LIMIT_BLOCKS)
299-
: String.format(" (%db away).", distanceBlocks);
300-
ChatUtils.message(String.format(
301-
"PlayerSonar: %s %s -> %s at %d, %d, %d%s", ping.lastKind,
302-
ping.lastOldId, ping.lastNewId, ping.pos.getX(),
291+
if(chatAlerts.isChecked() && now - ping.lastAlertMs >= 300L)
292+
{
293+
int distanceBlocks = (int)Math
294+
.round(Math.sqrt(ping.pos.distToCenterSqr(MC.player.getX(),
295+
MC.player.getY(), MC.player.getZ())));
296+
String rangeSuffix = onlyBeyondPlayerEspRange.isChecked()
297+
? String.format(" (%db away, outside %.0fb).", distanceBlocks,
298+
PLAYER_ESP_LIMIT_BLOCKS)
299+
: String.format(" (%db away).", distanceBlocks);
300+
ChatUtils.message(String.format(
301+
"PlayerSonar: %s %s -> %s at %d, %d, %d%s", ping.lastKind,
302+
ping.lastOldId, ping.lastNewId, ping.pos.getX(),
303303
ping.pos.getY(), ping.pos.getZ(), rangeSuffix));
304304
ping.lastAlertMs = now;
305305
}

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@
5050

5151
@SearchTags({"dig spot esp", "digspot esp", "hole esp", "tunnel esp",
5252
"stairs esp"})
53-
public final class TunnelHoleStairEspHack extends Hack implements UpdateListener,
54-
RenderListener, CameraTransformViewBobbingListener, PacketInputListener
53+
public final class TunnelHoleStairEspHack extends Hack
54+
implements UpdateListener, RenderListener,
55+
CameraTransformViewBobbingListener, PacketInputListener
5556
{
5657
private static final Direction[] CARDINALS =
5758
{Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST};
@@ -335,16 +336,19 @@ private void renderBoxes(PoseStack matrixStack)
335336
private void renderTracers(PoseStack matrixStack, float partialTicks)
336337
{
337338
if(!holeBoxes.isEmpty())
338-
RenderUtils.drawTracers("TunnelHoleStairESP", matrixStack, partialTicks,
339-
getCenters(holeBoxes), holeColor.getColorI(0x95), false);
339+
RenderUtils.drawTracers("TunnelHoleStairESP", matrixStack,
340+
partialTicks, getCenters(holeBoxes), holeColor.getColorI(0x95),
341+
false);
340342

341343
if(!tunnelBoxes.isEmpty())
342-
RenderUtils.drawTracers("TunnelHoleStairESP", matrixStack, partialTicks,
343-
getCenters(tunnelBoxes), tunnelColor.getColorI(0x95), false);
344+
RenderUtils.drawTracers("TunnelHoleStairESP", matrixStack,
345+
partialTicks, getCenters(tunnelBoxes),
346+
tunnelColor.getColorI(0x95), false);
344347

345348
if(!stairBoxes.isEmpty())
346-
RenderUtils.drawTracers("TunnelHoleStairESP", matrixStack, partialTicks,
347-
getCenters(stairBoxes), stairColor.getColorI(0x95), false);
349+
RenderUtils.drawTracers("TunnelHoleStairESP", matrixStack,
350+
partialTicks, getCenters(stairBoxes),
351+
stairColor.getColorI(0x95), false);
348352
}
349353

350354
private ArrayList<Vec3> getCenters(ArrayList<AABB> boxes)

0 commit comments

Comments
 (0)