DarkStorm652 / DarkBot

Minecraft thin client and automation framework
BSD 2-Clause "Simplified" License
124 stars 53 forks source link

Use MCProtocolLib for protocol #54

Closed Techcable closed 9 years ago

Techcable commented 9 years ago

I understand you have had some trouble implementing the minecraft protocol. I suggest you use MCProtocolLib to implement your new protocol provider.

DarkStorm652 commented 9 years ago

The issues are a little more complex and not really issues so much as challenges. MCProtocolLib is much more simplistic than my new implementation and doesn't support the features and flexibility I need. The work is almost done anyway, though I appreciate the suggestion!

Techcable commented 9 years ago

@DarkStorm652 Would you accept it as a backend implementation. Thats what i'm doing right now.

DarkStorm652 commented 9 years ago

Yes, that would be great! If you write it against the old protocol API, I'll gladly make a wrapper for it.

Techcable commented 9 years ago

@DarkStorm652 I've kinda-sorta implemented it against the new api. Any (non-event) interaction with the packet system has been abstracted to the protocol system, i had no idea how your PacketModel System worked.

    public String getVersionName();
    public Set<String> getVersionAliases();
    public boolean isConnected();
    public void disconnect(String reason);
    public void connect(String username, String password) throws AuthenticationException;
    public void connectInOfflineMode(String username);

EDIT 1: I've also mavenized the project. Feel free to undo this, although it would let my ci server build this automatically.

DarkStorm652 commented 9 years ago

@Techcable sorry about the lack of documentation; still fleshing out some parts and not everything fits together yet. The model stuff is meant as a way to turn a static description (in XML/other) of a protocol into a factory for new protocol instances based off of it. That will make up an implementation of the API. The actual API that will be visible from the bot is just everything referenced by Protocol. Only the stuff in there needs to be implemented, along with a ProtocolProvider to instantiate it.

Techcable commented 9 years ago

@DarkStorm652 I kinda understood that the xml thing defines the packet structure. I had 0 idea how the parsed packets are translated into events. I'm sorry if i messed up your implementation, but i was just trying to speed this up :wink: I don't expect any documentation before release, but because you haven't even implemented the new system, i had no idea how to implement it myself. Your system sounds kinda complicated :p

DarkStorm652 commented 9 years ago

@Techcable using the Protocol/State/Packet/Field interfaces are pretty straightforward. Your Protocol impl should have a set of states (play, login, etc.), with each state able to produce packets from a stream. Each packet has a set of fields, each of which is a value in the packet (wiki.vg/Protocol). I'm not sure how well MCProtocolLib lends itself to this structure, though. The packets themselves also have to be handled by the Protocol and translated into events. (You can look at the previous protocol system to see how this was handled.)

Techcable commented 9 years ago

@DarkStorm652 All that state stuff is handled in PacketLib. Although your current design seems very flexible, DarkBot is tied to that implementation, my new protocol interface removes that tie, and allows use of MCProtocolLib.