Coder Social home page Coder Social logo

minecraft-server's Introduction

minecraft-server's People

Contributors

sxtanna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minecraft-server's Issues

PacketI Implementation

Implementation of server bound packets.

Handshake

  • 0x00: Handshake
  • 0xFE: Legacy Server List Ping

Status

  • 0x00: Request
  • 0x01: Ping

Login

  • 0x00: Login Start
  • 0x01: Encryption Response
  • 0x02: Login Plugin Response

Play

  • 0x00: Teleport Confirm
  • 0x01: Query Block NBT
  • 0x02: Set Difficulty
  • 0x03: Chat Message
  • 0x04: Client Status
  • 0x05: Client Settings
  • 0x06: Tab Complete
  • 0x07: Window Confirmation
  • 0x08: Click Window Button
  • 0x09: Click Window
  • 0x0A: Close Window
  • 0x0B: Plugin Message
  • 0x0C: Edit Book
  • 0x0D: Entity NBT Request
  • 0x0E: Interact Entity
  • 0x0F: Keep Alive
  • 0x10: Lock Difficulty
  • 0x11: Player Position
  • 0x12: Player Position And Rotation
  • 0x13: Player Rotation
  • 0x14: Player Movement
  • 0x15: Vehicle Move
  • 0x16: Steer Boat
  • 0x17: Pick Item
  • 0x18: Craft Recipe Request
  • 0x19: Player Abilities
  • 0x1A: Player Digging
  • 0x1B: Entity Action
  • 0x1C: Steer Vehicle
  • 0x1D: Recipe Book Data
  • 0x1E: Name Item
  • 0x1F: Resource Pack Status
  • 0x20: Advancement Tab
  • 0x21: Select Trade
  • 0x22: Set Beacon Effect
  • 0x23: Held Item Change
  • 0x24: Update Command Block
  • 0x25: Update Command Block Minecart
  • 0x26: Creative Inventory Action
  • 0x27: Update Jigsaw Block
  • 0x28: Update Structure Block
  • 0x29: Update Sign
  • 0x2A: Animation
  • 0x2B: Spectate
  • 0x2C: Player Block Placement
  • 0x2D: Use Item

Doesn’t work

So in the terminal I see, that the server receives packets eg when I ping or try to join, but the client doesn’t receive anything.So ping/status doesn’t work and also jointing doesn’t work or is it beacuse I’m using the 1.8.9(Client Version)?But still if so I’m not getting an error for the ring version, or isn’t that implemented?Im sorry, I did not have so much time till now to actually read the code etc.

Correct name for function iDontKnowWhatThisDoes()

This function returns a number with at least the same magnitude (positive or negative) as var0, but which is also divisible by var1. An appropriate name might be findNextLargestNumberEvenlyDivisibleBy or similar.
It appears that the only place where this is used, it is being used to figure out how many 64-bit chunks are required to store some data. So for example, if you have 92 bits of data to store, it will return 128 (which the caller then divides by 64 to get 2).

Play the game!

Steps to actually being in the game. (from wiki.vg)

  • C→S: Handshake
  • C→S: Login Start
  • S→C: Encryption Request
  • C→S: Encryption Response
  • S→C: Set Compression (optional)
  • S→C: Login Success
  • S→C: Join Game
  • S→C: Plugin Message: minecraft:brand with the server's brand (optional)
  • S→C: Server Difficulty (optional)
  • S→C: Player Abilities (optional)
  • C→S: Plugin Message: minecraft:brand with the client's brand (optional)
  • C→S: Client Settings
  • S→C: Held Item Change
  • S→C: Declare Recipes
  • S→C: Tags
  • S→C: Entity Status
  • S→C: Declare Commands
  • S→C: Unlock Recipes
  • S→C: Player Position And Look
  • S→C: Player Info
  • S→C: Player Info
  • S→C: Update View Position
  • S→C: Update Light
  • S→C: Chunk Data
  • S→C: World Border
  • S→C: Spawn Position
  • S→C: Player Position And Look
  • C→S: Teleport Confirm
  • C→S: Player Position And Look
  • C→S: Client Status
  • S→C: inventory, entities, etc

Crashes when connecting with MCProtocolLib

https://github.com/Steveice10/MCProtocolLib/blob/1.15.2-1/example/com/github/steveice10/mc/protocol/test/MinecraftProtocolTest.java

panic: runtime error: index out of range [64] with length 64

goroutine 19 [running]:
github.com/golangmc/minecraft-server/impl/conn/crypto.(*cfb8).XORKeyStream(0xc0001428c0, 0xc001ba0000, 0x1d19f, 0x1d19f, 0xc001b82000, 0x1d19f, 0x1e000)
        /home/jack/Dev/minecraft-server/impl/conn/crypto/cfb8.go:66 +0x249
