Skip to content

Commit fe40138

Browse files
committed
trying to fix anti afk
1 parent b2940fe commit fe40138

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/networking/anti_afk.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import threading
22
import time
33

4-
from src.networking.packets.serverbound import Animation
4+
from src.networking.packets.serverbound import Animation, ChatMessage, PlayerLook
5+
6+
from random import randint, uniform
57

68

79
class AntiAFKThread(threading.Thread):
@@ -19,5 +21,11 @@ def run(self):
1921
if self.connection.game_state.received_position \
2022
and not (self.connection.client_upstream and self.connection.client_upstream.connected()):
2123
print("Sent AntiAFK packet", flush=True)
22-
self.connection.send_packet(Animation(Hand=0))
24+
# Try spamming /help
25+
self.connection.send_packet(ChatMessage(Message="/help"))
26+
# Swing arm randomly
27+
self.connection.send_packet(Animation(Hand=randint(0, 1)))
28+
29+
# Look around
30+
self.connection.send_packet(PlayerLook(Yaw=uniform(0, 360), Pitch=uniform(0, 360), OnGround=True))
2331
time.sleep(self.rate)

src/networking/packets/serverbound/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,29 @@ class EncryptionResponse(Packet):
7070
}
7171

7272

73+
class ChatMessage(Packet):
74+
id = 0x02
75+
definition = {
76+
"Message": String
77+
}
78+
79+
7380
class ClientStatus(Packet):
7481
id = 0x03
7582
definition = {
7683
"ActionID": VarInt
7784
}
7885

7986

87+
class PlayerLook(Packet):
88+
id = 0x0F
89+
definition = {
90+
"Yaw": Float,
91+
"Pitch": Float,
92+
"OnGround": Boolean,
93+
}
94+
95+
8096
class KeepAlive(Packet):
8197
id = 0x0B
8298
definition = {

0 commit comments

Comments
 (0)