Skip to content

Commit a17af3d

Browse files
committed
Updated PlayerESP/AntiSocial Alerts, Bookbot, Etc
1 parent 2c390b0 commit a17af3d

10 files changed

Lines changed: 395 additions & 243 deletions

File tree

src/main/java/net/wurstclient/commands/NoGoZoneCmd.java

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public NoGoZoneCmd()
2626
super("nogozone",
2727
"Manages NoGoZones - areas you cannot re-enter after leaving.\n"
2828
+ "Use when NoGoZone hack is enabled.",
29-
".nogozone add [x z]", ".nogozone list", ".nogozone remove <id>",
30-
".nogozone clear");
29+
".nogozone add [x z [radius]]", ".nogozone list",
30+
".nogozone remove <id>", ".nogozone clear");
3131
}
3232

3333
@Override
@@ -68,24 +68,30 @@ private void addZone(String[] args) throws CmdError
6868
ChatUtils.error("You must be in a world to add a NoGoZone.");
6969
return;
7070
}
71-
if(args.length != 1 && args.length != 3)
72-
throw new CmdError("Usage: .nogozone add [x z]");
71+
if(args.length != 1 && args.length != 3 && args.length != 4)
72+
throw new CmdError("Usage: .nogozone add [x z [radius]]");
7373

7474
// Read the effective render distance (capped by server view distance)
7575
int renderDistance = MC.options.getEffectiveRenderDistance();
7676
// Add +3 as specified
77-
int chunkRadius = renderDistance + 3;
77+
int blockRadius = (renderDistance + 3) * 16;
7878

7979
BlockPos zonePos = args.length == 3
8080
? parseXZ(args[1], args[2], MC.player.blockPosition().getY())
8181
: MC.player.blockPosition();
82-
int id = NoGoZoneHack.addZone(zonePos, chunkRadius);
82+
if(args.length == 4)
83+
{
84+
zonePos =
85+
parseXZ(args[1], args[2], MC.player.blockPosition().getY());
86+
blockRadius = parseRadius(args[3]);
87+
}
88+
89+
int id = NoGoZoneHack.addZone(zonePos, blockRadius);
8390
WURST.getHax().noGoZoneHack.setEnabled(true);
8491

85-
int blockRadius = chunkRadius * 16;
8692
ChatUtils.message("NoGoZone #" + id + " created at " + zonePos.getX()
8793
+ " " + zonePos.getY() + " " + zonePos.getZ() + " with radius "
88-
+ blockRadius + " blocks (" + chunkRadius + " chunks).");
94+
+ blockRadius + " blocks.");
8995
}
9096

9197
private BlockPos parseXZ(String xStr, String zStr, int y) throws CmdError
@@ -101,6 +107,21 @@ private BlockPos parseXZ(String xStr, String zStr, int y) throws CmdError
101107
}
102108
}
103109

110+
private int parseRadius(String radiusStr) throws CmdError
111+
{
112+
try
113+
{
114+
int radius = Integer.parseInt(radiusStr);
115+
if(radius < 1)
116+
throw new CmdError("Radius must be at least 1 block.");
117+
return radius;
118+
119+
}catch(NumberFormatException e)
120+
{
121+
throw new CmdError("Invalid radius: " + radiusStr);
122+
}
123+
}
124+
104125
private void listZones()
105126
{
106127
List<NoGoZone> zones = NoGoZoneHack.getZones();
@@ -116,8 +137,7 @@ private void listZones()
116137
{
117138
ChatUtils.message(" #" + zone.id + " | XYZ: " + zone.center.getX()
118139
+ " " + zone.center.getY() + " " + zone.center.getZ()
119-
+ " | Radius: " + zone.getBlockRadius() + " blocks ("
120-
+ zone.chunkRadius + " chunks)");
140+
+ " | Radius: " + zone.getBlockRadius() + " blocks");
121141
}
122142
}
123143

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,21 @@ public void onPlayerEnter(Player player,
120120

121121
String intruder =
122122
player == null ? info.getName() : player.getName().getString();
123+
Vec3 selfPos = MC.player == null ? null : MC.player.position();
123124

124125
Mode selectedMode = mode.getSelected();
125126
ChatUtils.message("\u00a76Antisocial:\u00a7r " + intruder
126127
+ " entered your range. Leaving via " + selectedMode + " mode.");
127128

128-
leave(selectedMode, intruder, info.getLastPos());
129+
leave(selectedMode, intruder, selfPos, info.getLastPos());
129130
}
130131

