Git Product home page Git Product logo

mcprotocollib's Introduction

MCProtocolLib

MCProtocolLib is a simple library for communicating with Minecraft clients and servers. It allows developers to build custom bots, clients, or servers for Minecraft with ease.

Example Code

See the example folder for sample usage.

Adding as a Dependency

MCProtocolLib builds are published to the Open Collaboration repository. Follow the below steps to add MCProtocolLib as a dependency to your project.

Maven

Add the Repository

<repositories>
    <repository>
        <id>opencollab</id>
        <url>https://repo.opencollab.dev/maven-releases/</url>
    </repository>
</repositories>

Add the Dependency

<dependency>
    <groupId>org.geysermc.mcprotocollib</groupId>
    <artifactId>protocol</artifactId>
    <version>(version here)</version>
</dependency>

Gradle (Groovy DSL)

Add the Repository

repositories {
    maven { 
        name 'opencollab'
        url 'https://repo.opencollab.dev/maven-releases/'
    }
}

Add the Dependency

dependencies {
    implementation 'org.geysermc.mcprotocollib:protocol:(version here)'
}

Gradle (Kotlin DSL)

Add the Repository

repositories {
    maven("https://repo.opencollab.dev/maven-releases/") {
        name = "opencollab"
    }
}

Add the Dependency

dependencies {
    implementation("org.geysermc.mcprotocollib:protocol:(version here)")
}

Snapshots

To use snapshot builds, switch the URL to https://repo.opencollab.dev/maven-snapshots/.

Javadocs

You can find the Javadocs for MCProtocolLib on opencollab.

Building the Source

MCProtocolLib uses Gradle to manage dependencies. To build the source code, run ./gradlew clean build in the project root directory.

Support and Development

Please join the GeyserMC Discord server and visit the #mcprotocollib channel for discussion and support for this project.

License

MCProtocolLib is licensed under the MIT license.

mcprotocollib's People

Contributors

aj-ferguson avatar alexprogrammerde avatar basaigh avatar camotoy avatar cxzlw avatar damatrix avatar davchoo avatar heath123 avatar ipbeegle avatar johni0702 avatar kas-tle avatar konicai avatar mattecarra avatar mcmdev avatar mikroskeem avatar onebeastchris avatar paulomart avatar phase avatar redned235 avatar rtm516 avatar sgdc3 avatar suprememortal avatar teksusik avatar tim203 avatar tycrek avatar vademon avatar vaigarashi avatar valaphee avatar winplay02 avatar yawkat 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  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

mcprotocollib's Issues

How do you even start to set this up?

Sorry for being a noob but I don't even know where to start within eclipse. When I import the project all the scripts give errors, and when I try to run test.java within eclipse it doesn't appear to be working either. Am I doing something wrong? How would I make this work? Thanks in advance.

ReadTimeout

I noticed that my bot stopped working because of an uncaught exception. Here's the message i got:

Apr 04, 2014 10:23:33 AM io.netty.channel.ChannelHandlerInvokerUtil invokeExceptionCaughtNow
WARNING: An exception was thrown by a user handler's exceptionCaught() method while handling the following exception:
io.netty.handler.timeout.ReadTimeoutException

Protocol Error

Using your maven repository and using build "1.7.4-SNAPSHOT" of the Library, I can't get my clients to connect to my server. I think it's a protocol error because of the strack trace:

