Skip to content

Commit

Permalink
1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
PureGero committed May 1, 2024
1 parent 971211f commit d341ede
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# minecraft-stress-test

Automate the stress testing of your 1.19.3 Minecraft server with bots.
Automate the stress testing of your 1.20.6 Minecraft server with bots.
This project will log offline-mode bots into the specified server which will
fly around and explore the world.

Expand Down
40 changes: 22 additions & 18 deletions src/main/java/com/github/puregero/minecraftstresstest/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import static java.lang.Thread.sleep;

public class Bot extends ChannelInboundHandlerAdapter {
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
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
private static final double CENTER_X = Double.parseDouble(System.getProperty("bot.x", "0"));
private static final double CENTER_Z = Double.parseDouble(System.getProperty("bot.z", "0"));
private static final boolean LOGS = Boolean.parseBoolean(System.getProperty("bot.logs", "true"));
Expand Down Expand Up @@ -131,16 +131,20 @@ private void loggedIn(ChannelHandlerContext ctx, UUID uuid, String username) {
//System.out.println("changing to config mode");

CompletableFuture.delayedExecutor(1000, TimeUnit.MILLISECONDS).execute(() -> {
// sendPacket(ctx, PacketIds.Serverbound.Play.CLIENT_INFORMATION, buffer -> {
// buffer.writeUtf("en_GB");
// buffer.writeByte(VIEW_DISTANCE);
// buffer.writeVarInt(0);
// buffer.writeBoolean(true);
// buffer.writeByte(0);
// buffer.writeVarInt(0);
// buffer.writeBoolean(false);
// buffer.writeBoolean(true);
// });
sendPacket(ctx, PacketIds.Serverbound.Configuration.CLIENT_INFORMATION, buffer -> {
buffer.writeUtf("en_GB");
buffer.writeByte(VIEW_DISTANCE);
buffer.writeVarInt(0);
buffer.writeBoolean(true);
buffer.writeByte(0);
buffer.writeVarInt(0);
buffer.writeBoolean(false);
buffer.writeBoolean(true);
});

sendPacket(ctx, PacketIds.Serverbound.Configuration.KNOWN_PACKS, buffer -> {
buffer.writeVarInt(0);
});

CompletableFuture.delayedExecutor(1000, TimeUnit.MILLISECONDS).execute(() -> tick(ctx));
});
Expand Down Expand Up @@ -202,27 +206,27 @@ private void tick(ChannelHandlerContext ctx) {
private void channelReadConfig(ChannelHandlerContext ctx, FriendlyByteBuf byteBuf) {
int packetId = byteBuf.readVarInt();

if (packetId == 1) {
if (packetId == PacketIds.Clientbound.Configuration.DISCONNECT) {
System.out.println(username + " (" + uuid + ") (config) was kicked due to " + byteBuf.readUtf());
ctx.close();

} else if (packetId == 2) {
} else if (packetId == PacketIds.Clientbound.Configuration.FINISH_CONFIGURATION) {
//System.out.println("changing to play mode");

sendPacket(ctx, 2, buffer -> {
sendPacket(ctx, PacketIds.Serverbound.Configuration.FINISH_CONFIGURATION, buffer -> {
});

configState = false;
playState = true;

} else if (packetId == 3) {
} else if (packetId == PacketIds.Clientbound.Configuration.KEEP_ALIVE) {
long id = byteBuf.readLong();
sendPacket(ctx, 3, buffer -> buffer.writeLong(id));
sendPacket(ctx, PacketIds.Serverbound.Configuration.KEEP_ALIVE, buffer -> buffer.writeLong(id));
System.out.println(username + " (" + uuid + ") keep alive config mode");

} else if (packetId == 4) {
} else if (packetId == PacketIds.Clientbound.Configuration.PING) {
int id = byteBuf.readInt();
sendPacket(ctx, 4, buffer -> buffer.writeInt(id));
sendPacket(ctx, PacketIds.Serverbound.Configuration.PONG, buffer -> buffer.writeInt(id));
System.out.println(username + " (" + uuid + ") ping config mode");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,29 @@ private Login() {
SET_COMPRESSION = 0x03;
}

public static final class Configuration {
private Configuration() {
}

public static final int
DISCONNECT = 0x02,
FINISH_CONFIGURATION = 0x03,
KEEP_ALIVE = 0x04,
PING = 0x05;
}

public static final class Play {
private Play() {
}

//client outbound
public static final int
DISCONNECT = 0x1B, //ok +1
KEEP_ALIVE = 0x24, //ok +1
PING = 0x33, //ok +1
SYNCHRONIZE_PLAYER_POSITION = 0x3E, //ok +2
RESOURCE_PACK = 0x43, //ok +3
SET_HEALTH = 0x5B; //ok
DISCONNECT = 0x1D,
KEEP_ALIVE = 0x26,
PING = 0x35,
SYNCHRONIZE_PLAYER_POSITION = 0x40,
RESOURCE_PACK = 0x46,
SET_HEALTH = 0x5D;
}

}
Expand All @@ -52,22 +63,32 @@ private Login() {

public static final int
LOGIN_START = 0x00,
LOGIN_ACKNOWLEDGED = 0x03;
LOGIN_ACKNOWLEDGED = 0x03;
}

public static final class Configuration {
private Configuration() {
}

public static final int
CLIENT_INFORMATION = 0x00,
FINISH_CONFIGURATION = 0x03,
KEEP_ALIVE = 0x04,
PONG = 0x05,
KNOWN_PACKS = 0x07;
}

public static final class Play {
private Play() {
}

//server outbound
public static final int
CONFIRM_TELEPORTATION = 0x00, //same
CLIENT_RESPAWN = 0x08, //....
CLIENT_INFORMATION = 0x00, //ok
KEEP_ALIVE = 0x15, //ok
SET_PLAYER_POSITION_AND_ROTATION = 0x18, //ok
PONG = 0x24, //ok
RESOURCE_PACK = 0x28; //ok
CONFIRM_TELEPORTATION = 0x00,
CLIENT_RESPAWN = 0x08,
KEEP_ALIVE = 0x18,
SET_PLAYER_POSITION_AND_ROTATION = 0x1B,
PONG = 0x27,
RESOURCE_PACK = 0x2B;
}

}
Expand Down

0 comments on commit d341ede

Please sign in to comment.