From e8b5c7c85ba4c21d0fa224c13f16325de92902b1 Mon Sep 17 00:00:00 2001 From: MegaTKC Date: Sat, 11 Sep 2021 17:50:47 -0700 Subject: [PATCH] Release 0.2 Update --- README.md | 19 ++- app.py | 53 ++++++ mcpisettings/AutoJump/autojump-disable.py | 5 + mcpisettings/AutoJump/autojump-enable.py | 5 + mcpisettings/AutoJump/gui.py | 34 ++++ mcpisettings/AutoJump/minecraft/__init__.py | 0 mcpisettings/AutoJump/minecraft/__init__.pyc | Bin 0 -> 132 bytes mcpisettings/AutoJump/minecraft/block.py | 89 ++++++++++ mcpisettings/AutoJump/minecraft/block.pyc | Bin 0 -> 3711 bytes mcpisettings/AutoJump/minecraft/connection.py | 50 ++++++ .../AutoJump/minecraft/connection.pyc | Bin 0 -> 2486 bytes mcpisettings/AutoJump/minecraft/event.py | 23 +++ mcpisettings/AutoJump/minecraft/event.pyc | Bin 0 -> 1321 bytes mcpisettings/AutoJump/minecraft/minecraft.py | 159 ++++++++++++++++++ mcpisettings/AutoJump/minecraft/minecraft.pyc | Bin 0 -> 9323 bytes mcpisettings/AutoJump/minecraft/util.py | 10 ++ mcpisettings/AutoJump/minecraft/util.pyc | Bin 0 -> 678 bytes mcpisettings/AutoJump/minecraft/vec3.py | 115 +++++++++++++ mcpisettings/AutoJump/minecraft/vec3.pyc | Bin 0 -> 5466 bytes mcpisettings/NameTags/gui.py | 34 ++++ mcpisettings/NameTags/minecraft/__init__.py | 0 mcpisettings/NameTags/minecraft/__init__.pyc | Bin 0 -> 132 bytes mcpisettings/NameTags/minecraft/block.py | 89 ++++++++++ mcpisettings/NameTags/minecraft/block.pyc | Bin 0 -> 3711 bytes mcpisettings/NameTags/minecraft/connection.py | 50 ++++++ .../NameTags/minecraft/connection.pyc | Bin 0 -> 2486 bytes mcpisettings/NameTags/minecraft/event.py | 23 +++ mcpisettings/NameTags/minecraft/event.pyc | Bin 0 -> 1321 bytes mcpisettings/NameTags/minecraft/minecraft.py | 159 ++++++++++++++++++ mcpisettings/NameTags/minecraft/minecraft.pyc | Bin 0 -> 9323 bytes mcpisettings/NameTags/minecraft/util.py | 10 ++ mcpisettings/NameTags/minecraft/util.pyc | Bin 0 -> 678 bytes mcpisettings/NameTags/minecraft/vec3.py | 115 +++++++++++++ mcpisettings/NameTags/minecraft/vec3.pyc | Bin 0 -> 5466 bytes mcpisettings/NameTags/nametag-disable.py | 5 + mcpisettings/NameTags/nametag-enable.py | 5 + minecraft/__init__.py | 0 minecraft/__init__.pyc | Bin 134 -> 132 bytes minecraft/block.py | 0 minecraft/block.pyc | Bin 3725 -> 3711 bytes minecraft/connection.py | 0 minecraft/connection.pyc | Bin 2502 -> 2486 bytes minecraft/event.py | 0 minecraft/event.pyc | Bin 1331 -> 1321 bytes minecraft/minecraft.py | 0 minecraft/minecraft.pyc | Bin 9399 -> 9323 bytes minecraft/util.py | 0 minecraft/util.pyc | Bin 684 -> 678 bytes minecraft/vec3.py | 0 minecraft/vec3.pyc | Bin 5518 -> 5466 bytes 50 files changed, 1047 insertions(+), 5 deletions(-) create mode 100644 app.py create mode 100644 mcpisettings/AutoJump/autojump-disable.py create mode 100644 mcpisettings/AutoJump/autojump-enable.py create mode 100644 mcpisettings/AutoJump/gui.py create mode 100644 mcpisettings/AutoJump/minecraft/__init__.py create mode 100644 mcpisettings/AutoJump/minecraft/__init__.pyc create mode 100644 mcpisettings/AutoJump/minecraft/block.py create mode 100644 mcpisettings/AutoJump/minecraft/block.pyc create mode 100644 mcpisettings/AutoJump/minecraft/connection.py create mode 100644 mcpisettings/AutoJump/minecraft/connection.pyc create mode 100644 mcpisettings/AutoJump/minecraft/event.py create mode 100644 mcpisettings/AutoJump/minecraft/event.pyc create mode 100644 mcpisettings/AutoJump/minecraft/minecraft.py create mode 100644 mcpisettings/AutoJump/minecraft/minecraft.pyc create mode 100644 mcpisettings/AutoJump/minecraft/util.py create mode 100644 mcpisettings/AutoJump/minecraft/util.pyc create mode 100644 mcpisettings/AutoJump/minecraft/vec3.py create mode 100644 mcpisettings/AutoJump/minecraft/vec3.pyc create mode 100644 mcpisettings/NameTags/gui.py create mode 100644 mcpisettings/NameTags/minecraft/__init__.py create mode 100644 mcpisettings/NameTags/minecraft/__init__.pyc create mode 100644 mcpisettings/NameTags/minecraft/block.py create mode 100644 mcpisettings/NameTags/minecraft/block.pyc create mode 100644 mcpisettings/NameTags/minecraft/connection.py create mode 100644 mcpisettings/NameTags/minecraft/connection.pyc create mode 100644 mcpisettings/NameTags/minecraft/event.py create mode 100644 mcpisettings/NameTags/minecraft/event.pyc create mode 100644 mcpisettings/NameTags/minecraft/minecraft.py create mode 100644 mcpisettings/NameTags/minecraft/minecraft.pyc create mode 100644 mcpisettings/NameTags/minecraft/util.py create mode 100644 mcpisettings/NameTags/minecraft/util.pyc create mode 100644 mcpisettings/NameTags/minecraft/vec3.py create mode 100644 mcpisettings/NameTags/minecraft/vec3.pyc create mode 100644 mcpisettings/NameTags/nametag-disable.py create mode 100644 mcpisettings/NameTags/nametag-enable.py mode change 100755 => 100644 minecraft/__init__.py mode change 100755 => 100644 minecraft/block.py mode change 100755 => 100644 minecraft/connection.py mode change 100755 => 100644 minecraft/event.py mode change 100755 => 100644 minecraft/minecraft.py mode change 100755 => 100644 minecraft/util.py mode change 100755 => 100644 minecraft/vec3.py diff --git a/README.md b/README.md index 8995b19..63ce336 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,24 @@ -# MCPI Hacks -by Nitro +# MCPI Hacks / MCPI Enhancer +by MegaTKC ## Requirements - Minecraft-PI / Minecraft-Pi-Reborn -- Python 3.6 +- Python 2.7 ## Usage -Download this repo from git clone or from zip. If downloaded repo from zip you must extract it. Now open the repo and run python filename.py. These hacks are in real clients such as WURST and Sigma. +Download this repo from git clone or from zip. If downloaded repo from zip you must extract it. Now open the repo and run python2 app.py. These hacks are in real clients such as WURST, Sigma and Zeroday. ### Known Issues and Bugs -Hacks such as scaffold are invisible to players, so users / mobs can walk through your client-side blocks. When in the sky with scaffold players will see you walking on invisible blocks or just floating in the air. You can run this in survival mode and creative mode in MCPI. +- Hacks such as scaffold are invisible to players, so users / mobs can walk through your client-side blocks. When in the sky with scaffold players will see you walking on invisible blocks or just floating in the air. You can run this in survival mode and creative mode in MCPI. +- To stop Scaffold or ChatSpammer, you need to go into the terminal and hit CTRL + C on your keyboard to remove the previously selected module. + +## Changelog (0.2) +- Added NameTags +- Renamed to MCPI Enhancer +- Added AutoJump +- Added GUI for Ease of use + ### Join my Minecraft-Pi Server! - nitro.pocket-server.net:19132 + diff --git a/app.py b/app.py new file mode 100644 index 0000000..70f0667 --- /dev/null +++ b/app.py @@ -0,0 +1,53 @@ +# MCPI Hacks GUI Panel / Requires Python 3 + +import Tkinter +import tkMessageBox +import os +import sys + +root = Tkinter.Tk() + +root.title("MCPI Enhancer") +root.geometry('350x200') + +# Hacks / Modules Start +def chatSpammer(): + print "chat-spammer.py running" + os.system('python2 chat-spammer.py') + +B = Tkinter.Button(root, text ="ChatSpammer", command = chatSpammer) + +B.pack() + +def scaffoldWalk(): + print "scaffold.py running" + os.system('python2 scaffold.py') + +B = Tkinter.Button(root, text ="Scaffold", command = scaffoldWalk) + +B.pack() + +def nametags(): + print "nametagsGui running" + os.system('python2 mcpisettings/NameTags/gui.py') + +B = Tkinter.Button(root, text ="NameTags", command = nametags) + +B.pack() + +def autojump(): + print "autojumpGui running" + os.system('python2 mcpisettings/AutoJump/gui.py') + +B = Tkinter.Button(root, text ="AutoJump", command = autojump) + +B.pack() + +def quit(): + print "Good Bye!" + root.destroy() + +B = Tkinter.Button(root, text ="Quit", command = quit) + +B.pack() +root.mainloop() diff --git a/mcpisettings/AutoJump/autojump-disable.py b/mcpisettings/AutoJump/autojump-disable.py new file mode 100644 index 0000000..a9626fd --- /dev/null +++ b/mcpisettings/AutoJump/autojump-disable.py @@ -0,0 +1,5 @@ +import minecraft.minecraft as minecraft + +mc = minecraft.Minecraft.create() + +mc.setting("autojump", False) \ No newline at end of file diff --git a/mcpisettings/AutoJump/autojump-enable.py b/mcpisettings/AutoJump/autojump-enable.py new file mode 100644 index 0000000..e56d96e --- /dev/null +++ b/mcpisettings/AutoJump/autojump-enable.py @@ -0,0 +1,5 @@ +import minecraft.minecraft as minecraft + +mc = minecraft.Minecraft.create() + +mc.setting("autojump", True) \ No newline at end of file diff --git a/mcpisettings/AutoJump/gui.py b/mcpisettings/AutoJump/gui.py new file mode 100644 index 0000000..a13bb20 --- /dev/null +++ b/mcpisettings/AutoJump/gui.py @@ -0,0 +1,34 @@ +import Tkinter +import tkMessageBox +import os +import sys + +root = Tkinter.Tk() + +root.title("AutoJump") +root.geometry('350x200') + +def enable(): + print "Enabled" + os.system('python2 mcpisettings/AutoJump/autojump-enable.py') + +B = Tkinter.Button(root, text ="Enable", command = enable) + +B.pack() + +def disable(): + print "Disabled" + os.system('python2 mcpisettings/AutoJump/autojump-disable.py') + +B = Tkinter.Button(root, text ="Disable", command = disable) + +B.pack() + +def quit(): + print "Quit AutoJump Gui" + root.destroy() + +B = Tkinter.Button(root, text ="Quit", command = quit) + +B.pack() +root.mainloop() diff --git a/mcpisettings/AutoJump/minecraft/__init__.py b/mcpisettings/AutoJump/minecraft/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mcpisettings/AutoJump/minecraft/__init__.pyc b/mcpisettings/AutoJump/minecraft/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..182a13713b891e41838a9d66f572489c306efe88 GIT binary patch literal 132 zcmZSn%*)l6@i!rv0SXv_v;zKR!M)FS8^*Uaz3CgafFD6hjQoQ9ocxmfg8Yj7k~~j-MSe}5Cohm+lWp<> zxk|Rl4!KIMksY#2u953xm)s!Njbzb?%iqXG%ZEg&+q<2&{XJO12=?H-h-^67YO)hI zO4y0A`98_!8!(aq?8=QnBN-$N8Oab~*hq#6BSsXLN3f0~($w9wv)A6tt!2-8gXdXE znsxT{yIk*f=Pak)wceywmUeS1-?jSF=dv`Xy-KEK8KWcb1p^0MV&UwR$OqH-U>HiE zM4;oiY|5pejF~w^C;6a!B<;Li#u7Zs((TO%6C+G1%TY)+BUIVi-AOCCXgjMkon>!! zvE6x_Rd)8HsW6necfaPNGF>U%)w#mE%gFF3!yGd^SQiII>G*^|E?(uWW)e)m^uAx1 zp|!1cwng_5-9q-ZvM;xYVkp(wd8ZWX0#kUwjh`FC6Ri-fyGL6$QodgNS%c?M#J(uhD_V(`k%xYU~YP9-(*T3INyXi0K zo~0A(yLLCR(5K&9IbWZTK2K7Qb=$SVyTR(^g6rS-bt0pQ5&Up zc9WmCaay!gvfEKALc>QGh;Ump200{h&=jQqxUpDJgqTf;44cE|#NgNfe)&GoxTMh` z8gV=;|t>cfyD5JawzL9hcfwy8b|L1FbYRXT*$Zg0S$Shk>bu1hoUespO)dL&uoSajVtd*5f(E(j)}qi^%2A0myX8iz z?uTo*ieeNaam#LbVPHq=IjZK{t9E}D>c)Z3CZPplJE-O80P(l#`t0FG=+{&jxjgZr zFzBB+q3!box56%O^&vKK4g-dOQH-hx*7*I?C0Kxj9ZDAIu3NvK>_ z(zE7PxsjMW)v|q`8I&jc%mi{EsaSV?0p_$f;;h?2j)rZn#EVfFHdQqW*8=9HKNQJ> z(CCb}aD!7uT%4lEX-vhwT~)PkMGD4y4o3OdYUDXfs<;U;w1O5RtA^oHyy*IM-qZ}^ zSQUYe%A~Lwdo@ptVjH%?$XR4`bx%@{evndmQLLC}OmP;aS$IY6YKB2kBy`07d0_x? zJCR*)Nqb1rU>T3A+fh@RtH$!wSE9gnT;++jyj7RU+8^u8&BadDwwu$50>qV+p8g`@{ySI_* zZXoxfpBqy2V)=t=_4bLxwd%zlLN78Y+fZ6Sid0k_ZK{^{mu$Me7)I^6xN67-W0vp) xB(YzqDVYMS$tK@^9}x+tTZ(>Vg6r!{{a|(rd$93 literal 0 HcmV?d00001 diff --git a/mcpisettings/AutoJump/minecraft/connection.py b/mcpisettings/AutoJump/minecraft/connection.py new file mode 100644 index 0000000..88f417b --- /dev/null +++ b/mcpisettings/AutoJump/minecraft/connection.py @@ -0,0 +1,50 @@ +import socket +import select +import sys +from util import flatten_parameters + +""" @author: Aron Nieminen, Mojang AB""" + +class RequestError(Exception): + pass + +class Connection: + """Connection to a Minecraft Pi game""" + RequestFailed = "Fail" + + def __init__(self, address, port): + self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.socket.connect((address, port)) + self.lastSent = "" + + def drain(self): + """Drains the socket of incoming data""" + while True: + readable, _, _ = select.select([self.socket], [], [], 0.0) + if not readable: + break + data = self.socket.recv(1500) + e = "Drained Data: <%s>\n"%data.strip() + e += "Last Message: <%s>\n"%self.lastSent.strip() + sys.stderr.write(e) + + def send(self, f, *data): + """Sends data. Note that a trailing newline '\n' is added here""" + s = "%s(%s)\n"%(f, flatten_parameters(data)) + #print "f,data:",f,data + #print "s",s + self.drain() + self.lastSent = s + self.socket.sendall(s) + + def receive(self): + """Receives data. Note that the trailing newline '\n' is trimmed""" + s = self.socket.makefile("r").readline().rstrip("\n") + if s == Connection.RequestFailed: + raise RequestError("%s failed"%self.lastSent.strip()) + return s + + def sendReceive(self, *data): + """Sends and receive data""" + self.send(*data) + return self.receive() diff --git a/mcpisettings/AutoJump/minecraft/connection.pyc b/mcpisettings/AutoJump/minecraft/connection.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f5d9bf16fe97486873436b73d2a641f3a2e69a2a GIT binary patch literal 2486 zcmb_eU2hvj6uq?HB1Y1Oid7yqoszO9aQ>bW6w2o9^AuY@9I9X@CPIo5# zkdhZt@dDx(@-KKsaL$bFAXU61*q-YS-b6Uo&rY?myLCOS7wPh$uTTsJ(nwTEJm|ug zZUAE$PLc}aB#CXi%4C|KmZ=izDcuV)0-5P&gyhz zd)c&tYl~@h|KwH7={berWKHE}*je;=Gs|ss^H~B~f(JN5$pgXy@PHj1VCAs$xG^$^ zZn(nbEpx_uFqczBb{eJ8-aO4{zlaVAUIV=zrA3*AaOP!)&u_t4k+HYR`GH&nat6eN z7ER+&&Xk-5GD4FAxu~ESnF`3`qWc&F2rhB7CXAV8$J$z^xcw-3+}}O0H{cJx+xa#b z9K^fZd#-H;qvNMcjUDL9cA1~c*ywWPx}|wuYhzsSWLn!x&aOh&Obta<*d)2dWSOz3 zyQ-ryQpr`YIDmeI^YS%usecixWbD>H4&+eDq3{PZE*kPfDCbJf1O5P(c_90h$1fm$ zAQ#A;!vU6|j2qk%o%4pA0YzAVyflw~jxbOhFUxp^?S%YUC{M9_23?2lM@Z^nofege z?2(Q<+R=0r6;(EcN)MwvwJCD*pW+WJ$GkItNaxW*G(U(o*UeVj#h(EDXb%{thk6$8 zcUySCVSZ4bYEP>!q57D#x`tY3&n=-cwk}R$Qfx_|d1ZWmo9nuEJzms>)lMKWx3MFk z)@h#pRBFHqIk^#;x2x)FlFY1fLi8^4S%ZQho8L+CP~Y(%LRB;3FIh# z57vQbt_dOs<|H5TpC_CIov^K1exDFOvb}?1_F;&U1BzP$TLlQBx)8rdwn3#I2U0(w z$hjTR$4MQXJ9zA8CEPi@7u@`t7&+FNE}rW*5vBb93sY!vGSRt1qBex4ZK&yW6OF)v z&Yi+NoLt-_J=P<{7uqC2PRF==sBflYS7BzC5RX)yyW`(8!!72{L&rw^0jnrizgpb! zhh4_SbEFvw_tY)*{v`<{!U^~e98Ut^`;BUKbO6|ayI4&J9lSKtDvxFZJDK{lNp!pp z^RHDT literal 0 HcmV?d00001 diff --git a/mcpisettings/AutoJump/minecraft/event.py b/mcpisettings/AutoJump/minecraft/event.py new file mode 100644 index 0000000..f884e0d --- /dev/null +++ b/mcpisettings/AutoJump/minecraft/event.py @@ -0,0 +1,23 @@ +from vec3 import Vec3 + +class BlockEvent: + """An Event related to blocks (e.g. placed, removed, hit)""" + HIT = 0 + + def __init__(self, type, x, y, z, face, entityId): + self.type = type + self.pos = Vec3(x, y, z) + self.face = face + self.entityId = entityId + + def __repr__(self): + sType = { + BlockEvent.HIT: "BlockEvent.HIT" + }.get(self.type, "???") + + return "BlockEvent(%s, %d, %d, %d, %d, %d)"%( + sType,self.pos.x,self.pos.y,self.pos.z,self.face,self.entityId); + + @staticmethod + def Hit(x, y, z, face, entityId): + return BlockEvent(BlockEvent.HIT, x, y, z, face, entityId) diff --git a/mcpisettings/AutoJump/minecraft/event.pyc b/mcpisettings/AutoJump/minecraft/event.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cb2c180a5801d9592cfdb73cdc57ca52c4713718 GIT binary patch literal 1321 zcmbtU&u zVO83W2d1v``uI)v;Yo_LJ7qDk*(@FSj%C%`(}j>4Q%nkP40Ae;f>cZG!ZN00Ze9@? z-ohzR6GfhAr08&j#NkP4E&}?7H7FoLjcPO!P1q4l*lEcAreKQ(5#8w}oX4rV1>Cem z`=op3Sfit(BX{r0QnKd`;yu*ss_iG-R9gCs58?t5`P_ODQ1hhbR5T~4TMQcsIZw^) z>ZOCuP^jz5I~w^C&eQ-qBaK0zyLHBVR9@`}7YbNtuH>m~=T$0_MQT_yaC KYarU(4*mcu#`GBg literal 0 HcmV?d00001 diff --git a/mcpisettings/AutoJump/minecraft/minecraft.py b/mcpisettings/AutoJump/minecraft/minecraft.py new file mode 100644 index 0000000..3cc3aa0 --- /dev/null +++ b/mcpisettings/AutoJump/minecraft/minecraft.py @@ -0,0 +1,159 @@ +from connection import Connection +from vec3 import Vec3 +from event import BlockEvent + +""" Minecraft PI low level api v0.1_0 + + Note: many methods have the parameter *arg. This solution makes it + simple to allow different types, and variable number of arguments. + The actual magic is a mix of flatten_parameters() and __iter__. Example: + A Cube class could implement __iter__ to work in Minecraft.setBlocks(c, id). + + (Because of this, it's possible to "erase" arguments. CmdPlayer removes + entityId, by injecting [] that flattens to nothing) + + @author: Aron Nieminen, Mojang AB""" + + +class CmdPositioner: + """Methods for setting and getting positions""" + def __init__(self, connection, packagePrefix): + self.conn = connection + self.pkg = packagePrefix + + def getPos(self, id): + """Get entity position (entityId:int) => Vec3""" + s = self.conn.sendReceive(self.pkg + ".getPos", id) + return Vec3(*map(float, s.split(","))) + + def setPos(self, id, *args): + """Set entity position (entityId:int, x,y,z)""" + self.conn.send(self.pkg + ".setPos", id, args) + + def getTilePos(self, id): + """Get entity tile position (entityId:int) => Vec3""" + s = self.conn.sendReceive(self.pkg + ".getTile", id) + return Vec3(*map(int, s.split(","))) + + def setTilePos(self, id, *args): + """Set entity tile position (entityId:int) => Vec3""" + self.conn.send(self.pkg + ".setTile", id, args) + + def setting(self, setting, status): + """Set a player setting (setting, status). keys: autojump""" + self.conn.send(self.pkg + ".setting", setting, 1 if bool(status) else 0) + + +class CmdEntity(CmdPositioner): + """Methods for entities""" + def __init__(self, connection): + CmdPositioner.__init__(self, connection, "entity") + + +class CmdPlayer(CmdPositioner): + """Methods for the host (Raspberry Pi) player""" + def __init__(self, connection): + CmdPositioner.__init__(self, connection, "player") + self.conn = connection + + def getPos(self): + return CmdPositioner.getPos(self, []) + def setPos(self, *args): + return CmdPositioner.setPos(self, [], args) + def getTilePos(self): + return CmdPositioner.getTilePos(self, []) + def setTilePos(self, *args): + return CmdPositioner.setTilePos(self, [], args) + +class CmdCamera: + def __init__(self, connection): + self.conn = connection + + def setNormal(self, *args): + """Set camera mode to normal Minecraft view ([entityId])""" + self.conn.send("camera.mode.setNormal", args) + + def setFixed(self): + """Set camera mode to fixed view""" + self.conn.send("camera.mode.setFixed") + + def setFollow(self, *args): + """Set camera mode to follow an entity ([entityId])""" + self.conn.send("camera.mode.setFollow", args) + + def setPos(self, *args): + """Set camera entity position (x,y,z)""" + self.conn.send("camera.setPos", args) + + +class CmdEvents: + """Events""" + def __init__(self, connection): + self.conn = connection + + def clearAll(self): + """Clear all old events""" + self.conn.send("events.clear") + + def pollBlockHits(self): + """Only triggered by sword => [BlockEvent]""" + s = self.conn.sendReceive("events.block.hits") + events = [e for e in s.split("|") if e] + return [BlockEvent.Hit(*map(int, e.split(","))) for e in events] + + +class Minecraft: + """The main class to interact with a running instance of Minecraft Pi.""" + def __init__(self, connection): + self.conn = connection + + self.camera = CmdCamera(connection) + self.entity = CmdEntity(connection) + self.player = CmdPlayer(connection) + self.events = CmdEvents(connection) + + def getBlock(self, *args): + """Get block (x,y,z) => id:int""" + return int(self.conn.sendReceive("world.getBlock", args)) + + def setBlock(self, *args): + """Set block (x,y,z,id,[data])""" + self.conn.send("world.setBlock", args) + + def setBlocks(self, *args): + """Set a cuboid of blocks (x0,y0,z0,x1,y1,z1,id,[data])""" + self.conn.send("world.setBlocks", args) + + def getHeight(self, *args): + """Get the height of the world (x,z) => int""" + return int(self.conn.sendReceive("world.getHeight", args)) + + def getPlayerEntityIds(self): + """Get the entity ids of the connected players => [id:int]""" + ids = self.conn.sendReceive("world.getPlayerIds") + return map(int, ids.split("|")) + + def saveCheckpoint(self): + """Save a checkpoint that can be used for restoring the world""" + self.conn.send("world.checkpoint.save") + + def restoreCheckpoint(self): + """Restore the world state to the checkpoint""" + self.conn.send("world.checkpoint.restore") + + def postToChat(self, msg): + """Post a message to the game chat""" + self.conn.send("chat.post", msg) + + def setting(self, setting, status): + """Set a world setting (setting, status). keys: world_immutable, nametags_visible""" + self.conn.send("world.setting", setting, 1 if bool(status) else 0) + + @staticmethod + def create(address = "localhost", port = 4711): + return Minecraft(Connection(address, port)) + + +if __name__ == "__main__": + mc = Minecraft.create() + mc.postToChat("Hello, Minecraft!") diff --git a/mcpisettings/AutoJump/minecraft/minecraft.pyc b/mcpisettings/AutoJump/minecraft/minecraft.pyc new file mode 100644 index 0000000000000000000000000000000000000000..168e62f2d30bcf914bd902a86e2fe44f3c1feba5 GIT binary patch literal 9323 zcmcgy-*Xg69q-vqLIQzs32^?n(*gBvW9=;E$hLg0WZiK&6I>OyhrWT&&4WOirW z?gWBRKEQ(ySC$Vx_-Faxf8w*HpU<~vXNK(ZYd0~Wo1UJY?(gqko$9|&9{=msfBw)? z*-sV!{|3$c3tfbNo=TMJcxv5K9-k{Jsi;m>tykT1RV7oZGp*LA@jRuXB^6Dp7fL-> z>Z|n`70oC;qc%Mi9m{8rsc3dEJD1PSs_3|i&Zy`_J~gMJc@>>i(aC%YOHQfioQf9m zsS`?L)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dnf9($78sX16pax_G>zg(4=J0~L)tT6$D={vy7(P585Y;))b46)rVs;nCcqJ2g3> z-lQrC*j4I*SvQb@onQmVbwFa1+_KJN!wtA`k)|f*q(E>Bew$6H`>AoYeQk~9GRa@L zirh=8nN1!Deb6IH9U2xnj0u3`z#hN~hec*W25K8#pWn2PE_M87!z{^7T?eh{T$ow0ifr|jmK2>MK*{4U4Y#{h;$sOL#H`ZA{rG* zj!L3TkKKtUxtUIyNV=~}op*3~CCk%TmpU`h&(;vN!iAI*E0R~Zkx>)Y|FkvKa)0S0 RD+bfloJwCSZ)|$C&0kTGh2Q`H literal 0 HcmV?d00001 diff --git a/mcpisettings/AutoJump/minecraft/vec3.py b/mcpisettings/AutoJump/minecraft/vec3.py new file mode 100644 index 0000000..ea701f3 --- /dev/null +++ b/mcpisettings/AutoJump/minecraft/vec3.py @@ -0,0 +1,115 @@ +class Vec3: + def __init__(self, x=0, y=0, z=0): + self.x = x + self.y = y + self.z = z + + def __add__(self, rhs): + c = self.clone() + c += rhs + return c + + def __iadd__(self, rhs): + self.x += rhs.x + self.y += rhs.y + self.z += rhs.z + return self + + def length(self): + return self.lengthSqr ** .5 + + def lengthSqr(self): + return self.x * self.x + self.y * self.y + self.z * self.z + + def __mul__(self, k): + c = self.clone() + c *= k + return c + + def __imul__(self, k): + self.x *= k + self.y *= k + self.z *= k + return self + + def clone(self): + return Vec3(self.x, self.y, self.z) + + def __neg__(self): + return Vec3(-self.x, -self.y, -self.z) + + def __sub__(self, rhs): + return self.__add__(-rhs) + + def __isub__(self, rhs): + return self.__iadd__(-rhs) + + def __repr__(self): + return "Vec3(%s,%s,%s)"%(self.x,self.y,self.z) + + def __iter__(self): + return iter((self.x, self.y, self.z)) + + def _map(self, func): + self.x = func(self.x) + self.y = func(self.y) + self.z = func(self.z) + + def __cmp__(self, rhs): + dx = self.x - rhs.x + if dx != 0: return dx + dy = self.y - rhs.y + if dy != 0: return dy + dz = self.z - rhs.z + if dz != 0: return dz + return 0 + + def iround(self): self._map(lambda v:int(v+0.5)) + def ifloor(self): self._map(int) + + def rotateLeft(self): self.x, self.z = self.z, -self.x + def rotateRight(self): self.x, self.z = -self.z, self.x + + @staticmethod + def y(n=1): return Vec3(0, n, 0) + @staticmethod + def up(n=1): return Vec3.y(n) + @staticmethod + def down(n=1): return Vec3.y(-n) + +def testVec3(): + # Note: It's not testing everything + + # 1.1 Test initialization + it = Vec3(1, -2, 3) + assert it.x == 1 + assert it.y == -2 + assert it.z == 3 + + assert it.x != -1 + assert it.y != +2 + assert it.z != -3 + + # 2.1 Test cloning and equality + clone = it.clone() + assert it == clone + it.x += 1 + assert it != clone + + # 3.1 Arithmetic + a = Vec3(10, -3, 4) + b = Vec3(-7, 1, 2) + c = a + b + assert c - a == b + assert c - b == a + assert a + a == a * 2 + + assert a - a == Vec3(0,0,0) + assert a + (-a) == Vec3(0,0,0) + + # Test repr + e = eval(repr(it)) + assert e == it + +if __name__ == "__main__": + testVec3() diff --git a/mcpisettings/AutoJump/minecraft/vec3.pyc b/mcpisettings/AutoJump/minecraft/vec3.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fb2ff0778a0da4437adec07d3595bde10f0b11fe GIT binary patch literal 5466 zcmcgw-EtH~6h1Sv8?yN!A=zXjq9O<^6q*uCDJ%+6{G*hJlPassO|$IGCPVfo&P))f za4#R6S+j6oFG6 z^jWBTpefl0N*^kHRHruecoMc-KHGgN_u0LUVo7oy-26(f6V9igjb#4TjoUZh{Jhaz zP3AjMH*Cg@Ryuzlv-Z~7!*m$EjfuKZY7Dg{oL6xw_%&Il^1_7Ur~v;x4U|oofPY6W zTP{aWU}+ho+3s~iHO5!yR28ozYE5%sz(=6Pm_`s7LpH-Z=8RapIp!N|dmjXNO8^X< zpqE|xo)UN-5`cG&&PnN>+5!rRPEKwQVL$I}j-p2S#4xZene)|{F(^tX5NAq%O*)dL zaQ`SO*8NyY(~EUBEG&cI?~e~Oc+v{^cGz7`R~EmERirovhRATR`li4o98#PD8hxXl zz5vETv$V>GIu^8AV@;h3TCMHnSq*E3%bT`|;1((|B?X0(r;a0I{^uCP_a9kF>SGI>Ps{L_`>OO*Y{2(UKe(V@(!z;9b0&ynv zS40M-25Mv}@SQ-Vz&C0GRUe*= zz7U96OmxF#W6t&=WxVD^J$V!Y;sbSn%_-ccUgE;n9pMo6B^#y5`dwpqn&iIA(G)9b zZ$u-9h$ss>g>PZn`Kj21TxoeSn{Am1aWieHpGhw2|9QL0)seK$o~c?r z$X=A4u5q{)8#BKb>}^qKgOJoC?7o>M7)=49G>o4=lnx6nbsKZ35AKeM*Ml|pGVlQ_ z4^}JDl!+2lt;D4blbm_*50Kd+y?Bys#y)wlOl=(ROoCq z0Cdit1c;(lPvVozau(UH=77#^B4~A);%E zGkF!nA|l0^;o@o22CP<{#6Ea@O_$>#z~j~*_tHihei^pXPpSF;AnKXx$P0tWG|@uz zqve(Kvm9eYmlU(huu)%5f7oh)%g@bTFKZp!a?E z))t()rkC6SjOjKyp)o0A&zMdxSZ|~1>#kaX%x8noYnEOSeB$;eNVvRxPO#54?DL}I zPm}N(;p?(}ncPW|*GW#1oCZnt+J-=nnw=2$?Z95i&#?V0$d==k+n@J!COPj3591+c zs$3~ohAJL@`IEe@S8!!_Sv(}-wlwjU&^Y=)qxd&yvr&w1F!=g{DBiStgrnz`E6F** zS@VMi7Sa!N!`GkWYM&4%n|=~XzU~v^^%9TEq}3tz|CbfZs-_lLCW&wawOJQms1 zQE`ZJ$X~Zwd0WSl%dhI}0G+>Q9cT|e6XBE5u-fCQh4@T_m!K9F;<(1y>`BcY%&5$v z#zCr1W-Lx@4^nIGg1yPXn*OSCYRvf;biIp% literal 0 HcmV?d00001 diff --git a/mcpisettings/NameTags/gui.py b/mcpisettings/NameTags/gui.py new file mode 100644 index 0000000..3af6087 --- /dev/null +++ b/mcpisettings/NameTags/gui.py @@ -0,0 +1,34 @@ +import Tkinter +import tkMessageBox +import os +import sys + +root = Tkinter.Tk() + +root.title("NameTags") +root.geometry('350x200') + +def enable(): + print "Enabled" + os.system('python2 mcpisettings/NameTags/nametag-enable.py') + +B = Tkinter.Button(root, text ="Enable", command = enable) + +B.pack() + +def disable(): + print "Disabled" + os.system('python2 mcpisettings/NameTags/nametag-disable.py') + +B = Tkinter.Button(root, text ="Disable", command = disable) + +B.pack() + +def quit(): + print "Quit NameTags Gui" + root.destroy() + +B = Tkinter.Button(root, text ="Quit", command = quit) + +B.pack() +root.mainloop() diff --git a/mcpisettings/NameTags/minecraft/__init__.py b/mcpisettings/NameTags/minecraft/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mcpisettings/NameTags/minecraft/__init__.pyc b/mcpisettings/NameTags/minecraft/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..182a13713b891e41838a9d66f572489c306efe88 GIT binary patch literal 132 zcmZSn%*)l6@i!rv0SXv_v;zKR!M)FS8^*Uaz3CgafFD6hjQoQ9ocxmfg8Yj7k~~j-MSe}5Cohm+lWp<> zxk|Rl4!KIMksY#2u953xm)s!Njbzb?%iqXG%ZEg&+q<2&{XJO12=?H-h-^67YO)hI zO4y0A`98_!8!(aq?8=QnBN-$N8Oab~*hq#6BSsXLN3f0~($w9wv)A6tt!2-8gXdXE znsxT{yIk*f=Pak)wceywmUeS1-?jSF=dv`Xy-KEK8KWcb1p^0MV&UwR$OqH-U>HiE zM4;oiY|5pejF~w^C;6a!B<;Li#u7Zs((TO%6C+G1%TY)+BUIVi-AOCCXgjMkon>!! zvE6x_Rd)8HsW6necfaPNGF>U%)w#mE%gFF3!yGd^SQiII>G*^|E?(uWW)e)m^uAx1 zp|!1cwng_5-9q-ZvM;xYVkp(wd8ZWX0#kUwjh`FC6Ri-fyGL6$QodgNS%c?M#J(uhD_V(`k%xYU~YP9-(*T3INyXi0K zo~0A(yLLCR(5K&9IbWZTK2K7Qb=$SVyTR(^g6rS-bt0pQ5&Up zc9WmCaay!gvfEKALc>QGh;Ump200{h&=jQqxUpDJgqTf;44cE|#NgNfe)&GoxTMh` z8gV=;|t>cfyD5JawzL9hcfwy8b|L1FbYRXT*$Zg0S$Shk>bu1hoUespO)dL&uoSajVtd*5f(E(j)}qi^%2A0myX8iz z?uTo*ieeNaam#LbVPHq=IjZK{t9E}D>c)Z3CZPplJE-O80P(l#`t0FG=+{&jxjgZr zFzBB+q3!box56%O^&vKK4g-dOQH-hx*7*I?C0Kxj9ZDAIu3NvK>_ z(zE7PxsjMW)v|q`8I&jc%mi{EsaSV?0p_$f;;h?2j)rZn#EVfFHdQqW*8=9HKNQJ> z(CCb}aD!7uT%4lEX-vhwT~)PkMGD4y4o3OdYUDXfs<;U;w1O5RtA^oHyy*IM-qZ}^ zSQUYe%A~Lwdo@ptVjH%?$XR4`bx%@{evndmQLLC}OmP;aS$IY6YKB2kBy`07d0_x? zJCR*)Nqb1rU>T3A+fh@RtH$!wSE9gnT;++jyj7RU+8^u8&BadDwwu$50>qV+p8g`@{ySI_* zZXoxfpBqy2V)=t=_4bLxwd%zlLN78Y+fZ6Sid0k_ZK{^{mu$Me7)I^6xN67-W0vp) xB(YzqDVYMS$tK@^9}x+tTZ(>Vg6r!{{a|(rd$93 literal 0 HcmV?d00001 diff --git a/mcpisettings/NameTags/minecraft/connection.py b/mcpisettings/NameTags/minecraft/connection.py new file mode 100644 index 0000000..88f417b --- /dev/null +++ b/mcpisettings/NameTags/minecraft/connection.py @@ -0,0 +1,50 @@ +import socket +import select +import sys +from util import flatten_parameters + +""" @author: Aron Nieminen, Mojang AB""" + +class RequestError(Exception): + pass + +class Connection: + """Connection to a Minecraft Pi game""" + RequestFailed = "Fail" + + def __init__(self, address, port): + self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.socket.connect((address, port)) + self.lastSent = "" + + def drain(self): + """Drains the socket of incoming data""" + while True: + readable, _, _ = select.select([self.socket], [], [], 0.0) + if not readable: + break + data = self.socket.recv(1500) + e = "Drained Data: <%s>\n"%data.strip() + e += "Last Message: <%s>\n"%self.lastSent.strip() + sys.stderr.write(e) + + def send(self, f, *data): + """Sends data. Note that a trailing newline '\n' is added here""" + s = "%s(%s)\n"%(f, flatten_parameters(data)) + #print "f,data:",f,data + #print "s",s + self.drain() + self.lastSent = s + self.socket.sendall(s) + + def receive(self): + """Receives data. Note that the trailing newline '\n' is trimmed""" + s = self.socket.makefile("r").readline().rstrip("\n") + if s == Connection.RequestFailed: + raise RequestError("%s failed"%self.lastSent.strip()) + return s + + def sendReceive(self, *data): + """Sends and receive data""" + self.send(*data) + return self.receive() diff --git a/mcpisettings/NameTags/minecraft/connection.pyc b/mcpisettings/NameTags/minecraft/connection.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f5d9bf16fe97486873436b73d2a641f3a2e69a2a GIT binary patch literal 2486 zcmb_eU2hvj6uq?HB1Y1Oid7yqoszO9aQ>bW6w2o9^AuY@9I9X@CPIo5# zkdhZt@dDx(@-KKsaL$bFAXU61*q-YS-b6Uo&rY?myLCOS7wPh$uTTsJ(nwTEJm|ug zZUAE$PLc}aB#CXi%4C|KmZ=izDcuV)0-5P&gyhz zd)c&tYl~@h|KwH7={berWKHE}*je;=Gs|ss^H~B~f(JN5$pgXy@PHj1VCAs$xG^$^ zZn(nbEpx_uFqczBb{eJ8-aO4{zlaVAUIV=zrA3*AaOP!)&u_t4k+HYR`GH&nat6eN z7ER+&&Xk-5GD4FAxu~ESnF`3`qWc&F2rhB7CXAV8$J$z^xcw-3+}}O0H{cJx+xa#b z9K^fZd#-H;qvNMcjUDL9cA1~c*ywWPx}|wuYhzsSWLn!x&aOh&Obta<*d)2dWSOz3 zyQ-ryQpr`YIDmeI^YS%usecixWbD>H4&+eDq3{PZE*kPfDCbJf1O5P(c_90h$1fm$ zAQ#A;!vU6|j2qk%o%4pA0YzAVyflw~jxbOhFUxp^?S%YUC{M9_23?2lM@Z^nofege z?2(Q<+R=0r6;(EcN)MwvwJCD*pW+WJ$GkItNaxW*G(U(o*UeVj#h(EDXb%{thk6$8 zcUySCVSZ4bYEP>!q57D#x`tY3&n=-cwk}R$Qfx_|d1ZWmo9nuEJzms>)lMKWx3MFk z)@h#pRBFHqIk^#;x2x)FlFY1fLi8^4S%ZQho8L+CP~Y(%LRB;3FIh# z57vQbt_dOs<|H5TpC_CIov^K1exDFOvb}?1_F;&U1BzP$TLlQBx)8rdwn3#I2U0(w z$hjTR$4MQXJ9zA8CEPi@7u@`t7&+FNE}rW*5vBb93sY!vGSRt1qBex4ZK&yW6OF)v z&Yi+NoLt-_J=P<{7uqC2PRF==sBflYS7BzC5RX)yyW`(8!!72{L&rw^0jnrizgpb! zhh4_SbEFvw_tY)*{v`<{!U^~e98Ut^`;BUKbO6|ayI4&J9lSKtDvxFZJDK{lNp!pp z^RHDT literal 0 HcmV?d00001 diff --git a/mcpisettings/NameTags/minecraft/event.py b/mcpisettings/NameTags/minecraft/event.py new file mode 100644 index 0000000..f884e0d --- /dev/null +++ b/mcpisettings/NameTags/minecraft/event.py @@ -0,0 +1,23 @@ +from vec3 import Vec3 + +class BlockEvent: + """An Event related to blocks (e.g. placed, removed, hit)""" + HIT = 0 + + def __init__(self, type, x, y, z, face, entityId): + self.type = type + self.pos = Vec3(x, y, z) + self.face = face + self.entityId = entityId + + def __repr__(self): + sType = { + BlockEvent.HIT: "BlockEvent.HIT" + }.get(self.type, "???") + + return "BlockEvent(%s, %d, %d, %d, %d, %d)"%( + sType,self.pos.x,self.pos.y,self.pos.z,self.face,self.entityId); + + @staticmethod + def Hit(x, y, z, face, entityId): + return BlockEvent(BlockEvent.HIT, x, y, z, face, entityId) diff --git a/mcpisettings/NameTags/minecraft/event.pyc b/mcpisettings/NameTags/minecraft/event.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cb2c180a5801d9592cfdb73cdc57ca52c4713718 GIT binary patch literal 1321 zcmbtU&u zVO83W2d1v``uI)v;Yo_LJ7qDk*(@FSj%C%`(}j>4Q%nkP40Ae;f>cZG!ZN00Ze9@? z-ohzR6GfhAr08&j#NkP4E&}?7H7FoLjcPO!P1q4l*lEcAreKQ(5#8w}oX4rV1>Cem z`=op3Sfit(BX{r0QnKd`;yu*ss_iG-R9gCs58?t5`P_ODQ1hhbR5T~4TMQcsIZw^) z>ZOCuP^jz5I~w^C&eQ-qBaK0zyLHBVR9@`}7YbNtuH>m~=T$0_MQT_yaC KYarU(4*mcu#`GBg literal 0 HcmV?d00001 diff --git a/mcpisettings/NameTags/minecraft/minecraft.py b/mcpisettings/NameTags/minecraft/minecraft.py new file mode 100644 index 0000000..3cc3aa0 --- /dev/null +++ b/mcpisettings/NameTags/minecraft/minecraft.py @@ -0,0 +1,159 @@ +from connection import Connection +from vec3 import Vec3 +from event import BlockEvent + +""" Minecraft PI low level api v0.1_0 + + Note: many methods have the parameter *arg. This solution makes it + simple to allow different types, and variable number of arguments. + The actual magic is a mix of flatten_parameters() and __iter__. Example: + A Cube class could implement __iter__ to work in Minecraft.setBlocks(c, id). + + (Because of this, it's possible to "erase" arguments. CmdPlayer removes + entityId, by injecting [] that flattens to nothing) + + @author: Aron Nieminen, Mojang AB""" + + +class CmdPositioner: + """Methods for setting and getting positions""" + def __init__(self, connection, packagePrefix): + self.conn = connection + self.pkg = packagePrefix + + def getPos(self, id): + """Get entity position (entityId:int) => Vec3""" + s = self.conn.sendReceive(self.pkg + ".getPos", id) + return Vec3(*map(float, s.split(","))) + + def setPos(self, id, *args): + """Set entity position (entityId:int, x,y,z)""" + self.conn.send(self.pkg + ".setPos", id, args) + + def getTilePos(self, id): + """Get entity tile position (entityId:int) => Vec3""" + s = self.conn.sendReceive(self.pkg + ".getTile", id) + return Vec3(*map(int, s.split(","))) + + def setTilePos(self, id, *args): + """Set entity tile position (entityId:int) => Vec3""" + self.conn.send(self.pkg + ".setTile", id, args) + + def setting(self, setting, status): + """Set a player setting (setting, status). keys: autojump""" + self.conn.send(self.pkg + ".setting", setting, 1 if bool(status) else 0) + + +class CmdEntity(CmdPositioner): + """Methods for entities""" + def __init__(self, connection): + CmdPositioner.__init__(self, connection, "entity") + + +class CmdPlayer(CmdPositioner): + """Methods for the host (Raspberry Pi) player""" + def __init__(self, connection): + CmdPositioner.__init__(self, connection, "player") + self.conn = connection + + def getPos(self): + return CmdPositioner.getPos(self, []) + def setPos(self, *args): + return CmdPositioner.setPos(self, [], args) + def getTilePos(self): + return CmdPositioner.getTilePos(self, []) + def setTilePos(self, *args): + return CmdPositioner.setTilePos(self, [], args) + +class CmdCamera: + def __init__(self, connection): + self.conn = connection + + def setNormal(self, *args): + """Set camera mode to normal Minecraft view ([entityId])""" + self.conn.send("camera.mode.setNormal", args) + + def setFixed(self): + """Set camera mode to fixed view""" + self.conn.send("camera.mode.setFixed") + + def setFollow(self, *args): + """Set camera mode to follow an entity ([entityId])""" + self.conn.send("camera.mode.setFollow", args) + + def setPos(self, *args): + """Set camera entity position (x,y,z)""" + self.conn.send("camera.setPos", args) + + +class CmdEvents: + """Events""" + def __init__(self, connection): + self.conn = connection + + def clearAll(self): + """Clear all old events""" + self.conn.send("events.clear") + + def pollBlockHits(self): + """Only triggered by sword => [BlockEvent]""" + s = self.conn.sendReceive("events.block.hits") + events = [e for e in s.split("|") if e] + return [BlockEvent.Hit(*map(int, e.split(","))) for e in events] + + +class Minecraft: + """The main class to interact with a running instance of Minecraft Pi.""" + def __init__(self, connection): + self.conn = connection + + self.camera = CmdCamera(connection) + self.entity = CmdEntity(connection) + self.player = CmdPlayer(connection) + self.events = CmdEvents(connection) + + def getBlock(self, *args): + """Get block (x,y,z) => id:int""" + return int(self.conn.sendReceive("world.getBlock", args)) + + def setBlock(self, *args): + """Set block (x,y,z,id,[data])""" + self.conn.send("world.setBlock", args) + + def setBlocks(self, *args): + """Set a cuboid of blocks (x0,y0,z0,x1,y1,z1,id,[data])""" + self.conn.send("world.setBlocks", args) + + def getHeight(self, *args): + """Get the height of the world (x,z) => int""" + return int(self.conn.sendReceive("world.getHeight", args)) + + def getPlayerEntityIds(self): + """Get the entity ids of the connected players => [id:int]""" + ids = self.conn.sendReceive("world.getPlayerIds") + return map(int, ids.split("|")) + + def saveCheckpoint(self): + """Save a checkpoint that can be used for restoring the world""" + self.conn.send("world.checkpoint.save") + + def restoreCheckpoint(self): + """Restore the world state to the checkpoint""" + self.conn.send("world.checkpoint.restore") + + def postToChat(self, msg): + """Post a message to the game chat""" + self.conn.send("chat.post", msg) + + def setting(self, setting, status): + """Set a world setting (setting, status). keys: world_immutable, nametags_visible""" + self.conn.send("world.setting", setting, 1 if bool(status) else 0) + + @staticmethod + def create(address = "localhost", port = 4711): + return Minecraft(Connection(address, port)) + + +if __name__ == "__main__": + mc = Minecraft.create() + mc.postToChat("Hello, Minecraft!") diff --git a/mcpisettings/NameTags/minecraft/minecraft.pyc b/mcpisettings/NameTags/minecraft/minecraft.pyc new file mode 100644 index 0000000000000000000000000000000000000000..168e62f2d30bcf914bd902a86e2fe44f3c1feba5 GIT binary patch literal 9323 zcmcgy-*Xg69q-vqLIQzs32^?n(*gBvW9=;E$hLg0WZiK&6I>OyhrWT&&4WOirW z?gWBRKEQ(ySC$Vx_-Faxf8w*HpU<~vXNK(ZYd0~Wo1UJY?(gqko$9|&9{=msfBw)? z*-sV!{|3$c3tfbNo=TMJcxv5K9-k{Jsi;m>tykT1RV7oZGp*LA@jRuXB^6Dp7fL-> z>Z|n`70oC;qc%Mi9m{8rsc3dEJD1PSs_3|i&Zy`_J~gMJc@>>i(aC%YOHQfioQf9m zsS`?L)oHa;QT=}^eL`)Yb0De*3tGy4z;{W2O=3!)yqgzS4 zUEQ*A+I4eNnESnMT`5*vPtw-T%{|?<_9Q>(L~E&u`GxN1wBvr)(aa5W8V~?$^c4~j z6amFRJq|#ostl%8G$jKNN~pFD+RVtztP1Ycj&ZkTba%DgN+aWMrhVUNYvXR)54(}y z&c?kA8q*>J*(zu&XyzQcr=EJMR1<@W3ibh0T_ z;%i4Gp+PTf?SyT;*4LZy;~G{g=}ZHoi(6?&Uj)dV&|JK`vUcZ_+gNQbc4F+%4>xTw zYV`K)EIw&A<8Ex5%`+GqLZiGnuSM7h$uyc^^K%S<$~OK9PTNA=_krN^ih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isettings/NameTags/minecraft/vec3.py b/mcpisettings/NameTags/minecraft/vec3.py new file mode 100644 index 0000000..ea701f3 --- /dev/null +++ b/mcpisettings/NameTags/minecraft/vec3.py @@ -0,0 +1,115 @@ +class Vec3: + def __init__(self, x=0, y=0, z=0): + self.x = x + self.y = y + self.z = z + + def __add__(self, rhs): + c = self.clone() + c += rhs + return c + + def __iadd__(self, rhs): + self.x += rhs.x + self.y += rhs.y + self.z += rhs.z + return self + + def length(self): + return self.lengthSqr ** .5 + + def lengthSqr(self): + return self.x * self.x + self.y * self.y + self.z * self.z + + def __mul__(self, k): + c = self.clone() + c *= k + return c + + def __imul__(self, k): + self.x *= k + self.y *= k + self.z *= k + return self + + def clone(self): + return Vec3(self.x, self.y, self.z) + + def __neg__(self): + return Vec3(-self.x, -self.y, -self.z) + + def __sub__(self, rhs): + return self.__add__(-rhs) + + def __isub__(self, rhs): + return self.__iadd__(-rhs) + + def __repr__(self): + return "Vec3(%s,%s,%s)"%(self.x,self.y,self.z) + + def __iter__(self): + return iter((self.x, self.y, self.z)) + + def _map(self, func): + self.x = func(self.x) + self.y = func(self.y) + self.z = func(self.z) + + def __cmp__(self, rhs): + dx = self.x - rhs.x + if dx != 0: return dx + dy = self.y - rhs.y + if dy != 0: return dy + dz = self.z - rhs.z + if dz != 0: return dz + return 0 + + def iround(self): self._map(lambda v:int(v+0.5)) + def ifloor(self): self._map(int) + + def rotateLeft(self): self.x, self.z = self.z, -self.x + def rotateRight(self): self.x, self.z = -self.z, self.x + + @staticmethod + def y(n=1): return Vec3(0, n, 0) + @staticmethod + def up(n=1): return Vec3.y(n) + @staticmethod + def down(n=1): return Vec3.y(-n) + +def testVec3(): + # Note: It's not testing everything + + # 1.1 Test initialization + it = Vec3(1, -2, 3) + assert it.x == 1 + assert it.y == -2 + assert it.z == 3 + + assert it.x != -1 + assert it.y != +2 + assert it.z != -3 + + # 2.1 Test cloning and equality + clone = it.clone() + assert it == clone + it.x += 1 + assert it != clone + + # 3.1 Arithmetic + a = Vec3(10, -3, 4) + b = Vec3(-7, 1, 2) + c = a + b + assert c - a == b + assert c - b == a + assert a + a == a * 2 + + assert a - a == Vec3(0,0,0) + assert a + (-a) == Vec3(0,0,0) + + # Test repr + e = eval(repr(it)) + assert e == it + +if __name__ == "__main__": + testVec3() diff --git a/mcpisettings/NameTags/minecraft/vec3.pyc b/mcpisettings/NameTags/minecraft/vec3.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fb2ff0778a0da4437adec07d3595bde10f0b11fe GIT binary patch literal 5466 zcmcgw-EtH~6h1Sv8?yN!A=zXjq9O<^6q*uCDJ%+6{G*hJlPassO|$IGCPVfo&P))f za4#R6S+j6oFG6 z^jWBTpefl0N*^kHRHruecoMc-KHGgN_u0LUVo7oy-26(f6V9igjb#4TjoUZh{Jhaz zP3AjMH*Cg@Ryuzlv-Z~7!*m$EjfuKZY7Dg{oL6xw_%&Il^1_7Ur~v;x4U|oofPY6W zTP{aWU}+ho+3s~iHO5!yR28ozYE5%sz(=6Pm_`s7LpH-Z=8RapIp!N|dmjXNO8^X< zpqE|xo)UN-5`cG&&PnN>+5!rRPEKwQVL$I}j-p2S#4xZene)|{F(^tX5NAq%O*)dL zaQ`SO*8NyY(~EUBEG&cI?~e~Oc+v{^cGz7`R~EmERirovhRATR`li4o98#PD8hxXl zz5vETv$V>GIu^8AV@;h3TCMHnSq*E3%bT`|;1((|B?X0(r;a0I{^uCP_a9kF>SGI>Ps{L_`>OO*Y{2(UKe(V@(!z;9b0&ynv zS40M-25Mv}@SQ-Vz&C0GRUe*= zz7U96OmxF#W6t&=WxVD^J$V!Y;sbSn%_-ccUgE;n9pMo6B^#y5`dwpqn&iIA(G)9b zZ$u-9h$ss>g>PZn`Kj21TxoeSn{Am1aWieHpGhw2|9QL0)seK$o~c?r z$X=A4u5q{)8#BKb>}^qKgOJoC?7o>M7)=49G>o4=lnx6nbsKZ35AKeM*Ml|pGVlQ_ z4^}JDl!+2lt;D4blbm_*50Kd+y?Bys#y)wlOl=(ROoCq z0Cdit1c;(lPvVozau(UH=77#^B4~A);%E zGkF!nA|l0^;o@o22CP<{#6Ea@O_$>#z~j~*_tHihei^pXPpSF;AnKXx$P0tWG|@uz zqve(Kvm9eYmlU(huu)%5f7oh)%g@bTFKZp!a?E z))t()rkC6SjOjKyp)o0A&zMdxSZ|~1>#kaX%x8noYnEOSeB$;eNVvRxPO#54?DL}I zPm}N(;p?(}ncPW|*GW#1oCZnt+J-=nnw=2$?Z95i&#?V0$d==k+n@J!COPj3591+c zs$3~ohAJL@`IEe@S8!!_Sv(}-wlwjU&^Y=)qxd&yvr&w1F!=g{DBiStgrnz`E6F** zS@VMi7Sa!N!`GkWYM&4%n|=~XzU~v^^%9TEq}3tz|CbfZs-_lLCW&wawOJQms1 zQE`ZJ$X~Zwd0WSl%dhI}0G+>Q9cT|e6XBE5u-fCQh4@T_m!K9F;<(1y>`BcY%&5$v z#zCr1W-Lx@4^nIGg1yPXn*OSCYRvf;biIp% literal 0 HcmV?d00001 diff --git a/mcpisettings/NameTags/nametag-disable.py b/mcpisettings/NameTags/nametag-disable.py new file mode 100644 index 0000000..764c23e --- /dev/null +++ b/mcpisettings/NameTags/nametag-disable.py @@ -0,0 +1,5 @@ +import minecraft.minecraft as minecraft + +mc = minecraft.Minecraft.create() + +mc.setting("nametags_visible", False) \ No newline at end of file diff --git a/mcpisettings/NameTags/nametag-enable.py b/mcpisettings/NameTags/nametag-enable.py new file mode 100644 index 0000000..6000e6c --- /dev/null +++ b/mcpisettings/NameTags/nametag-enable.py @@ -0,0 +1,5 @@ +import minecraft.minecraft as minecraft + +mc = minecraft.Minecraft.create() + +mc.setting("nametags_visible", True) \ No newline at end of file diff --git a/minecraft/__init__.py b/minecraft/__init__.py old mode 100755 new mode 100644 diff --git a/minecraft/__init__.pyc b/minecraft/__init__.pyc index a846f5a8d4ca98235ae1d97d94ac380929023700..182a13713b891e41838a9d66f572489c306efe88 100644 GIT binary patch delta 46 zcmZo;Y++<){>;nOm+^NZyP32u0|SG8Mt*LpehH9FEY|mR4)E0VNKDQyo*1PA06!59 ALjV8( delta 48 zcmZo+Y-40+{>;nuHTU~Ob~9Oh1_lQGjQreG{en#W+|0bxeaMnH|k8lTdR2 delta 279 zcmew_(<{r){F#^QYwq`r>{D4}br={J^fU5vQ}qin^>Z`xQj?1k(@J!ciZWBuQzuVk zlbC#-rGTI+k;!?ixdc^7Oy*myiJ&$`7@1AZ`V0&V`WgATsrn^AGO<|S*Ezsb*CR1GyLj>e7KzOc zj5UN5NpAkcv=OhO%?DVt@G1aWCAnFF&5xj>$xGNL5pc8QZ`xQj?1k(@J!ciZWBuQztjF zOKi4dtRbvSa`QW;jl?Ls%pypPG6^<6!pc??biL%{1dddKsw5`=;K(MZN^>C)RwHO!}^fU5vQ}s)LWMZ+tuXBK>u18{WcJX9gW~t5Z e7?lVqT8!6_x6B=QM$@c=x5~Trs@}D>gQ(Wr6w08rj_U>6=kNRr%wLI hBC+`uqY4qqCOa~B6EN&Ka|ZzxT`Z9VRQzMn1^_b@LR`7^@A=dJGH<`WgATsrn^AGO<|S*Ezsb*CR1GyLj?OF^SC` zO#F<56iq(Ee3GD=Q!GCSs(GNmGWj>_38K{fVf#-&o%m#Zj%*U9r zCWO>&_U4iz6jB~RZ&m!e z38<5pY%9b*xlmvML3M6|hX|^%6^cM~!Ml9F5`R}ga1WJRfE1l9bJIzUhjDAs;RZy~7eq0BpiYFOkh;8pWc?h0Oc uVA(YJm;6RTYBoPmU?v=p`W&p2Wt18T88-P6K{eu&+m-Qq4CL@06>R{lRm8&p delta 1478 zcmaFuvE7rM`7Z`xQj?1k(@J!ciZWBuQztiy zNlbQ7VcFcp#LY;A(i6-liBNTfM diff --git a/minecraft/util.py b/minecraft/util.py old mode 100755 new mode 100644 diff --git a/minecraft/util.pyc b/minecraft/util.pyc index 404801bf351752a786ff70dcdaca05bb1797d8a0..de5c6c43ad4c516f262378fbaef75afeb8b0998d 100644 GIT binary patch delta 112 zcmZ3(x{Q^b`7{^V{nhXpK`WgATsrn^AGO<|S*Ezsb*CR1GyLhr6;{v?$ M+)NR8Z`xQj?1k(@J!ciZWBuQz!c{ QE+C+SohgEViYg`@0MEiES^xk5 diff --git a/minecraft/vec3.py b/minecraft/vec3.py old mode 100755 new mode 100644 diff --git a/minecraft/vec3.pyc b/minecraft/vec3.pyc index c7ccc5dbf91c31356bfdb591095e0a570c33fb1d..fb2ff0778a0da4437adec07d3595bde10f0b11fe 100644 GIT binary patch delta 957 zcmeCvzNN*^{F#@lFXQh<_UDY!nhXpK`WgATsrn^AGO<|S*Ezsb*CR1GyLhr8i}2+6 z%4QfC0=zu**fsbgY4SK zoy;+`6h4}pPJ3r1dlV}Qvl9j RXGO{gs`<~uI=Mnr3;@?jBWVBt delta 957 zcmcbm)u+wQ{F#^QYwq`r?9UlxwHX)~^fU5vQ}qin^>Z`xQj?1k(@J!ciZWBuQzviW zkeaN_R6{`32X4v9mzib|Pz5q;0dpP!RR?&*Cp)k-5KwiSrHOzFkeep5_7hMAa#JW< zB>`10**XZQ0NJ*bJ&p)f<{X4nZQz(gz?=;nl9L-as|l)-nry&DC{`YGeIj7a2kwIe zRBYf7pZu7|fPkt4yb_b$c;gAGY9XK^o{vy$F!47MFk>EnJ^>XP0!0K=Y!$eMU&ZES Yg2$QgD*