03:33:04 WARN: io.netty.handler.codec.DecoderException: java.lang.ArrayIndexOutOfBoundsException: 23
03:33:04 WARN: at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:258)
03:33:04 WARN: at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:140)
03:33:04 WARN: at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:108)
03:33:04 WARN: at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:74)
03:33:04 WARN: at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:138)
03:33:04 WARN: at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:317)
03:33:04 WARN: at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:154)
03:33:04 WARN: at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:108)
03:33:04 WARN: at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:74)
03:33:04 WARN: at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:138)
03:33:04 WARN: at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:317)
03:33:04 WARN: at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:154)
03:33:04 WARN: at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:108)
03:33:04 WARN: at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:74)
03:33:04 WARN: at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:138)
03:33:04 WARN: at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:317)
03:33:04 WARN: at io.netty.handler.timeout.ReadTimeoutHandler.channelRead(ReadTimeoutHandler.java:148)
03:33:04 WARN: at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:74)
03:33:04 WARN: at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:138)
03:33:04 WARN: at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:317)
03:33:04 WARN: at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
03:33:04 WARN: at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:123)
03:33:04 WARN: at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:485)
03:33:04 WARN: at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:452)
[03:33:04 INFO]: (Client Name Here) lost connection: Disconnected
03:33:04 WARN: at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:346)
03:33:04 WARN: at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:794)
03:33:04 WARN: at java.lang.Thread.run(Thread.java:722)
03:33:04 WARN: Caused by: java.lang.ArrayIndexOutOfBoundsException: 23
03:33:04 WARN: at ch.spacebase.mc.protocol.packet.ingame.server.entity.ServerEntityEffectPacket.read(ServerEntityEffectPacket.java:46)
03:33:04 WARN: at ch.spacebase.packetlib.tcp.TcpPacketCodec.decode(TcpPacketCodec.java:36)
03:33:04 WARN: at io.netty.handler.codec.ByteToMessageCodec$1.decode(ByteToMessageCodec.java:42)
03:33:04 WARN: at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:227)

26 more

The netty exception is generated by the reading of the ServerEntityEffectPacket.

Can you please take a look? Thanks!

IGNORE THIS

Copied your example, but when executed just this stacktrace gets printed:

Exception in thread "main" java.net.BindException: Cannot assign requested address: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:104)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:464)
at io.netty.channel.DefaultChannelPipeline$HeadHandler.bind(DefaultChannelPipeline.java:1032)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeBindNow(ChannelHandlerInvokerUtil.java:99)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeBind(DefaultChannelHandlerInvoker.java:196)
at io.netty.channel.DefaultChannelHandlerContext.bind(DefaultChannelHandlerContext.java:363)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:898)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:189)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:294)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:318)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:794)
at java.lang.Thread.run(Unknown Source)

Help?
Greetings okaay.

Need a way to tell clients to unload chunks.

I need to tell the client to unload chunks. According to http://wiki.vg/Protocol#Chunk_Data I need to set "Ground-Up Continuous" to true and have no chunks present in a Chunk Data packet. However...when I try to do this I get the following exception:

java.lang.IllegalArgumentException: Chunks must contain all 16 chunks in a column if biomeData is not null. at ch.spacebase.mc.protocol.packet.ingame.server.world.ServerChunkDataPacket.(ServerChunkDataPacket.java:54)

How should I tell the client to unload chunks?

From http://wiki.vg/Protocol#Chunk_Data

Chunk Data

Chunks are not unloaded by the client automatically. To unload chunks, send this packet with ground-up continuous=true and no 16^3 chunks (eg. primary bit mask=0). The server does not send skylight information for nether-chunks, it's up to the client to know if the player is currently in the nether. You can also infer this information from the primary bitmask and the amount of uncompressed bytes sent.

NoClassDefFoundError

C:\Users\Jamie\Desktop>java -jar lotto.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/spacehq/packetlib
/SessionFactory
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.spacehq.packetlib.SessionFactor
y
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more

Used the exact base example code, changing the relative things.
I built the jar and attached it to eclipse's project.

Maven gives the same error.

Throwing nosuchmethod error

I am writing own minecraft server and currently writing unit tests for my protocol implementation. The best way to be sure that all is fine use external library. Here my unit test:

    public void testPing() {
        MinecraftProtocol protocol = new MinecraftProtocol(ProtocolMode.STATUS);
        Client client = new Client("localhost", 25565, protocol, new TcpSessionFactory());
        client.getSession().setFlag(
                ProtocolConstants.SERVER_INFO_HANDLER_KEY, (ServerInfoHandler) (session, info) -> {
            assertEquals("Test", info.getDescription().getFullText());
            assertEquals("1.7.4", info.getVersionInfo().getVersionName());
            assertEquals(5, info.getVersionInfo().getProtocolVersion());
            assertEquals(2, info.getPlayerInfo().getOnlinePlayers());
            assertEquals(10, info.getPlayerInfo().getMaxPlayers());
        });

        client.getSession().connect();
    }

Exception:

java.lang.NoSuchMethodError: io.netty.bootstrap.Bootstrap.channel(Ljava/lang/Class;)Lio/netty/bootstrap/Bootstrap;
    at org.spacehq.packetlib.tcp.TcpSessionFactory.createClientSession(TcpSessionFactory.java:37)
    at org.spacehq.packetlib.Client.<init>(Client.java:19)
    at ru.ensemplix.server.ping.TestPing.testPing(TestPing.java:44)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74)