131-
private void leave(Mode selectedMode, String intruder, Vec3 intruderPos)
132+
private void leave(Mode selectedMode, String intruder, Vec3 selfPos,
133+
Vec3 intruderPos)
132134
{
133-
String details = "Detected player: " + intruder + "\nDetected at: "
134-
+ formatVec(intruderPos);
135+
String details = "Detected player: " + intruder + "\nDetected at:\n"
136+
+ DisconnectContext.formatPlayerDetectionDetails(selfPos,
137+
intruderPos);
135138

136139
switch(selectedMode)
137140
{
@@ -189,13 +192,4 @@ public void onPlayerExit(PlayerRangeAlertManager.PlayerInfo info)
189192
{
190193
// not needed
191194
}
192-
193-
private static String formatVec(Vec3 vec)
194-
{
195-
if(vec == null)
196-
return "unknown";
197-
198-
return String.format(java.util.Locale.ROOT, "%.1f, %.1f, %.1f", vec.x,
199-
vec.y, vec.z);
200-
}
201195
}

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,12 +1441,21 @@ public void onRenderGUI(GuiGraphicsExtractor context, float partialTicks)
14411441
if(info == null || info.isBlank())
14421442
return;
14431443

1444+
String eta = buildETAInfo();
1445+
14441446
Font font = MC.font;
14451447
int centerX = context.guiWidth() / 2;
14461448
int y = context.guiHeight() / 2 + 10;
14471449
int textWidth = font.width(info);
14481450
int x = centerX - textWidth / 2;
14491451
context.text(font, info, x, y, 0xFFFFFFFF, true);
1452+
1453+
if(eta != null && !eta.isBlank())
1454+
{
1455+
int etaWidth = font.width(eta);
1456+
int etaX = centerX - etaWidth / 2;
1457+
context.text(font, eta, etaX, y + 10, 0xFFAAAAAA, true);
1458+
}
14501459
}
14511460

14521461
@Override
@@ -2177,6 +2186,47 @@ private String buildCrosshairInfo()
21772186
getStateLabel());
21782187
}
21792188

