Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endless loop when trying to run any command #14

Open
marcin-zbijowski opened this issue Jan 1, 2017 · 10 comments
Open

Endless loop when trying to run any command #14

marcin-zbijowski opened this issue Jan 1, 2017 · 10 comments

Comments

@marcin-zbijowski
Copy link

Hi,

I bought a book for my kid "Learn to Program with Minecraft" and I'm following setup guide. I've installed everything and I'm checking if it works. Basically, everything looks installed but as far as I can tell, there is something wrong with the module API. I don't know Python and I'm stuck when I try to run anything more then Minecraft.create().

>>> mc.player.getPos()
Drained Data: <b''>
Last Message: <>
Drained Data: <b''>
Last Message: <>
Drained Data: <b''>
Last Message: <>

and that's it.

LOG:

Python 3.5.2 (default, Dec 17 2016, 06:22:37) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from mcpi.minecraft import Minecraft
>>> mc = Minecraft.create("localhost", 25565)
>>> mc
<mcpi.minecraft.Minecraft object at 0x100ba2208>
>>> mc.player
<mcpi.minecraft.CmdPlayer object at 0x100cf9198>
>>> mc.player.getPos
<bound method CmdPlayer.getPos of <mcpi.minecraft.CmdPlayer object at 0x100cf9198>>

Any help with that will be very much appreciated.

@thomasvoth
Copy link

I'm seeing a similar issue, did you ever get this resolved?

@eah123
Copy link

eah123 commented Nov 30, 2017

I am using the "Learn to Program with Minecraft" book, too. I am able to use the API on both Windows 10 and Mac OS X 10.13.1. I am on Python 3.6.1. I used the Minecraft setup tool located at: https://www.nostarch.com/programwithminecraft
I had to update the spigot.jar file using the instructions here: https://www.spigotmc.org/
so that my Minecraft and the server versions were the same (Minecraft 1.12.2). This is probably the cause of your error - different Minecraft client and server versions.

>>> from mcpi.minecraft import Minecraft
>>> mc = Minecraft.create()
>>> mc.player.getPos()
Vec3(10.0,63.0,12.0)
>>>

@aleksey-kutepov
Copy link

@marcin-zbijowski, here you use the port Minecraft is listening to
mc = Minecraft.create("localhost", 25565)
But you need to talk to the port RasperryJuice plugin server is listening to (just keep default)
mc = Minecraft.create()
More precisely, the defaults are:
mc = Minecraft.create(address = "localhost", port = 4711)

@docent-net
Copy link

docent-net commented Feb 4, 2018

Haha hi @marcin-zbijowski - it made my evening that I found you here and with the very same problem (we work together, actually sitting 3m from each other) :D

So today I had similiar issues you guys mentioned above. In my case the source of all this was actually that I wanted to install the Spigot server on Fedora (not Raspbian nor any other Debian - related distro). And there are no specific packages of Spigot for Fedora so you need to build it manually unfortunately.

I described the whole process here: https://maciej.lasyk.info/2018/Feb/04/minecraft-python-and-fedora/

Tl-dr:

First problem was already mentioned by @eah123 - I needed to build Spigot with exactly same version as my Minecraft client (the game I run on laptop). If this is not satisfied you will not be able to connect from your game to your server:

java -jar BuildTools.jar --rev 1.12.2

The second problem - after installing server you need to also build RaspberryJuice plugin for Bukkit that actually create socket API on TCP port :4711 that will be used by Python API helper. Otherwise Minecraft.create() will not be able to connect to it. So:

sudo dnf/yum install maven
git clone https://github.com/zhuowei/RaspberryJuice
mvn package

And now just copy jar file to Minecraft server plugins directory:

cp jars/raspberryjuice-1.11.jar /where/you/have/spigot/installed/plugins/

Restart your server and you're all good :)

@aboisvert
Copy link

Just in case somebody else stumbles here like I did... I had similar issue as described above ("Drained Data... Last Message") because I was connecting to the Minecraft server's main port instead of the RasperryJuice plugin server's port.

For me the root cause was because the RasperryJuice plugin didn't start correctly due to running on Java 1.7.x instead of 1.8.x. (I noticed the UnsupportedClassVersionError 52.0 in the logs) The only open port was the server main port at 25565. I initially discounted the RasperryJuice plugin issue, thinking "oh it's just a random plugin failing but the server itself starts up just fine and I can connect to it".

Anyway, thanks @aleksey-kutepov for your comment!

@aleksey-kutepov
Copy link

Ok. Now I think I'm ready to add PR "fixing" this. So my ideas is to:

  • add trottling for "Drained data" messages like 1,2,3,5,8,... seconds
  • add message like "Probably you are connecting to the wrong port, current port is {RaspberryJuice.current.port}"

coming soon)

@evgeni-nabokov
Copy link

The author of the book did not mention RasperryJuice. He just provided an outdated Spigot server with plugins. Shame on the author.

@eah123
Copy link

eah123 commented Nov 15, 2018

Stop using Spigot / Bukkit / Raspberry Juice.
Just use RaspberryJam Mod with Minecraft Forge 1.12. https://github.com/arpruss/raspberryjammod
You don't need to run a server.
I taught a 13-week class in Python with it.

@evgeni-nabokov
Copy link

evgeni-nabokov commented Nov 15, 2018

@eah123 The book deals with Spigot and Raspberry Juice. If you teach a class, then provide your lectures, please.

@evgeni-nabokov
Copy link

@aleksey-kutepov Is there any progress of developing the "fix"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants