MCProtocolLib is a Minecraft protocol library written in the Java programming language. It can be used to create clients, servers, and to otherwise create and parse packets.
// Here is an example of an MCProtocolLib client
// version: 1.19.2

import com.github.steveice10.mc.protocol.MinecraftProtocol;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.SessionAdapter;
import com.github.steveice10.packetlib.packet.Packet;
import com.github.steveice10.packetlib.tcp.TcpClientSession;

import java.time.Instant;
import java.util.ArrayList;

public class Example {

public static void main (String args) {

Session client = new TcpClientSession("localhost", 25565, new MinecraftProtocol("Player"), null);

client.addListener(new SessionAdapter() {

@Override

public void packetReceived (Session session, Packet packet) {

if (packet instanceof ClientboundLoginPacket) {

session.send(new ServerboundChatPacket("Hello, world!", Instant.now().toEpochMilli(), 0, new byte0, false, new ArrayList<>(), null));

}

}

});

client.connect();

}
}
by chipmunk minecraft June 5, 2023
Get the mcprotocollib mug.