2189+
private String buildETAInfo()
2190+
{
2191+
if(currentTarget == null || MC.player == null || targets.isEmpty())
2192+
return null;
2193+
2194+
if(commandForwardUnlimited)
2195+
return null;
2196+
2197+
double speed = MC.player.getDeltaMovement().length() * 20.0;
2198+
if(speed < 0.01)
2199+
return null;
2200+
2201+
// Sum remaining distance: current target + all subsequent targets
2202+
double totalDist = 0;
2203+
Vec3 lastPos = MC.player.position();
2204+
2205+
for(int i = currentIndex; i < targets.size(); i++)
2206+
{
2207+
AutoFlyTarget t = targets.get(i);
2208+
Vec3 targetPos = Vec3.atCenterOf(t.pos);
2209+
totalDist += lastPos.distanceTo(targetPos);
2210+
lastPos = targetPos;
2211+
}
2212+
2213+
double etaSeconds = totalDist / speed;
2214+
2215+
if(etaSeconds < 60)
2216+
return String.format(Locale.ROOT, "ETA %.0fs", etaSeconds);
2217+
2218+
if(etaSeconds < 3600)
2219+
{
2220+
int minutes = (int)(etaSeconds / 60);
2221+
int seconds = (int)(etaSeconds % 60);
2222+
return String.format(Locale.ROOT, "ETA %dm %ds", minutes, seconds);
2223+
}
2224+
2225+
int hours = (int)(etaSeconds / 3600);
2226+
int minutes = (int)((etaSeconds % 3600) / 60);
2227+
return String.format(Locale.ROOT, "ETA %dh %dm", hours, minutes);
2228+
}
2229+
21802230
private String getStateLabel()
21812231
{
21822232
if(pathFinder != null)

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

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
import java.io.IOException;
1414
import java.nio.charset.StandardCharsets;
1515
import java.util.ArrayList;
16+
import java.util.HashSet;
1617
import java.util.List;
1718
import java.util.Optional;
1819
import java.util.PrimitiveIterator;
1920
import java.util.Random;
21+
import java.util.Set;
2022

2123
import net.minecraft.core.component.DataComponents;
2224
import net.minecraft.network.chat.Component;
@@ -102,7 +104,9 @@ private enum RandomType
102104

103105
private int delayTimer;
104106
private int bookCount;
107+
private int inventoryCooldown;
105108
private Random random;
109+
private final Set<Integer> unsignedWrittenSlots = new HashSet<>();
106110

107111
public BookBotHack()
108112
{
@@ -137,7 +141,9 @@ protected void onEnable()
137141

138142
random = new Random();
139143
delayTimer = delay.getValueI();
144+
inventoryCooldown = 0;
140145
bookCount = 0;
146+
unsignedWrittenSlots.clear();
141147

142148
EVENTS.add(UpdateListener.class, this);
143149
}
@@ -146,12 +152,19 @@ protected void onEnable()
146152
protected void onDisable()
147153
{
148154
EVENTS.remove(UpdateListener.class, this);
155+
unsignedWrittenSlots.clear();
149156
}
150157

151158
@Override
152159
public void onUpdate()
153160
{
154161
// Find an empty writable book in inventory
162+
if(inventoryCooldown > 0)
163+
{
164+
inventoryCooldown--;
165+
return;
166+
}
167+
155168
int slot = findWritableBookSlot();
156169
if(slot == -1)
157170
{
@@ -241,7 +254,7 @@ private int findWritableBookSlot()
241254
for(int i = 0; i < MC.player.getInventory().getContainerSize(); i++)
242255
{
243256
ItemStack s = MC.player.getInventory().getItem(i);
244-
if(s.is(Items.WRITABLE_BOOK))
257+
if(s.is(Items.WRITABLE_BOOK) && !unsignedWrittenSlots.contains(i))
245258
{
246259
// Accept any writable book; server will accept updates
247260
return i;
@@ -260,7 +273,18 @@ private void moveToMainHand(int slot)
260273
if(slot < 9)
261274
MC.player.getInventory().setSelectedSlot(slot);
262275
else
263-
InventoryUtils.selectItem(slot);
276+
swapWithMainHand(slot);
277+
}
278+
279+
private void swapWithMainHand(int slot)
280+
{
281+
if(slot < 0 || slot == MC.player.getInventory().getSelectedSlot())
282+
return;
283+
284+
IMC.getInteractionManager().windowClick_SWAP(
285+
InventoryUtils.toNetworkSlot(slot),
286+
MC.player.getInventory().getSelectedSlot());
287+
inventoryCooldown = 2;
264288
}
265289

266290
private List<String> randomPages(PrimitiveIterator.OfInt chars)
@@ -398,6 +422,20 @@ private void writeBook(List<String> pages)
398422
MC.player.getInventory().getSelectedSlot(), pages,
399423
sign.isChecked() ? Optional.of(title) : Optional.empty()));
400424

425+
if(!sign.isChecked())
426+
{
427+
int selectedSlot = MC.player.getInventory().getSelectedSlot();
428+
unsignedWrittenSlots.add(selectedSlot);
429+
430+
int nextSlot = findWritableBookSlot();
431+
if(nextSlot != -1)
432+
{
433+
swapWithMainHand(nextSlot);
434+
unsignedWrittenSlots.add(nextSlot);
435+
unsignedWrittenSlots.remove(selectedSlot);
436+
}
437+
}
438+
401439
bookCount++;
402440
}
403441

0 commit comments

Comments
 (0)