GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - AJ-Ferguson/Protocol: A protocol library for Minecraft Bedrock Edition

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

136 Commits
136 Commits

Folders and files

NameName
Last commit message
Last commit date
bedrock
bedrock
 
 
common
common
 
 
.gitignore
.gitignore
 
 
Jenkinsfile
Jenkinsfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

Repository files navigation

Protocol

License Build Status Discord

Introduction

A protocol library for Minecraft that supports multiple versions. (Currently Bedrock Edition only)

Links

  • Jenkins
  • JavaDocs
  • Discord

Usage

Client

Creating a client
// This is the local address to bind to, not the remote one.
// If bound to 127.0.0.1 any incoming packets from outside your computer will not be received.
InetSocketAddress bindAddress = new InetSocketAddress("0.0.0.0", 12345);
BedrockClient client = new BedrockClient(bindAddress);

// Bind the port
client.bind().join();
Pinging a Remote Server

This can be done whilst the client is connected to a server however it cannot be to the connected server.

InetSocketAddress addressToPing = new InetSocketAddress("play.nukkitx.com", 19132);
client.ping(addressToPing).whenComplete((pong, throwable) -> {
    if (throwable != null) {
        // Error occurred or timeout
        return;
    }
    // Pong received.
}).join(); // Join if you do not want this to be handled asynchronously.
Connecting to a Remote Server

A BedrockClient can only have one session per instance. If you need more, create extra instances.

InetSocketAddress addressToConnect = new InetSocketAddress("play.nukkitx.com", 19132);
client.connect(addressToConnect).whenComplete((session, throwable) -> {
    if (throwable != null) {
        // Unable to establish connection
        return;
    }
    // Connection established
    // Make sure to set the packet codec version you wish to use before sending out packets
    session.setPacketCodec(Bedrock_v389.V389_CODEC);
    // Add disconnect handler
    session.addDisconnectHandler((reason) -> System.out.println("Disconnected"));
    // Remember to set a packet handler so you receive incoming packets
    session.setPacketHandler(new FooBarPacketHandler());
    // Now send packets...
}).join(); // Join if you do not want this to be handled asynchronously.

Server

Creating a Server
InetSocketAddress bindAddress = new InetSocketAddress("0.0.0.0", 19132);
BedrockServer server = new BedrockServer(bindAddress);

BedrockPong pong = new BedrockPong();
pong.setEdition("MCPE");
pong.setMotd("My Server");
pong.setPlayerCount(0);
pong.setMaximumPlayerCount(20);
pong.setGameType("Survival");
pong.setProtocolVersion(Bedrock_v389.V389_CODEC.getProtocolVersion());

server.setHandler(new BedrockServerEventHandler() {
    @Override
    public boolean onConnectionRequest(InetSocketAddress address) {
        return true; // Connection will be accepted
    }
    
    @Override
    public BedrockPong onQuery(InetSocketAddress address) {
        return pong;
    }
    
    @Override
    public void onSessionCreation(BedrockServerSession serverSession) {
        // Connection established
        // Add disconnect handler
        session.addDisconnectHandler((reason) -> System.out.println("Disconnected"));
        // Remember to set a packet handler so you receive incoming packets
        session.setPacketHandler(new FooBarPacketHandler());
        // By default, the server will use a compatible codec that will read any LoginPacket.
        // After receiving the LoginPacket, you need to set the correct packet codec for the client and continue. 
    }
});

// Start server up
server.bind().join();

Maven

Protocol Versions:
Dependency Minecraft Version
bedrock-v291 1.7.0
bedrock-v313 1.8.0
bedrock-v332 1.9.0
bedrock-v340 1.10.0
bedrock-v354 1.11.0
bedrock-v361 1.12.0
bedrock-v388 1.13.0
bedrock-v389 1.14.x
Repository:
    <repositories>
        <repository>
            <id>nukkitx-repo-release</id>
            <url>https://repo.nukkitx.com/maven-releases/</url>
        </repository>
        <repository>
            <id>nukkitx-repo-snapshot</id>
            <url>https://repo.nukkitx.com/maven-snapshots/</url>
        </repository>
    </repositories>
Dependencies:
    <dependencies>
        <dependency>
            <groupId>com.nukkitx.protocol</groupId>
            <artifactId>bedrock-v(VERSION)</artifactId>
            <version>2.4.5</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

Projects Using This Library

  • ProxyPass - Vanilla server man-in-the-middle proxy
  • DragonProxy - Allow Bedrock clients to join Java Edition servers
  • Geyser - A bridge between Bedrock and Java Edition
  • BedrockConnect - Allow Xbox/Switch Bedrock clients to add and join servers

If you would like to add your project here, please create a pull request.

About

A protocol library for Minecraft Bedrock Edition

git.io/ProtocolLib

Resources

Readme
LGPL-3.0 license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.