github.com/golangmc/minecraft-server/impl/conn.(*connection).Encrypt(...)
        /home/jack/Dev/minecraft-server/impl/conn/connect.go:64
github.com/golangmc/minecraft-server/impl/conn.(*connection).SendPacket(0xc000296150, 0x7bf040, 0xc000396010)
        /home/jack/Dev/minecraft-server/impl/conn/connect.go:172 +0x248
github.com/golangmc/minecraft-server/impl/game/mode.HandleState3.func5(0xc00010e1e0, 0xc000162400)
        /home/jack/Dev/minecraft-server/impl/game/mode/mode_state3.go:154 +0xeb
created by github.com/golangmc/minecraft-server/impl/game/mode.HandleState3
        /home/jack/Dev/minecraft-server/impl/game/mode/mode_state3.go:80 +0x20e

import com.github.steveice10.mc.auth.exception.request.RequestException;
import com.github.steveice10.mc.protocol.MinecraftConstants;
import com.github.steveice10.mc.protocol.MinecraftProtocol;
import com.github.steveice10.mc.protocol.data.SubProtocol;
import com.github.steveice10.mc.protocol.data.message.Message;
import com.github.steveice10.mc.protocol.data.message.TranslationMessage;
import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo;
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoHandler;
import com.github.steveice10.mc.protocol.data.status.handler.ServerPingTimeHandler;
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerChunkDataPacket;
import com.github.steveice10.packetlib.Client;
import com.github.steveice10.packetlib.ProxyInfo;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import com.github.steveice10.packetlib.event.session.PacketReceivedEvent;
import com.github.steveice10.packetlib.event.session.SessionAdapter;
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;

import java.net.Proxy;
import java.util.Arrays;

public class TestClient {
    private static final boolean SPAWN_SERVER = false;
    private static final boolean VERIFY_USERS = true;
    private static final String HOST = "127.0.0.1";
    private static final int PORT = 25565;
    private static final ProxyInfo PROXY = null;
    private static final Proxy AUTH_PROXY = Proxy.NO_PROXY;
    private static final String USERNAME = "********";
    private static final String PASSWORD = "********";

    public static void main(String[] args) {
        status();
        login();
    }

    private static void status() {
        MinecraftProtocol protocol = new MinecraftProtocol(SubProtocol.STATUS);
        Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(PROXY));
        client.getSession().setFlag(MinecraftConstants.AUTH_PROXY_KEY, AUTH_PROXY);
        client.getSession().setFlag(MinecraftConstants.SERVER_INFO_HANDLER_KEY, new ServerInfoHandler() {
            @Override
            public void handle(Session session, ServerStatusInfo info) {
                System.out.println("Version: " + info.getVersionInfo().getVersionName() + ", " + info.getVersionInfo().getProtocolVersion());
                System.out.println("Player Count: " + info.getPlayerInfo().getOnlinePlayers() + " / " + info.getPlayerInfo().getMaxPlayers());
                System.out.println("Players: " + Arrays.toString(info.getPlayerInfo().getPlayers()));
                System.out.println("Description: " + info.getDescription().getFullText());
                System.out.println("Icon: " + info.getIconPng());
            }
        });

        client.getSession().setFlag(MinecraftConstants.SERVER_PING_TIME_HANDLER_KEY, new ServerPingTimeHandler() {
            @Override
            public void handle(Session session, long pingTime) {
                System.out.println("Server ping took " + pingTime + "ms");
            }
        });

        client.getSession().connect();
        while(client.getSession().isConnected()) {
            try {
                Thread.sleep(5);
            } catch(InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    private static void login() {
        MinecraftProtocol protocol = null;
        if(VERIFY_USERS) {
            try {
                protocol = new MinecraftProtocol(USERNAME, PASSWORD);
                System.out.println("Successfully authenticated user.");
            } catch(RequestException e) {
                e.printStackTrace();
                return;
            }
        } else {
            protocol = new MinecraftProtocol(USERNAME);
        }

        Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(PROXY));
        client.getSession().setFlag(MinecraftConstants.AUTH_PROXY_KEY, AUTH_PROXY);
        client.getSession().addListener(new SessionAdapter() {
            @Override
            public void packetReceived(PacketReceivedEvent event) {
                if(event.getPacket() instanceof ServerJoinGamePacket) {
                    event.getSession().send(new ClientChatPacket("Hello, this is a test of MCProtocolLib."));
                } else if(event.getPacket() instanceof ServerChatPacket) {
                    Message message = event.<ServerChatPacket>getPacket().getMessage();
                    System.out.println("Received Message: " + message.getFullText());
                    if(message instanceof TranslationMessage) {
                        System.out.println("Received Translation Components: " + Arrays.toString(((TranslationMessage) message).getTranslationParams()));
                    }
//                    event.getSession().disconnect("Finished");
                } 
                else if (event.getPacket() instanceof ServerChunkDataPacket) {
// This increases probability of crashing
                    ServerChunkDataPacket data = event.getPacket();
                    System.out.println("Received message: " + data);
                }
            }

            @Override
            public void disconnected(DisconnectedEvent event) {
                System.out.println("Disconnected: " + Message.fromString(event.getReason()).getFullText());
                if(event.getCause() != null) {
                    event.getCause().printStackTrace();
                }
            }
        });

        client.getSession().connect();
    }
}

PacketO Implementation

Implementation of client bound packets.

Handshake

no client bound packets for this state

Status