Library was added to my project by your maven repository. Would be very thankful for fixing this problem.

How do you use this?

Sorry if I am being a complete noob, but How do you use the library. I have seen and ran the example but it still does not make sense? What would be a good way to start up the server and how would it be done so It can receive packets from a real client

ServerCombatPacket

https://github.com/Steveice10/MCProtocolLib/blob/1.8/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerCombatPacket.java#L58

the eventType or state should be a varint according to the wiki. i assume you read a byte because a bigger type hasnt been observed?

eventType = in.readVarInt();

    if (eventType == 1) {
        duration = in.readVarInt();
        entityId = in.readInt();
    } else if (eventType == 2) {
        playerId = in.readVarInt();
        entityId = in.readInt();
        message = in.readString();
    }

NetUtil.java

I would have made a pull request but i'm not on my home computer

in the readEntityMetadata(NetInput in) Method change :

int typeId = b >> 5;
to
int typeId = (b & 0xE0) >> 5;

It was doing this wierd thing where the typeId would come out as -4 which made type == null.

MessageStyle StackOverflow

Just got new snapshot and chat test failed.

Caused by: java.lang.StackOverflowError
    at org.spacehq.mc.protocol.data.message.MessageStyle.<init>(MessageStyle.java:13)
    at org.spacehq.mc.protocol.data.message.MessageStyle.<init>(MessageStyle.java:13)
    at org.spacehq.mc.protocol.data.message.MessageStyle.<init>(MessageStyle.java:13)
    at org.spacehq.mc.protocol.data.message.MessageStyle.<init>(MessageStyle.java:13)

NetUtil.dataToChunks not setting ParsedChunkData fields

In NetUtil.dataToChunks it doesn't look like the ParsedChunkData is getting it's fields set properly. This may just be me but all of the blocks in ServerChunkDataPacket and ServerMultiChunkDataPacket are 0 which is causing me a real brainache. It'd be awesome if you could check this out, thanks!

ServerPlayerListDataPacket writing header two times.

File and line: https://github.com/Steveice10/MCProtocolLib/blob/snapshot/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListDataPacket.java#L40

Function write:

@Override
    public void write(NetOutput out) throws IOException {
        out.writeString(this.header.toJsonString());
        out.writeString(this.header.toJsonString());
    }

should be

@Override
    public void write(NetOutput out) throws IOException {
        out.writeString(this.header.toJsonString());
        out.writeString(this.footer.toJsonString());
    }

According to http://wiki.vg/Protocol#Player_List_Header.2FFooter.

registering packets?

Hey, I wanted to make a little project with this but ran into a problem. I tried googling but didnt find anything.

Alright so I want to make a client connect to a server and then chat some message. I've used code from the example but it's throwing the exception:

Disconnected: Internal network exception: io.netty.handler.codec.EncoderException: java.lang.IllegalArgumentException: Unregistered outgoing packet class: org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket

I already tried the PacketProtocol register methods but no luck there yet.

Thanks!

1.6.4 Support

Hi. Is there any possibility of adding 1.6.4 support? I want to update a Bukkit plugin which adds fake connections to servers for Plugin Messanging between servers, and I want to update it to 1.6.4. I tried changing the protocol number (I saw that there were no protocol changes) but there actually are some protocol changes, so, I can't update to 1.6.4. Could you do for me? Thanks!

Multi version support

Is there any chance of seeing multiple version support?
Given the amount of code per packet I don't see why it should be too hard to somehow add support for multiple versions. Maybe even use some kind of plugin system to have versions as modules.
It would be very useful for people trying to build bots and things that have support for multiple versions without having to checkout versions that had support but not the latest bug fixes.
Just a thought, Thanks,
Jonathan

Crash when lightning strikes

