+1
-1
README.md
+1
-1
README.md
···
1
1
# minecraft-stress-test
2
2
3
-
Automate the stress testing of your 1.19.3 Minecraft server with bots.
3
+
Automate the stress testing of your 1.20.6 Minecraft server with bots.
4
4
This project will log offline-mode bots into the specified server which will
5
5
fly around and explore the world.
6
6
+22
-18
src/main/java/com/github/puregero/minecraftstresstest/Bot.java
+22
-18
src/main/java/com/github/puregero/minecraftstresstest/Bot.java
···
15
15
import static java.lang.Thread.sleep;
16
16
17
17
public class Bot extends ChannelInboundHandlerAdapter {
18
-
private static final int PROTOCOL_VERSION = Integer.parseInt(System.getProperty("bot.protocol.version", "765")); // 761 is 1.19.3 https://wiki.vg/Protocol_version_numbers
18
+
private static final int PROTOCOL_VERSION = Integer.parseInt(System.getProperty("bot.protocol.version", "766")); // 761 is 1.19.3 https://wiki.vg/Protocol_version_numbers
19
19
private static final double CENTER_X = Double.parseDouble(System.getProperty("bot.x", "0"));
20
20
private static final double CENTER_Z = Double.parseDouble(System.getProperty("bot.z", "0"));
21
21
private static final boolean LOGS = Boolean.parseBoolean(System.getProperty("bot.logs", "true"));
···
131
131
//System.out.println("changing to config mode");
132
132
133
133
CompletableFuture.delayedExecutor(1000, TimeUnit.MILLISECONDS).execute(() -> {
134
-
// sendPacket(ctx, PacketIds.Serverbound.Play.CLIENT_INFORMATION, buffer -> {
135
-
// buffer.writeUtf("en_GB");
136
-
// buffer.writeByte(VIEW_DISTANCE);
137
-
// buffer.writeVarInt(0);
138
-
// buffer.writeBoolean(true);
139
-
// buffer.writeByte(0);
140
-
// buffer.writeVarInt(0);
141
-
// buffer.writeBoolean(false);
142
-
// buffer.writeBoolean(true);
143
-
// });
134
+
sendPacket(ctx, PacketIds.Serverbound.Configuration.CLIENT_INFORMATION, buffer -> {
135
+
buffer.writeUtf("en_GB");
136
+
buffer.writeByte(VIEW_DISTANCE);
137
+
buffer.writeVarInt(0);
138
+
buffer.writeBoolean(true);
139
+
buffer.writeByte(0);
140
+
buffer.writeVarInt(0);
141
+
buffer.writeBoolean(false);
142
+
buffer.writeBoolean(true);
143
+
});
144
+
145
+
sendPacket(ctx, PacketIds.Serverbound.Configuration.KNOWN_PACKS, buffer -> {
146
+
buffer.writeVarInt(0);
147
+
});
144
148
145
149
CompletableFuture.delayedExecutor(1000, TimeUnit.MILLISECONDS).execute(() -> tick(ctx));
146
150
});
···
202
206
private void channelReadConfig(ChannelHandlerContext ctx, FriendlyByteBuf byteBuf) {
203
207
int packetId = byteBuf.readVarInt();
204
208
205
-
if (packetId == 1) {
209
+
if (packetId == PacketIds.Clientbound.Configuration.DISCONNECT) {
206
210
System.out.println(username + " (" + uuid + ") (config) was kicked due to " + byteBuf.readUtf());
207
211
ctx.close();
208
212
209
-
} else if (packetId == 2) {
213
+
} else if (packetId == PacketIds.Clientbound.Configuration.FINISH_CONFIGURATION) {
210
214
//System.out.println("changing to play mode");
211
215
212
-
sendPacket(ctx, 2, buffer -> {
216
+
sendPacket(ctx, PacketIds.Serverbound.Configuration.FINISH_CONFIGURATION, buffer -> {
213
217
});
214
218
215
219
configState = false;
216
220
playState = true;
217
221
218
-
} else if (packetId == 3) {
222
+
} else if (packetId == PacketIds.Clientbound.Configuration.KEEP_ALIVE) {
219
223
long id = byteBuf.readLong();
220
-
sendPacket(ctx, 3, buffer -> buffer.writeLong(id));
224
+
sendPacket(ctx, PacketIds.Serverbound.Configuration.KEEP_ALIVE, buffer -> buffer.writeLong(id));
221
225
System.out.println(username + " (" + uuid + ") keep alive config mode");
222
226
223
-
} else if (packetId == 4) {
227
+
} else if (packetId == PacketIds.Clientbound.Configuration.PING) {
224
228
int id = byteBuf.readInt();
225
-
sendPacket(ctx, 4, buffer -> buffer.writeInt(id));
229
+
sendPacket(ctx, PacketIds.Serverbound.Configuration.PONG, buffer -> buffer.writeInt(id));
226
230
System.out.println(username + " (" + uuid + ") ping config mode");
227
231
228
232
}
+36
-15
src/main/java/com/github/puregero/minecraftstresstest/PacketIds.java
+36
-15
src/main/java/com/github/puregero/minecraftstresstest/PacketIds.java
···
18
18
SET_COMPRESSION = 0x03;
19
19
}
20
20
21
+
public static final class Configuration {
22
+
private Configuration() {
23
+
}
24
+
25
+
public static final int
26
+
DISCONNECT = 0x02,
27
+
FINISH_CONFIGURATION = 0x03,
28
+
KEEP_ALIVE = 0x04,
29
+
PING = 0x05;
30
+
}
31
+
21
32
public static final class Play {
22
33
private Play() {
23
34
}
24
35
25
36
//client outbound
26
37
public static final int
27
-
DISCONNECT = 0x1B, //ok +1
28
-
KEEP_ALIVE = 0x24, //ok +1
29
-
PING = 0x33, //ok +1
30
-
SYNCHRONIZE_PLAYER_POSITION = 0x3E, //ok +2
31
-
RESOURCE_PACK = 0x43, //ok +3
32
-
SET_HEALTH = 0x5B; //ok
38
+
DISCONNECT = 0x1D,
39
+
KEEP_ALIVE = 0x26,
40
+
PING = 0x35,
41
+
SYNCHRONIZE_PLAYER_POSITION = 0x40,
42
+
RESOURCE_PACK = 0x46,
43
+
SET_HEALTH = 0x5D;
33
44
}
34
45
35
46
}
···
52
63
53
64
public static final int
54
65
LOGIN_START = 0x00,
55
-
LOGIN_ACKNOWLEDGED = 0x03;
66
+
LOGIN_ACKNOWLEDGED = 0x03;
67
+
}
68
+
69
+
public static final class Configuration {
70
+
private Configuration() {
71
+
}
72
+
73
+
public static final int
74
+
CLIENT_INFORMATION = 0x00,
75
+
FINISH_CONFIGURATION = 0x03,
76
+
KEEP_ALIVE = 0x04,
77
+
PONG = 0x05,
78
+
KNOWN_PACKS = 0x07;
56
79
}
57
80
58
81
public static final class Play {
59
82
private Play() {
60
83
}
61
84
62
-
//server outbound
63
85
public static final int
64
-
CONFIRM_TELEPORTATION = 0x00, //same
65
-
CLIENT_RESPAWN = 0x08, //....
66
-
CLIENT_INFORMATION = 0x00, //ok
67
-
KEEP_ALIVE = 0x15, //ok
68
-
SET_PLAYER_POSITION_AND_ROTATION = 0x18, //ok
69
-
PONG = 0x24, //ok
70
-
RESOURCE_PACK = 0x28; //ok
86
+
CONFIRM_TELEPORTATION = 0x00,
87
+
CLIENT_RESPAWN = 0x08,
88
+
KEEP_ALIVE = 0x18,
89
+
SET_PLAYER_POSITION_AND_ROTATION = 0x1B,
90
+
PONG = 0x27,
91
+
RESOURCE_PACK = 0x2B;
71
92
}
72
93
73
94
}