  • 0x00: Response
  • 0x01: Pong

Login

  • 0x00: Disconnect
  • 0x01: Encryption Request
  • 0x02: Login Success
  • 0x03: Set Compression
  • 0x04: Login Plugin Request

Play

  • 0x00: Spawn Object
  • 0x01: Spawn Experience Orb
  • 0x02: Spawn Global Entity
  • 0x03: Spawn Mob
  • 0x04: Spawn Painting
  • 0x05: Spawn Player
  • 0x06: Entity Animation
  • 0x07: Statistics
  • 0x08: Acknowledge Player Digging
  • 0x09: Block Break Animation
  • 0x0A: Update Block Entity
  • 0x0B: Block Action
  • 0x0C: Block Change
  • 0x0D: Boss Bar
  • 0x0E: Server Difficulty
  • 0x0F: Chat Message
  • 0x10: Multi Block Change
  • 0x11: Tab Complete
  • 0x12: Declare Commands
  • 0x13: Window Confirmation
  • 0x14: Close Window
  • 0x15: Window Items
  • 0x16: Window Property
  • 0x17: Set Slot
  • 0x18: Set Cooldown
  • 0x19: Plugin Message
  • 0x1A: Named Sound Effect
  • 0x1B: Disconnect
  • 0x1C: Entity Status
  • 0x1D: Explosion
  • 0x1E: Unload Chunk
  • 0x1F: Change Game State
  • 0x20: Open Horse Window
  • 0x21: Keep Alive
  • 0x22: Chunk Data
  • 0x23: Effect
  • 0x24: Particle
  • 0x25: Update Light
  • 0x26: Join Game
  • 0x27: Map Data
  • 0x28: Trade List
  • 0x29: Entity Position
  • 0x2A: Entity Position and Rotation
  • 0x2B: Entity Rotation
  • 0x2C: Entity Movement
  • 0x2D: Vehicle Move
  • 0x2E: Open Book
  • 0x2F: Open Window
  • 0x30: Open Sign Editor
  • 0x31: Craft Recipe Response
  • 0x32: Player Abilities
  • 0x33: Combat Event
  • 0x34: Player Info
  • 0x35: Face Player
  • 0x36: Player Position And Look
  • 0x37: Unlock Recipes
  • 0x38: Destroy Entities
  • 0x39: Remove Entity Effect
  • 0x3A: Resource Pack Send
  • 0x3B: Respawn
  • 0x3C: Entity Head Look
  • 0x3D: Select Advancement Tab
  • 0x3E: World Border
  • 0x3F: Camera
  • 0x40: Held Item Change
  • 0x41: Update View Position
  • 0x42: Update View Distance
  • 0x43: Display Scoreboard
  • 0x44: Entity Metadata
  • 0x45: Attach Entity
  • 0x46: Entity Velocity
  • 0x47: Entity Equipment
  • 0x48: Set Experience
  • 0x49: Update Health
  • 0x4A: Scoreboard Objective
  • 0x4B: Set Passengers
  • 0x4C: Teams
  • 0x4D: Update Score
  • 0x4E: Spawn Position
  • 0x4F: Time Update
  • 0x50: Title
  • 0x51: Entity Sound Effect
  • 0x52: Sound Effect
  • 0x53: Stop Sound
  • 0x54: Player List Header And Footer
  • 0x55: NBT Query Response
  • 0x56: Collect Item
  • 0x57: Entity Teleport
  • 0x58: Advancements
  • 0x59: Entity Properties
  • 0x5A: Entity Effect
  • 0x0B: Declare Recipes
  • 0x0C: Tags

Plugin support

(Suggestion, im not sure how to add the label)
Im not experienced with go at all, but I suggest getting a good plugin system from the start.
After a little googling I came across this , which might be good.

Join error string buffer maximum length

So when trying to join with a minecraft client(1.8.9) there’s just nothing happening.Propably because of the changes in the protocol since than.But with the versions 1.16.x and 1.20.1 I get following error: „internal exception: io.netty.handler.codec.DecoderException: The recived encoded string bugfer length is longer than maximum allowed (99 > 48)“.After looking trough the code for a bit I couldn’t find anything which could help.So I have two questions:

  1. Which version is this designed for?
  2. Is there a way to upgrade it to a few other versions which don’t have to much of an change?(Like the 1.16.x and/or 1.20.1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.