io.netty.handler.codec.DecoderException: java.lang.ArrayIndexOutOfBoundsExceptio
n: 1
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageD
ecoder.java:258)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessage
Decoder.java:140)
at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCo
dec.java:108)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(Chann
elHandlerInvokerUtil.java:74)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(Defau
ltChannelHandlerInvoker.java:138)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(Default
ChannelHandlerContext.java:317)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessage
Decoder.java:154)
at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCo
dec.java:108)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(Chann
elHandlerInvokerUtil.java:74)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(Defau
ltChannelHandlerInvoker.java:138)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(Default
ChannelHandlerContext.java:317)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessage
Decoder.java:154)
at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCo
dec.java:108)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(Chann
elHandlerInvokerUtil.java:74)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(Defau
ltChannelHandlerInvoker.java:138)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(Default
ChannelHandlerContext.java:317)
at io.netty.handler.timeout.ReadTimeoutHandler.channelRead(ReadTimeoutHa
ndler.java:148)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(Chann
elHandlerInvokerUtil.java:74)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(Defau
ltChannelHandlerInvoker.java:138)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(Default
ChannelHandlerContext.java:317)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChanne
lPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(Abstra
ctNioByteChannel.java:123)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.jav
a:485)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEve
ntLoop.java:452)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:346)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThread
EventExecutor.java:794)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at ch.spacebase.mc.protocol.packet.ingame.server.entity.spawn.ServerSpaw
nGlobalEntityPacket.read(ServerSpawnGlobalEntityPacket.java:51)
at ch.spacebase.packetlib.tcp.TcpPacketCodec.decode(TcpPacketCodec.java:
36)
at io.netty.handler.codec.ByteToMessageCodec$1.decode(ByteToMessageCodec
.java:42)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageD
ecoder.java:227)
... 26 more

McProtocolLib doesn't work

I have a very old build of McProtocolLib. It works fine. Now I found a new version of McProtocolLib is available, so I downloaded it. The package names have changed. After I ran it, I found that it doesn't work.

The old version of McProtocolLib is called mcprotocollib-1.7.4-SNAPSHOT and the package is started with ch.spacebase.
I downloaded new version of McProtocolLib(mcprotocollib-1.8-20141107.234636-19).
It doesn't work. I launched my application, no error, just nothing happened.
Here is my code. http://pastebin.com/HvaRt2Er
It only showed 'Test'. 'TEST' didn't show. I also tried to remove client.getSession().connect(); in getMotd(), it didn't work too :\

I tried to launch it with the old version of McProtocolLib(I had removed Session in ServerPingTimeHandler and ServerInfoHandler), it worked fine.

I also tried to use the latest McProtocolLib for Minecraft 1.7.4. It doesn't work too.

Do you have any idea why it doesn't work? I hope you can reply soon. Thanks.

Sorry for my bad English.

Proxy doesn't work

Proxies aren't working. I tried over 15, but none of them worked. I'm using MCProtocolLib 1.8.

My code:
Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("59.108.48.37", 8080));
Client client = new Client("localhost", 25565, protocol, new TcpSessionFactory(proxy));
client.connect();

The client does not connect and it throws no exception. I hope you can help me and thanks for this awesome library!

Examples

I know there is an chat bot example included, but I want to know how to make the player move and attack and place blocks and things like that.

Bug Cipher data failed.

Trying to run the Chatbot example wrapped in an Android application.
The library has been compiled using Maven on Debian 6 x86.
The Server is a vanilla 1.6.2 minecraft server running on debian.
Bukkit servers react with the same output.

Client Log:
18.36.56 Logging In.....

Server Log:

javax.crypto.BadPaddingException: Blocktype mismatch: 0
at sun.security.rsa.RSAPadding.unpadV15(RSAPadding.java:328)
at sun.security.rsa.RSAPadding.unpad(RSAPadding.java:272)
at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:356)
at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:382)
at javax.crypto.Cipher.doFinal(Cipher.java:1922)
at lf.a(SourceFile:119)
at lf.b(SourceFile:114)
at lf.a(SourceFile:106)
at fx.a(SourceFile:52)
at cn.i(SourceFile:254)
at cn.c(SourceFile:17)
at co.run(SourceFile:94)
Cipher data failed!
java.lang.IllegalArgumentException: Missing argument
at javax.crypto.spec.SecretKeySpec.(SecretKeySpec.java:93)
at lf.a(SourceFile:106)
at fx.a(SourceFile:52)
at cn.i(SourceFile:254)
at cn.c(SourceFile:17)
at co.run(SourceFile:94)
13-08-05 18:36:59 [INFO] Heisenberg [/91.106.224.195:56823] lost connection

