zhuowei/RaspberryJuice

Modded python library not Python 2 compatible

Closed this issue · 4 comments

I'm attempting to follow instructions to Code Minecraft with Python on macOS (https://gist.github.com/noahcoad/fc9d3984a5d4d61648269c0a9477c622), and that uses this library.

However, I'm getting stuck at the very last step, actually running the python. I get the following syntax error:

code/minecraft_py/py ▶ python2 rainbow.py
Traceback (most recent call last):
  File "rainbow.py", line 1, in <module>
    import mcpi.minecraft as minecraft
  File "/Users/stephennixon/code/minecraft_py/py/mcpi/minecraft.py", line 133
    results.append(ProjectileEvent.Hit(*map(int,info[0:4]),*info[4:]))
                                                           ^
SyntaxError: invalid syntax

mcpi/minecraft.py L126-L134

Just to cover my bases, I also tried Python 3, but go another error:

▶ python3 rainbow.py
Traceback (most recent call last):
  File "rainbow.py", line 7, in <module>
    mc = minecraft.Minecraft.create()
  File "/Users/stephennixon/code/minecraft_py/py/mcpi/minecraft.py", line 358, in create
    return Minecraft(Connection(address, port))
  File "/Users/stephennixon/code/minecraft_py/py/mcpi/connection.py", line 17, in __init__
    self.socket.connect((address, port))
ConnectionRefusedError: [Errno 61] Connection refused

I don't see anything obviously wrong with the syntax at this portion ... any idea what might be happening?

Sorry if this is the wrong place to leave a question; I'd just love to get this working. :) Free to close the issue if you feel it's irrelevant in this repo; otherwise, thanks for any pointers if you have them!

It looks like some recent changes made to the mcpi library for projectile hits aren't python2 compatible.

Can you try again using python3 the error suggests the Raspberry Juice wasn't running at the time. Or, there is something, like a local firewall, blocking python3 from talking to raspberry juice.

Changed title to reflect the error

Python 2 issue resolved with #91

Got it working!

python2 was failing with the same message (ConnectionRefusedError: [Errno 61] Connection refused), and I found that spigot.jar was failing to load:

[12:51:34 ERROR]: Could not load 'plugins/raspberryjuice-1.11.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
	at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:162) ~[spigot.jar:git-Spigot-f6a273b-a639ae4]
	at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot.jar:git-Spigot-f6a273b-a639ae4]
	at org.bukkit.craftbukkit.v1_13_R2.CraftServer.loadPlugins(CraftServer.java:320) [spigot.jar:git-Spigot-f6a273b-a639ae4]
	at net.minecraft.server.v1_13_R2.DedicatedServer.init(DedicatedServer.java:213) [spigot.jar:git-Spigot-f6a273b-a639ae4]
	at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:702) [spigot.jar:git-Spigot-f6a273b-a639ae4]
	at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.util.zip.ZipException: zip file is empty
	at java.util.zip.ZipFile$Source.zerror(ZipFile.java:1535) ~[?:?]
	at java.util.zip.ZipFile$Source.findEND(ZipFile.java:1349) ~[?:?]
	at java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1443) ~[?:?]
	at java.util.zip.ZipFile$Source.<init>(ZipFile.java:1274) ~[?:?]
	at java.util.zip.ZipFile$Source.get(ZipFile.java:1237) ~[?:?]
	at java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:727) ~[?:?]
	at java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:844) ~[?:?]
	at java.util.zip.ZipFile.<init>(ZipFile.java:247) ~[?:?]
	at java.util.zip.ZipFile.<init>(ZipFile.java:177) ~[?:?]
	at java.util.jar.JarFile.<init>(JarFile.java:346) ~[?:?]
	at java.util.jar.JarFile.<init>(JarFile.java:317) ~[?:?]
	at java.util.jar.JarFile.<init>(JarFile.java:283) ~[?:?]
	at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:150) ~[spigot.jar:git-Spigot-f6a273b-a639ae4]
	... 5 more

Embarrassingly, this was because I hadn't properly copied spigot/plugins/raspberryjuice-1.11.jar into its proper directory. Once I downloaded this file and manually placed it, things started working!

The python2 syntax error has also been solved, so I'll close this. Thanks so much for your help!