Example throwing exception

When I try to run the example, it throws a Java.net.BindException

Cannot assign requested address: bind

The stack trace doesn't point to any lines of code inside of the actual source code, just java stuff.

More info:
Apr 04, 2014 7:18:01 PM io.netty.channel.DefaultChannelId defaultProcessId
WARNING: Failed to find the current process ID; using a random value: 8030

Unknown effect ID

shouldn't throw an exception, just log a warning.

Caused by: java.io.IOException: Unknown effect id: 1013
        at org.spacehq.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket.idToEffect(ServerPlayEffectPacket.java:145)
        at org.spacehq.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket.read(ServerPlayEffectPacket.java:61)
        at org.spacehq.packetlib.tcp.TcpPacketCodec.decode(TcpPacketCodec.java:36)
        at io.netty.handler.codec.ByteToMessageCodec$1.decode(ByteToMessageCodec.java:42)
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:227)
,,,

Proxy Not Working

Code:
Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("204.27.58.202", 9050));
I also tried with around 20 other SOCKS proxies, which work outside of Eclipse.
This is using the example code provided too.
Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(proxy));
client.getSession().connect();

I can connect with the proxy through to google using
new URL("http://www.google.com").openConnection(proxy);

And it connects, but I cannot connect to a server with it.
Exception in thread "main" java.net.SocketException: Connection timed out: connect

ClientPlayerPositionPacket

Hi,
I tried to move bot (client) myself, but i couldn't move it. Also i tried to clone entity move from ServerPlayerPositionPacket to move it but i couldn't do it either. How can i move client, can you give me an example? I'm using 1.7.4 version of this library.
Thanks.

Protocol Error

Once again, I think you might have a protocol error in the library.

[15:28:10 WARN]: io.netty.handler.codec.DecoderException: java.lang.NegativeArraySizeException
[15:28:10 WARN]: at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:258)
[15:28:10 WARN]: at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:140)
[15:28:10 WARN]: at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:108)
[15:28:10 WARN]: at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:74)
[15:28:10 WARN]: at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:138)
[15:28:10 WARN]: at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:317)
[15:28:10 WARN]: at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:154)
[15:28:10 WARN]: at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:108)
[15:28:10 WARN]: at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:74)
[15:28:10 WARN]: at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:138)
[15:28:10 WARN]: at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:317)
[15:28:10 WARN]: at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:154)
[15:28:10 WARN]: at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:108)
[15:28:10 WARN]: at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:74)
[15:28:10 WARN]: at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:138)
[15:28:10 WARN]: at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:317)
[15:28:10 WARN]: at io.netty.handler.timeout.ReadTimeoutHandler.channelRead(ReadTimeoutHandler.java:148)
[15:28:10 WARN]: at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:74)
[15:28:10 WARN]: at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:138)
[15:28:10 WARN]: at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:317)
[15:28:10 WARN]: at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
[15:28:10 WARN]: at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:123)
[15:28:10 WARN]: at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:485)
[15:28:10 WARN]: at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:452)
[15:28:10 WARN]: at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:346)
[15:28:10 WARN]: at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:794)
[15:28:10 WARN]: at java.lang.Thread.run(Thread.java:722)
[15:28:10 WARN]: Caused by: java.lang.NegativeArraySizeException
[15:28:10 WARN]: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.nio.channels.ClosedChannelException
[15:28:10 WARN]: at ch.spacebase.mc.protocol.packet.ingame.server.world.ServerMapDataPacket.read(ServerMapDataPacket.java:49)
[15:28:10 WARN]: at ch.spacebase.packetlib.tcp.TcpPacketCodec.decode(TcpPacketCodec.java:36)
[15:28:10 WARN]: at io.netty.handler.codec.ByteToMessageCodec$1.decode(ByteToMessageCodec.java:42)
[15:28:10 WARN]: at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:227)
[15:28:10 WARN]: ... 26 more
[15:28:10 WARN]: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.nio.channels.ClosedChannelException

Can you please take a look again? Sorry and thanks!

Having trouble finding some packets

http://wiki.vg/Protocol#Entity

This one in particular, it's the packet that gets sent every in-game tick when the user isn't moving. When this packet isn't sent, the bot won't pick any items up.

I thought it was maybe ServerEntityMovementPacket, but I can't send it, so I'm not sure if I had the right packet to begin with.

Disconnected: Internal network exception:
io.netty.handler.codec.EncoderException: java.lang.IllegalArgumentException: 
Unregistered outgoing packet class: 
ch.spacebase.mc.protocol.packet.ingame.server.entity.ServerEntityMovementPacket

Trying to run example script but getting error

i am getting the following error when trying to run the example script ( Just the chat/login example)

Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lio/netty/channel/DefaultChannelId;
09-17 15:11:47.314    5344-5344/myapp W/System.errFailed to establish connection.
09-17 15:11:47.314    5344-5344/myapp W/System.errio.netty.channel.ChannelException: Unable to create Channel from class class io.netty.channel.socket.nio.NioSocketChannel
09-17 15:11:47.314    5344-5344/myapp W/System.errat io.netty.bootstrap.Bootstrap$BootstrapChannelFactory.newChannel(Bootstrap.java:299)
09-17 15:11:47.314    5344-5344/myapp W/System.errat io.netty.bootstrap.Bootstrap.createChannel(Bootstrap.java:99)
09-17 15:11:47.314    5344-5344/myapp W/System.errat io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:251)
09-17 15:11:47.314    5344-5344/myapp W/System.errat io.netty.bootstrap.Bootstrap.doConnect(Bootstrap.java:181)
09-17 15:11:47.314    5344-5344/myapp W/System.errat io.netty.bootstrap.Bootstrap.connect(Bootstrap.java:137)
09-17 15:11:47.314    5344-5344/myapp W/System.errat org.spacehq.packetlib.tcp.TcpSession.connect(TcpSession.java:67)
09-17 15:11:47.314    5344-5344/myapp W/System.errat org.spacehq.packetlib.tcp.TcpSession.connect(TcpSession.java:51)
09-17 15:11:47.314    5344-5344/myapp W/System.errat myapp.MainActivity$PlaceholderFragment$1.onClick(MainActivity.java:245)
09-17 15:11:47.314    5344-5344/myapp W/System.errat android.view.View.performClick(View.java:4640)
09-17 15:11:47.314    5344-5344/myapp W/System.errat android.view.View$PerformClick.run(View.java:19421)
09-17 15:11:47.314    5344-5344/myapp W/System.errat android.os.Handler.handleCallback(Handler.java:733)
09-17 15:11:47.314    5344-5344/myapp W/System.errat android.os.Handler.dispatchMessage(Handler.java:95)
09-17 15:11:47.314    5344-5344/myapp W/System.errat android.os.Looper.loop(Looper.java:136)
09-17 15:11:47.314    5344-5344/myapp W/System.errat android.app.ActivityThread.main(ActivityThread.java:5579)
09-17 15:11:47.324    5344-5344/myapp W/System.errat java.lang.reflect.Method.invokeNative(Native Method)
09-17 15:11:47.324    5344-5344/myapp W/System.errat java.lang.reflect.Method.invoke(Method.java:515)
09-17 15:11:47.324    5344-5344/myapp W/System.errat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
09-17 15:11:47.324    5344-5344/myapp W/System.errat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
09-17 15:11:47.324    5344-5344/myapp W/System.errat dalvik.system.NativeStart.main(Native Method)
09-17 15:11:47.324    5344-5344/myapp W/System.errCaused by: java.lang.reflect.InvocationTargetException
09-17 15:11:47.324    5344-5344/myapp W/System.errat java.lang.reflect.Constructor.constructNative(Native Method)
09-17 15:11:47.324    5344-5344/myapp W/System.errat java.lang.reflect.Constructor.newInstance(Constructor.java:423)
09-17 15:11:47.324    5344-5344/myapp W/System.errat io.netty.bootstrap.Bootstrap$BootstrapChannelFactory.newChannel(Bootstrap.java:297)
09-17 15:11:47.324    5344-5344/myapp W/System.err﹕ ... 18 more
09-17 15:11:47.324    5344-5344/myapp W/System.errCaused by: java.lang.NoClassDefFoundError: java.lang.management.ManagementFactory
09-17 15:11:47.324    5344-5344/myapp W/System.errat io.netty.channel.DefaultChannelId.defaultProcessId(DefaultChannelId.java:231)
09-17 15:11:47.324    5344-5344/myapp W/System.errat io.netty.channel.DefaultChannelId.<clinit>(DefaultChannelId.java:99)
09-17 15:11:47.324    5344-5344/myapp W/System.errat io.netty.channel.AbstractChannel.<init>(AbstractChannel.java:51)
09-17 15:11:47.324    5344-5344/myapp W/System.errat io.netty.channel.nio.AbstractNioChannel.<init>(AbstractNioChannel.java:67)
09-17 15:11:47.324    5344-5344/myapp W/System.errat io.netty.channel.nio.AbstractNioByteChannel.<init>(AbstractNioByteChannel.java:48)
09-17 15:11:47.324    5344-5344/myapp W/System.errat io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:77)
09-17 15:11:47.324    5344-5344/myapp W/System.errat io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:67)
09-17 15:11:47.324    5344-5344/myapp W/System.errat io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:60)
09-17 15:11:47.324    5344-5344/myapp W/System.err﹕ ... 21 more

any solution for this? It's running on android

Proxy support

Proxy support would be a great addition to add. I was going to try to do so myself, but the way that the libraries are set it this seems quite difficult to do. Great work on the library. It has been working very well.

Player move don't work

Hi! When I try to send a packet:
ClientPlayerPositionRotationPacket(isGrounded, playerX, playerY - 1.62, playerY, playerZ, 90, 90)
I see nothing on my server(PlayerMoveEvent print). What is the problem?

No Class Def Found Error: /org/spacehq/packetlib/packet/PacketProtocol

Build Logs and Error

C:\Users\Jamie\Documents\GitHub\LotteryBot\LotteryBot>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building lotterybot 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ lotterybot ---
[INFO] Deleting C:\Users\Jamie\Documents\GitHub\LotteryBot\LotteryBot\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lotterybot


[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ lotterybot ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 2 source files to C:\Users\Jamie\Documents\GitHub\LotteryBot\Lo
tteryBot\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ lo
tterybot ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\Jamie\Documents\GitHub\Lotte
ryBot\LotteryBot\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ lottery
bot ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ lotterybot ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ lotterybot ---
[INFO] Building jar: C:\Users\Jamie\Documents\GitHub\LotteryBot\LotteryBot\targe
t\lotterybot-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ lotterybot ---
[INFO] Installing C:\Users\Jamie\Documents\GitHub\LotteryBot\LotteryBot\target\l
otterybot-1.0-SNAPSHOT.jar to C:\Users\Jamie.m2\repository\ca\jamiesinn\lottery
bot\1.0-SNAPSHOT\lotterybot-1.0-SNAPSHOT.jar
[INFO] Installing C:\Users\Jamie\Documents\GitHub\LotteryBot\LotteryBot\pom.xml
to C:\Users\Jamie.m2\repository\ca\jamiesinn\lotterybot\1.0-SNAPSHOT\lotterybot
-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.796 s
[INFO] Finished at: 2015-02-20T16:01:55-05:00
[INFO] Final Memory: 14M/154M
[INFO] ------------------------------------------------------------------------
C:\Users\Jamie\Documents\GitHub\LotteryBot\LotteryBot>cd target

C:\Users\Jamie\Documents\GitHub\LotteryBot\LotteryBot\target>java -jar lotterybo
t-1.0-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/spacehq/packetlib
/packet/PacketProtocol
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.spacehq.packetlib.packet.Packet
Protocol
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more

C:\Users\Jamie\Documents\GitHub\LotteryBot\LotteryBot\target>

Building with Maven, using the exact sample code from the example.

Pom File:


4.0.0

<groupId>ca.jamiesinn</groupId>
<artifactId>lotterybot</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
    <repository>
        <id>spacehq-repo</id>
        <url>http://repo.spacehq.org/</url>
    </repository>
</repositories>
<build>
    <plugins>
        <plugin>
            <!-- Build an executable JAR -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                        <mainClass>ca.jamiesinn.lotterybot.LotteryBot</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.spacehq</groupId>
        <artifactId>mcprotocollib</artifactId>
        <version>1.8-SNAPSHOT</version>
    </dependency>
</dependencies>

Can't connect to server.

http://pastebin.com/rJDAcqtM
The code above is just a modification of the example class. It should join the server and say a message, but it doesn't join the server. There are no errors it just says "Successfully authenticated user."

Thanks,
LuckyTheCat

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.