foo
This commit is contained in:
parent
7cc261ea67
commit
5f4e5affd1
1
raspberryjammod/TODO
Executable file
1
raspberryjammod/TODO
Executable file
@ -0,0 +1 @@
|
||||
win32move doesn't work
|
0
raspberryjammod/mcpipy/NeuroPy/NeuroPy.py
Normal file → Executable file
0
raspberryjammod/mcpipy/NeuroPy/NeuroPy.py
Normal file → Executable file
0
raspberryjammod/mcpipy/NeuroPy/README.txt
Normal file → Executable file
0
raspberryjammod/mcpipy/NeuroPy/README.txt
Normal file → Executable file
0
raspberryjammod/mcpipy/NeuroPy/__init__.py
Normal file → Executable file
0
raspberryjammod/mcpipy/NeuroPy/__init__.py
Normal file → Executable file
0
raspberryjammod/mcpipy/bridge.py
Normal file → Executable file
0
raspberryjammod/mcpipy/bridge.py
Normal file → Executable file
0
raspberryjammod/mcpipy/brooksc_findpos.py
Executable file → Normal file
0
raspberryjammod/mcpipy/brooksc_findpos.py
Executable file → Normal file
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#import the minecraft.py module from the minecraft directory
|
||||
import mcpi.minecraft as minecraft
|
||||
#import minecraft block module
|
||||
import mcpi.block as block
|
||||
#import time, so delays can be used
|
||||
import server
|
||||
|
||||
def main():
|
||||
mc = minecraft.Minecraft.create(server.address)
|
||||
# write the rest of your code here...
|
||||
mc.postToChat("Erasing a 50x50 block...")
|
||||
mc.setBlocks(-50,-10,-50,50,10,50,block.AIR.id)
|
||||
mc.setBlocks(-50,0,-50,50,-10,50,block.GRASS.id)
|
||||
mc.postToChat("Done Erasing a 50x50 block!")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,27 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# as shared on mcpipy.com
|
||||
|
||||
import mcpi.minecraft as minecraft
|
||||
import mcpi.block as block
|
||||
import time
|
||||
import server
|
||||
|
||||
|
||||
# If you are running this script with the bukkit mod, then use a diamond block as the magic center block for teleporting
|
||||
# comment/uncomment below as appropriate
|
||||
magic_block = block.DIAMOND_BLOCK # for bukkit server
|
||||
#magic_block = block.NETHER_REACTOR_CORE # for raspberry pi
|
||||
|
||||
if __name__ == "__main__": # The script
|
||||
mc = minecraft.Minecraft.create(server.address)
|
||||
loc = mc.player.getPos()
|
||||
x = loc.x
|
||||
y = loc.y - 1
|
||||
z = loc.z
|
||||
for z_z in range (int(z-1), int(z+2)):
|
||||
for x_x in range(int(x-1), int(x+2)):
|
||||
mc.setBlock(x_x,y,z_z, block.COBBLESTONE)
|
||||
mc.setBlock(x_x,y+1,z_z, block.AIR)
|
||||
|
||||
mc.setBlock(x,y,z, magic_block)
|
@ -1,17 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#import the minecraft.py module from the minecraft directory
|
||||
import mcpi.minecraft as minecraft
|
||||
#import minecraft block module
|
||||
import mcpi.block as block
|
||||
#import time, so delays can be used
|
||||
import server
|
||||
|
||||
def main():
|
||||
mc = minecraft.Minecraft.create(server.address)
|
||||
# write the rest of your code here...
|
||||
mc.postToChat("Hello MCPIPY World!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
0
raspberryjammod/mcpipy/brooksc_tntsnake.py
Executable file → Normal file
0
raspberryjammod/mcpipy/brooksc_tntsnake.py
Executable file → Normal file
@ -1,106 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# mcpipy.com retrieved from URL below, written by burnaron
|
||||
# http://www.minecraftforum.net/topic/1689199-my-first-script-bunkermaticpy/
|
||||
|
||||
import mcpi.minecraft as minecraft
|
||||
import mcpi.block as block
|
||||
from math import *
|
||||
import server
|
||||
|
||||
mc = minecraft.Minecraft.create(server.address)
|
||||
x1 = 0
|
||||
y1 = 0
|
||||
z1 = 0
|
||||
# FASE 1: cleaning zone
|
||||
mc.setBlocks(x1-2,y1,z1-2,x1+2,y1+20,z1+2,0)
|
||||
mc.setBlocks(x1-51,y1-61,z1-51,x1+51,y1-19,z1+51,1)
|
||||
# FASE 2: establishing access
|
||||
mc.setBlocks(x1-1.5,y1+2,z1-1.5,x1+1.5,y1-60,z1+1.5,1)
|
||||
mc.setBlocks(x1-1,y1+2,z1-1,x1-1,y1-60,z1-1,0)
|
||||
# FASE 3: establishing main tunnels
|
||||
mc.setBlocks(x1-1,y1-60,z1-1,x1+1,y1-56,z1+1,0)
|
||||
mc.setBlocks(x1-50,y1-60,z1,x1+50,y1-58,z1,0)
|
||||
mc.setBlocks(x1,y1-60,z1-50,x1,y1-58,z1+50,0)
|
||||
mc.setBlocks(x1-1,y1+2,z1-1,x1-1,y1-60,z1-1,65,3)
|
||||
# FASE 4: establishing main chambers
|
||||
for pos in range(0,8):
|
||||
mc.setBlocks(x1+10+pos,y1-60,z1-pos,x1+10+pos,y1-58+pos,z1+pos,0)
|
||||
mc.setBlocks(x1-10-pos,y1-60,z1-pos,x1-10-pos,y1-58+pos,z1+pos,0)
|
||||
mc.setBlocks(x1-pos,y1-60,z1+10+pos,x1+pos,y1-58+pos,z1+10+pos,0)
|
||||
mc.setBlocks(x1-pos,y1-60,z1-10-pos,x1+pos,y1-58+pos,z1-10-pos,0)
|
||||
|
||||
mc.setBlocks(x1+18,y1-60,z1-8,x1+18+24,y1-50,z1+8,0)
|
||||
mc.setBlocks(x1-18,y1-60,z1-8,x1-18-24,y1-50,z1+8,0)
|
||||
mc.setBlocks(x1-8,y1-60,z1+18,x1+8,y1-50,z1+18+24,0)
|
||||
mc.setBlocks(x1-8,y1-60,z1-18,x1+8,y1-50,z1-18-24,0)
|
||||
|
||||
for pos in range(0,8):
|
||||
mc.setBlocks(x1+18+24+pos,y1-60,z1-8+pos,x1+18+24+pos,y1-50-pos,z1+8-pos,0)
|
||||
mc.setBlocks(x1-18-24-pos,y1-60,z1-8+pos,x1-18-24-pos,y1-50-pos,z1+8-pos,0)
|
||||
mc.setBlocks(x1-8+pos,y1-60,z1+18+24+pos,x1+8-pos,y1-50-pos,z1+18+24+pos,0)
|
||||
mc.setBlocks(x1-8+pos,y1-60,z1-18-24-pos,x1+8-pos,y1-50-pos,z1-18-24-pos,0)
|
||||
|
||||
# FASE 5: establishing lights & doors:
|
||||
# FASE 5.1: central chamber lights:
|
||||
mc.setBlock(0,-57,1,50)
|
||||
mc.setBlock(1,-57,0,50)
|
||||
mc.setBlock(0,-57,-1,50)
|
||||
mc.setBlock(-1,-57,0,50)
|
||||
# FASE 5.2: main chambers lights
|
||||
for pos in range(2,8):
|
||||
mc.setBlock(x1+pos,y1-58,z1+10+pos,50)
|
||||
mc.setBlock(x1-pos,y1-58,z1+10+pos,50)
|
||||
mc.setBlock(x1+pos,y1-58,z1-10-pos,50)
|
||||
mc.setBlock(x1-pos,y1-58,z1-10-pos,50)
|
||||
mc.setBlock(x1+10+pos,y1-58,z1+pos,50)
|
||||
mc.setBlock(x1+10+pos,y1-58,z1-pos,50)
|
||||
mc.setBlock(x1-10-pos,y1-58,z1+pos,50)
|
||||
mc.setBlock(x1-10-pos,y1-58,z1-pos,50)
|
||||
|
||||
for pos in range(0,24,2):
|
||||
mc.setBlock(x1+8,y1-58,z1+18+pos,50)
|
||||
mc.setBlock(x1-8,y1-58,z1+18+pos,50)
|
||||
mc.setBlock(x1+8,y1-58,z1-18-pos,50)
|
||||
mc.setBlock(x1-8,y1-58,z1-18-pos,50)
|
||||
mc.setBlock(x1+18+pos,y1-58,z1+8,50)
|
||||
mc.setBlock(x1+18+pos,y1-58,z1-8,50)
|
||||
mc.setBlock(x1-18-pos,y1-58,z1+8,50)
|
||||
mc.setBlock(x1-18-pos,y1-58,z1-8,50)
|
||||
|
||||
for pos in range(0,7):
|
||||
mc.setBlock(x1+8-pos,y1-58,z1+18+24+pos,50)
|
||||
mc.setBlock(x1-8+pos,y1-58,z1+18+24+pos,50)
|
||||
mc.setBlock(x1+8-pos,y1-58,z1-18-24-pos,50)
|
||||
mc.setBlock(x1-8+pos,y1-58,z1-18-24-pos,50)
|
||||
mc.setBlock(x1+18+24+pos,y1-58,z1+8-pos,50)
|
||||
mc.setBlock(x1+18+24+pos,y1-58,z1-8+pos,50)
|
||||
mc.setBlock(x1-18-24-pos,y1-58,z1+8-pos,50)
|
||||
mc.setBlock(x1-18-24-pos,y1-58,z1-8+pos,50)
|
||||
# FASE 5.3: doors
|
||||
mc.setBlock(x1,y1-60,z1+2,64,1)
|
||||
mc.setBlock(x1,y1-59,z1+2,64,8)
|
||||
mc.setBlock(x1,y1-58,z1+2,1)
|
||||
mc.setBlock(x1,y1-60,z1+10,64,3)
|
||||
mc.setBlock(x1,y1-59,z1+10,64,8)
|
||||
mc.setBlock(x1,y1-58,z1+10,1)
|
||||
|
||||
mc.setBlock(x1,y1-60,z1-2,64,3)
|
||||
mc.setBlock(x1,y1-59,z1-2,64,8)
|
||||
mc.setBlock(x1,y1-58,z1-2,1)
|
||||
mc.setBlock(x1,y1-60,z1-10,64,1)
|
||||
mc.setBlock(x1,y1-59,z1-10,64,8)
|
||||
mc.setBlock(x1,y1-58,z1-10,1)
|
||||
|
||||
mc.setBlock(x1+2,y1-60,z1,64,4)
|
||||
mc.setBlock(x1+2,y1-59,z1,64,8)
|
||||
mc.setBlock(x1+2,y1-58,z1,1)
|
||||
mc.setBlock(x1+10,y1-60,z1,64,2)
|
||||
mc.setBlock(x1+10,y1-59,z1,64,8)
|
||||
mc.setBlock(x1+10,y1-58,z1,1)
|
||||
mc.setBlock(x1-2,y1-60,z1,64,2)
|
||||
mc.setBlock(x1-2,y1-59,z1,64,8)
|
||||
mc.setBlock(x1-2,y1-58,z1,1)
|
||||
mc.setBlock(x1-10,y1-60,z1,64,4)
|
||||
mc.setBlock(x1-10,y1-59,z1,64,8)
|
||||
mc.setBlock(x1-10,y1-58,z1,1)
|
@ -1,95 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# mcpipy.com retrieved from URL below, written by burnaron
|
||||
# http://www.minecraftforum.net/topic/1689199-my-first-script-bunkermaticpy/
|
||||
|
||||
import mcpi.minecraft as minecraft
|
||||
import mcpi.block as block
|
||||
from math import *
|
||||
import server
|
||||
|
||||
mc = minecraft.Minecraft.create(server.address)
|
||||
x1 = -4
|
||||
y1 = 3
|
||||
z1 = 9
|
||||
long_tun = 10
|
||||
long_arc_ch = 8
|
||||
long_ch = 26
|
||||
long_m_ch = long_ch - 2 * long_arc_ch
|
||||
deepness = 60
|
||||
high_c_ch = 3
|
||||
|
||||
# FASE 1: cleaning zone
|
||||
mc.setBlocks(x1-2,y1,z1-2,x1+2,y1+20,z1+2,0)
|
||||
mc.setBlocks(x1-(long_tun+long_ch+1),y1-(deepness+1),z1-(long_tun+long_ch+1),x1+long_tun+long_ch+1,y1-(deepness-long_arc_ch-2-1),z1+long_tun+long_ch+1,1)
|
||||
|
||||
# FASE 2: establishing access
|
||||
mc.setBlocks(x1-1.5,y1+2,z1-1.5,x1+1.5,y1-deepness,z1+1.5,1)
|
||||
mc.setBlocks(x1-1,y1+2,z1-1,x1-1,y1-deepness,z1-1,0)
|
||||
|
||||
# FASE 3: establishing main tunnels, central chamber & and access stairs
|
||||
# FASE 3.1: establishing central chamber
|
||||
mc.setBlocks(x1-1,y1-deepness,z1-1,x1+1,y1-(deepness-high_c_ch),z1+1,0)
|
||||
|
||||
# FASE 3.2: establishing main tunnels
|
||||
mc.setBlocks(x1-(long_tun+long_ch),y1-deepness,z1,x1+long_tun+long_ch,y1-(deepness-1),z1,0)
|
||||
mc.setBlocks(x1,y1-deepness,z1-(long_tun+long_ch),x1,y1-(deepness-1),z1+long_tun+long_ch,0)
|
||||
|
||||
# FASE 3.3: establishing access stairs
|
||||
mc.setBlocks(x1-1,y1+2,z1-1,x1-1,y1-deepness,z1-1,65,3)
|
||||
|
||||
# FASE 4: establishing main chambers
|
||||
for pos in range(0,long_arc_ch):
|
||||
mc.setBlocks(x1+long_tun+pos,y1-deepness,z1-pos,x1+long_tun+pos,y1-(deepness-2)+pos,z1+pos,0)
|
||||
mc.setBlocks(x1-long_tun-pos,y1-deepness,z1-pos,x1-long_tun-pos,y1-(deepness-2)+pos,z1+pos,0)
|
||||
mc.setBlocks(x1-pos,y1-deepness,z1+long_tun+pos,x1+pos,y1-(deepness-2)+pos,z1+long_tun+pos,0)
|
||||
mc.setBlocks(x1-pos,y1-deepness,z1-long_tun-pos,x1+pos,y1-(deepness-2)+pos,z1-long_tun-pos,0)
|
||||
|
||||
mc.setBlocks(x1+long_tun+long_arc_ch,y1-deepness,z1-long_arc_ch,x1+long_tun+long_arc_ch+long_m_ch,y1-(deepness-2)+long_arc_ch,z1+long_arc_ch,0)
|
||||
mc.setBlocks(x1-(long_tun+long_arc_ch),y1-deepness,z1-long_arc_ch,x1-(long_tun+long_arc_ch)-long_m_ch,y1-(deepness-2)+long_arc_ch,z1+long_arc_ch,0)
|
||||
mc.setBlocks(x1-long_arc_ch,y1-deepness,z1+long_tun+long_arc_ch,x1+long_arc_ch,y1-(deepness-2)+long_arc_ch,z1+long_tun+long_arc_ch+long_m_ch,0)
|
||||
mc.setBlocks(x1-long_arc_ch,y1-deepness,z1-(long_tun+long_arc_ch),x1+long_arc_ch,y1-(deepness-2)+long_arc_ch,z1-(long_tun+long_arc_ch)-(long_m_ch),0)
|
||||
|
||||
for pos in range(0,long_arc_ch):
|
||||
mc.setBlocks(x1+long_tun+long_arc_ch+long_m_ch+pos,y1-deepness,z1-long_arc_ch+pos,x1+long_tun+long_arc_ch+long_m_ch+pos,y1-(deepness-2)+long_arc_ch-pos,z1+long_arc_ch-pos,0)
|
||||
mc.setBlocks(x1-(long_tun+long_arc_ch)-long_m_ch-pos,y1-deepness,z1-long_arc_ch+pos,x1-(long_tun+long_arc_ch)-long_m_ch-pos,y1-(deepness-2)+long_arc_ch-pos,z1+long_arc_ch-pos,0)
|
||||
mc.setBlocks(x1-long_arc_ch+pos,y1-deepness,z1+long_tun+long_arc_ch+long_m_ch+pos,x1+long_arc_ch-pos,y1-(deepness-2)+long_arc_ch-pos,z1+long_tun+long_arc_ch+long_m_ch+pos,0)
|
||||
mc.setBlocks(x1-long_arc_ch+pos,y1-deepness,z1-(long_tun+long_arc_ch)-long_m_ch-pos,x1+long_arc_ch-pos,y1-(deepness-2)+long_arc_ch-pos,z1-(long_tun+long_arc_ch)-long_m_ch-pos,0)
|
||||
|
||||
# FASE 5: establishing lights & doors:
|
||||
# FASE 5.1: central chamber lights:
|
||||
mc.setBlock(x1,y1-(deepness-2),z1+1,50)
|
||||
mc.setBlock(x1+1,y1-(deepness-2),z1,50)
|
||||
mc.setBlock(x1,y1-(deepness-2),z1-1,50)
|
||||
mc.setBlock(x1-1,y1-(deepness-2),z1,50)
|
||||
|
||||
# FASE 5.2: main chambers lights
|
||||
for pos in range(2,long_arc_ch):
|
||||
mc.setBlock(x1+pos,y1-(deepness-2),z1+long_tun+pos,50)
|
||||
mc.setBlock(x1-pos,y1-(deepness-2),z1+long_tun+pos,50)
|
||||
mc.setBlock(x1+pos,y1-(deepness-2),z1-long_tun-pos,50)
|
||||
mc.setBlock(x1-pos,y1-(deepness-2),z1-long_tun-pos,50)
|
||||
mc.setBlock(x1+long_tun+pos,y1-(deepness-2),z1+pos,50)
|
||||
mc.setBlock(x1+long_tun+pos,y1-(deepness-2),z1-pos,50)
|
||||
mc.setBlock(x1-long_tun-pos,y1-(deepness-2),z1+pos,50)
|
||||
mc.setBlock(x1-long_tun-pos,y1-(deepness-2),z1-pos,50)
|
||||
|
||||
for pos in range(0,long_m_ch,2):
|
||||
mc.setBlock(x1+long_arc_ch,y1-(deepness-2),z1+long_tun+long_arc_ch+pos,50)
|
||||
mc.setBlock(x1-long_arc_ch,y1-(deepness-2),z1+long_tun+long_arc_ch+pos,50)
|
||||
mc.setBlock(x1+long_arc_ch,y1-(deepness-2),z1-(long_tun+long_arc_ch)-pos,50)
|
||||
mc.setBlock(x1-long_arc_ch,y1-(deepness-2),z1-(long_tun+long_arc_ch)-pos,50)
|
||||
mc.setBlock(x1+long_tun+long_arc_ch+pos,y1-(deepness-2),z1+long_arc_ch,50)
|
||||
mc.setBlock(x1+long_tun+long_arc_ch+pos,y1-(deepness-2),z1-long_arc_ch,50)
|
||||
mc.setBlock(x1-(long_tun+long_arc_ch)-pos,y1-(deepness-2),z1+long_arc_ch,50)
|
||||
mc.setBlock(x1-(long_tun+long_arc_ch)-pos,y1-(deepness-2),z1-long_arc_ch,50)
|
||||
|
||||
for pos in range(0,7):
|
||||
mc.setBlock(x1+long_arc_ch-pos,y1-(deepness-2),z1+long_tun+long_arc_ch+long_m_ch+pos,50)
|
||||
mc.setBlock(x1-long_arc_ch+pos,y1-(deepness-2),z1+long_tun+long_arc_ch+long_m_ch+pos,50)
|
||||
mc.setBlock(x1+long_arc_ch-pos,y1-(deepness-2),z1-(long_tun+long_arc_ch)-long_m_ch-pos,50)
|
||||
mc.setBlock(x1-long_arc_ch+pos,y1-(deepness-2),z1-(long_tun+long_arc_ch)-long_m_ch-pos,50)
|
||||
mc.setBlock(x1+long_tun+long_arc_ch+long_m_ch+pos,y1-(deepness-2),z1+long_arc_ch-pos,50)
|
||||
mc.setBlock(x1+long_tun+long_arc_ch+long_m_ch+pos,y1-(deepness-2),z1-long_arc_ch+pos,50)
|
||||
mc.setBlock(x1-(long_tun+long_arc_ch)-long_m_ch-pos,y1-(deepness-2),z1+long_arc_ch-pos,50)
|
||||
mc.setBlock(x1-(long_tun+long_arc_ch)-long_m_ch-pos,y1-(deepness-2),z1-long_arc_ch+pos,50)
|
@ -18,6 +18,12 @@ def getHeightBelow(x,y,z):
|
||||
return min(mc.getHeight(x,z),y)
|
||||
|
||||
def rectangularPrism(x1,y1,z1, x2,y2,z2, distribution):
|
||||
x1 = int(round(x1))
|
||||
y1 = int(round(y1))
|
||||
z1 = int(round(z1))
|
||||
x2 = int(round(x2))
|
||||
y2 = int(round(y2))
|
||||
z2 = int(round(z2))
|
||||
for x in range(min(x1,x2),max(x1,x2)+1):
|
||||
for y in range(min(y1,y2),max(y1,y2)+1):
|
||||
for z in range(min(z1,z2),max(z1,z2)+1):
|
||||
|
25
raspberryjammod/mcpipy/chess.py
Normal file → Executable file
25
raspberryjammod/mcpipy/chess.py
Normal file → Executable file
@ -21,19 +21,24 @@ LABEL_BLOCK = REDSTONE_BLOCK
|
||||
try:
|
||||
import _sunfish as sunfish
|
||||
except:
|
||||
import urllib2
|
||||
import os.path
|
||||
import os
|
||||
content = urllib2.urlopen("https://raw.githubusercontent.com/thomasahle/sunfish/master/sunfish.py").read()
|
||||
filename = os.path.join(os.path.dirname(sys.argv[0]),"_sunfish.py")
|
||||
try:
|
||||
import urllib2
|
||||
import os.path
|
||||
content = urllib2.urlopen("https://raw.githubusercontent.com/thomasahle/sunfish/master/sunfish.py").read()
|
||||
f=open(os.path.join(os.path.dirname(sys.argv[0]),"_sunfish.py"),"w")
|
||||
f.write("# From: https://raw.githubusercontent.com/thomasahle/sunfish/master/sunfish.py\n")
|
||||
f.write("# Covered by the GPL 2 license\n")
|
||||
f.write(content)
|
||||
f=open(filename,"wb")
|
||||
f.write(b"# -*- coding: utf-8 -*-")
|
||||
f.write(b"# From: https://raw.githubusercontent.com/thomasahle/sunfish/master/sunfish.py\n")
|
||||
f.write(b"# Covered by the GPL 2 license\n")
|
||||
f.write(bytearray(content))
|
||||
f.close()
|
||||
import _sunfish as sunfish
|
||||
except:
|
||||
print "Failed download: You need sunfish.py for this script."
|
||||
|
||||
os.remove(filename)
|
||||
print("Error creating _sunfish.py")
|
||||
sys.exit(0)
|
||||
|
||||
def getCoords(row,col):
|
||||
return (corner.x+8*row+4,corner.y,corner.z+8*col+4)
|
||||
|
||||
@ -390,7 +395,7 @@ while True:
|
||||
sunfish.tp = OrderedDict()
|
||||
move,score = sunfish.search(pos)
|
||||
else:
|
||||
moves = tuple(pos.genMoves())
|
||||
moves = tuple(pos.gen_moves())
|
||||
move = None
|
||||
while move not in moves:
|
||||
if move is not None:
|
||||
|
0
raspberryjammod/mcpipy/clock.py
Normal file → Executable file
0
raspberryjammod/mcpipy/clock.py
Normal file → Executable file
6
raspberryjammod/mcpipy/console.py
Normal file → Executable file
6
raspberryjammod/mcpipy/console.py
Normal file → Executable file
@ -1,3 +1,7 @@
|
||||
#
|
||||
# WARNING: If you're running RJM on a server, do NOT include this script server-side for security reasons.
|
||||
#
|
||||
|
||||
#
|
||||
# Code under the MIT license by Alexander Pruss
|
||||
#
|
||||
@ -26,6 +30,8 @@ def inputLine(prompt):
|
||||
return 'quit()'
|
||||
elif c.message == ' ':
|
||||
return ''
|
||||
elif "__" in c.message:
|
||||
sys.exit();
|
||||
else:
|
||||
return c.message
|
||||
time.sleep(0.2)
|
||||
|
@ -1,114 +0,0 @@
|
||||
# Don't execute this directory -- this is a support script for danielbates_setblockdemo.py
|
||||
|
||||
import sys
|
||||
|
||||
# Add some common locations where the main API might be. Feel free to add/change
|
||||
# these to suit you.
|
||||
sys.path.append("mcpi")
|
||||
sys.path.append("api/python/mcpi")
|
||||
sys.path.append("mcpi/api/python/mcpi")
|
||||
|
||||
# Attempt to import Mojang's API.
|
||||
try:
|
||||
import connection
|
||||
import minecraft
|
||||
except ImportError:
|
||||
print "Unable to find Minecraft API. Please place minecraft_basic.py in the mcpi directory."
|
||||
exit()
|
||||
|
||||
_server = None
|
||||
_blockedit = None
|
||||
_playeredit = None
|
||||
|
||||
def connect(ip="127.0.0.1", port=4711):
|
||||
global _server, _blockedit, _playeredit
|
||||
|
||||
try:
|
||||
_server = connection.Connection(ip, port)
|
||||
_blockedit = minecraft.Minecraft(_server)
|
||||
_playeredit = _blockedit.player
|
||||
except Exception:
|
||||
print "Unable to connect to Minecraft server at {0}:{1}".format(ip,port)
|
||||
return
|
||||
|
||||
print "Connected to Minecraft server at {0}:{1}".format(ip,port)
|
||||
|
||||
def setblock(x,y,z,*typedata):
|
||||
_blockedit.setBlock(x,y,z,typedata)
|
||||
|
||||
def getblock(x,y,z):
|
||||
return _blockedit.getBlock(x,y,z)
|
||||
|
||||
def moveplayer(x,y,z):
|
||||
_playeredit.setPos(x,y,z)
|
||||
|
||||
AIR = 0
|
||||
STONE = 1
|
||||
GRASS = 2
|
||||
DIRT = 3
|
||||
COBBLESTONE = 4
|
||||
WOOD_PLANK = 5
|
||||
SAPLING = 6
|
||||
BEDROCK = 7
|
||||
WATER_FLOWING = 8
|
||||
WATER = 9
|
||||
LAVA_FLOWING = 10
|
||||
LAVA = 11
|
||||
SAND = 12
|
||||
GRAVEL = 13
|
||||
GOLD_ORE = 14
|
||||
IRON_ORE = 15
|
||||
COAL_ORE = 16
|
||||
WOOD = 17
|
||||
LEAVES = 18
|
||||
GLASS = 20
|
||||
LAPIS_ORE = 21
|
||||
LAPIS = 22
|
||||
SANDSTONE = 24
|
||||
BED = 26
|
||||
COBWEB = 30
|
||||
TALL_GRASS = 31
|
||||
WOOL = 35
|
||||
FLOWER_YELLOW = 37
|
||||
FLOWER_RED = 38
|
||||
MUSHROOM_BROWN = 39
|
||||
MUSHROOM_RED = 40
|
||||
GOLD = 41
|
||||
IRON = 42
|
||||
STONE_SLAB_DOUBLE = 43
|
||||
STONE_SLAB = 44
|
||||
BRICK = 45
|
||||
TNT = 46
|
||||
BOOKSHELF = 47
|
||||
MOSSY_STONE = 48
|
||||
TORCH = 50
|
||||
FIRE = 51
|
||||
WOOD_STAIRS = 53
|
||||
CHEST = 54
|
||||
DIAMOND_ORE = 56
|
||||
DIAMOND = 57
|
||||
CRAFTING_TABLE = 58
|
||||
FARMLAND = 60
|
||||
FURNACE = 61
|
||||
FURNACE_ACTIVE = 62
|
||||
WOOD_DOOR = 64
|
||||
LADDER = 65
|
||||
COBBLESTONE_STAIRS = 67
|
||||
IRON_DOOR = 71
|
||||
REDSTONE_ORE = 73
|
||||
SNOW_COVER = 78
|
||||
ICE = 79
|
||||
SNOW = 80
|
||||
CACTUS = 81
|
||||
CLAY = 82
|
||||
SUGAR_CANE = 83
|
||||
FENCE = 85
|
||||
GLOWSTONE = 89
|
||||
INVISIBLE_BEDROCK = 95
|
||||
STONE_BRICK = 98
|
||||
GLASS_PANE = 102
|
||||
MELON = 103
|
||||
FENCE_GATE = 107
|
||||
GLOWING_OBSIDIAN = 246
|
||||
NETHER_REACTOR_CORE = 247
|
||||
UPDATE_GAME_BLOCK = 249
|
76
raspberryjammod/mcpipy/danielbates_setblockdemo.py
Executable file → Normal file
76
raspberryjammod/mcpipy/danielbates_setblockdemo.py
Executable file → Normal file
@ -1,7 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
from math import sin, cos, radians
|
||||
import danielbates_minecraft_basic as mc
|
||||
#
|
||||
# By Daniel Bates, with minor adaptations by Alexander Pruss
|
||||
#
|
||||
|
||||
from mc import *
|
||||
#import pygame.image # comment this out if not using images - it's slow to import. If you uncomment, uncomment the image reference below.
|
||||
import random
|
||||
import server
|
||||
@ -283,7 +286,7 @@ def officeblock(wallmaterial):
|
||||
goody = (point.y%5 == 1) or (point.y%5 == 2)
|
||||
goodz = (point.z%5 == 1) or (point.z%5 == 2)
|
||||
if (goodx and goody) or (goodz and goody):
|
||||
return mc.GLASS
|
||||
return GLASS
|
||||
else:
|
||||
return wallmaterial
|
||||
return f
|
||||
@ -313,13 +316,13 @@ def tomaterial(r,g,b):
|
||||
# Just a quick hack for now - could of course add more colours
|
||||
# and a way of finding the nearest supported colour.
|
||||
if (r,g,b) == (255,255,255): # white
|
||||
return mc.AIR
|
||||
return AIR
|
||||
elif (r,g,b) == (0,0,0): # black
|
||||
return mc.OBSIDIAN
|
||||
return OBSIDIAN
|
||||
elif (r,g,b) == (188,17,66): # pink
|
||||
return mc.REDSTONE_ORE
|
||||
return REDSTONE_ORE
|
||||
elif (r,g,b) == (117,169,40): # green
|
||||
return mc.MELON
|
||||
return MELON
|
||||
else:
|
||||
return None
|
||||
|
||||
@ -374,61 +377,62 @@ by multiplying them together.
|
||||
fillfunc = solid(material)
|
||||
for point in shape:
|
||||
point2 = transform * point
|
||||
mc.setblock(int(point2.x), int(point2.y), int(point2.z), fillfunc(point))
|
||||
mc.setBlock(int(point2.x), int(point2.y), int(point2.z), fillfunc(point))
|
||||
|
||||
def clear(shape, transform=identity()):
|
||||
"""Remove any non-air blocks in the given shape."""
|
||||
fillshape(shape,transform,mc.AIR)
|
||||
fillshape(shape,transform,AIR)
|
||||
|
||||
def main():
|
||||
global mc
|
||||
"""Function used to build my demo world. Extra clearing may be required for
|
||||
hilly worlds."""
|
||||
mc.connect(server.address)
|
||||
mc = Minecraft()
|
||||
|
||||
# Create a large empty space with a neat, grassy floor. Takes a long time!
|
||||
clear(cuboid(100,10,120))
|
||||
fillshape(floor(100,120), shift(0,-1,0), material=mc.GRASS)
|
||||
fillshape(floor(100,120), shift(0,-1,0), material=GRASS)
|
||||
|
||||
# Introduce basic shapes/transformations/fill functions.
|
||||
fillshape(arrow, material=mc.STONE)
|
||||
fillshape(arrow, shift(6,0,0), mc.STONE)
|
||||
fillshape(arrow, shift(12,0,0)*rotationx(90), mc.STONE)
|
||||
fillshape(arrow, shift(18,0,0)*rotationx(45), mc.STONE)
|
||||
fillshape(arrow, shift(24,0,0), fillfunc=chequers(mc.WOOD, mc.STONE))
|
||||
fillshape(arrow, material=STONE)
|
||||
fillshape(arrow, shift(6,0,0), STONE)
|
||||
fillshape(arrow, shift(12,0,0)*rotationx(90), STONE)
|
||||
fillshape(arrow, shift(18,0,0)*rotationx(45), STONE)
|
||||
fillshape(arrow, shift(24,0,0), fillfunc=chequers(WOOD, STONE))
|
||||
|
||||
# Introduce generator functions.
|
||||
fillshape(cuboid(4,4,4), shift(30,0,0), mc.STONE)
|
||||
fillshape(cuboid(3,8,2), shift(36,0,0), mc.STONE)
|
||||
fillshape(cuboid(4,4,4), shift(30,0,0), STONE)
|
||||
fillshape(cuboid(3,8,2), shift(36,0,0), STONE)
|
||||
|
||||
# Show other simple shapes.
|
||||
fillshape(sphere(5), shift(45,5,0), mc.STONE)
|
||||
fillshape(pyramid(5), shift(50,0,0), mc.STONE)
|
||||
fillshape(cylinder(5,4), shift(65,0,0), mc.STONE)
|
||||
fillshape(cone(5,5), shift(75,0,0), mc.STONE)
|
||||
fillshape(sphere(5), shift(45,5,0), STONE)
|
||||
fillshape(pyramid(5), shift(50,0,0), STONE)
|
||||
fillshape(cylinder(5,4), shift(65,0,0), STONE)
|
||||
fillshape(cone(5,5), shift(75,0,0), STONE)
|
||||
|
||||
# Show some fill functions.
|
||||
fillshape(cuboid(4,4,4), shift(80,0,5), fillfunc=chequers(mc.GOLD, mc.IRON))
|
||||
fillshape(pyramid(5), shift(80,0,10), fillfunc=randomfill([mc.SAND, mc.SANDSTONE]))
|
||||
fillshape(hollowcuboid(4,6,4), shift(80,0,22), mc.WOOD_PLANK)
|
||||
fillshape(building(2,6,2), shift(80,0,30), fillfunc=officeblock(mc.COBBLESTONE))
|
||||
fillshape(cuboid(4,4,4), shift(80,0,5), fillfunc=chequers(GOLD_BLOCK, IRON_BLOCK))
|
||||
fillshape(pyramid(5), shift(80,0,10), fillfunc=randomfill([SAND, SANDSTONE]))
|
||||
fillshape(hollowcuboid(4,6,4), shift(80,0,22), WOOD)
|
||||
fillshape(building(2,6,2), shift(80,0,30), fillfunc=officeblock(COBBLESTONE))
|
||||
|
||||
# Line drawing.
|
||||
fillshape(line(80,0,40,85,5,45), material=mc.WOOL)
|
||||
fillshape(line(80,0,40,80,2,50), material=mc.WOOL)
|
||||
fillshape(line(80,2,50,85,5,45), material=mc.WOOL)
|
||||
fillshape(line(80,0,40,85,5,45), material=WOOL)
|
||||
fillshape(line(80,0,40,80,2,50), material=WOOL)
|
||||
fillshape(line(80,2,50,85,5,45), material=WOOL)
|
||||
|
||||
# Fun lava sphere.
|
||||
fillshape(sphere(10), shift(80,10,60), mc.GLASS)
|
||||
fillshape(sphere(9), shift(80,10,60), mc.LAVA)
|
||||
fillshape(sphere(10), shift(80,10,60), GLASS)
|
||||
fillshape(sphere(9), shift(80,10,60), LAVA)
|
||||
|
||||
# Fractals - far easier to code than to build by hand.
|
||||
fillshape(mengersponge(0), shift(70,0,75), mc.IRON)
|
||||
fillshape(mengersponge(1), shift(66,0,75), mc.IRON)
|
||||
fillshape(mengersponge(2), shift(56,0,75), mc.IRON)
|
||||
fillshape(mengersponge(3), shift(28,0,75), mc.IRON)
|
||||
fillshape(mengersponge(0), shift(70,0,75), IRON_BLOCK)
|
||||
fillshape(mengersponge(1), shift(66,0,75), IRON_BLOCK)
|
||||
fillshape(mengersponge(2), shift(56,0,75), IRON_BLOCK)
|
||||
fillshape(mengersponge(3), shift(28,0,75), IRON_BLOCK)
|
||||
|
||||
# Maze.
|
||||
fillshape(maze(25,25), shift(0,0,75), mc.STONE)
|
||||
fillshape(maze(25,25), shift(0,0,75), STONE)
|
||||
|
||||
# Picture - can use the same technique to draw text.
|
||||
# fillshape(cuboid(24,30,1), shift(0,0,30), fillfunc=image("pi.png",24,30))
|
||||
|
0
raspberryjammod/mcpipy/davef21370_maze.py
Executable file → Normal file
0
raspberryjammod/mcpipy/davef21370_maze.py
Executable file → Normal file
@ -1,261 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# mcpipy.com retrieved from URL below, written by Davie Wales
|
||||
# https://bitbucket.org/dwales/minesweeper-for-minecraft-pi-edition/src
|
||||
|
||||
|
||||
import sys
|
||||
import random
|
||||
import threading
|
||||
import mcpi.minecraft as minecraft
|
||||
import server
|
||||
|
||||
|
||||
defaultDifficulty = 0.1
|
||||
setDifficulty = defaultDifficulty
|
||||
|
||||
class board:
|
||||
""" The cartesian grid can be done as follows:
|
||||
board = [["?", "*", "?", "?", "*", "?", "?", "?", "?", "*",],
|
||||
["?", "?", "*", "?", "?", "?", "?", "?", "?", "?",],
|
||||
["?", "*", "*", "?", "*", "?", "?", "*", "*", "?",],
|
||||
["?", "?", "?", "?", "?", "?", "*", "?", "*", "?",],
|
||||
["*", "?", "?", "?", "?", "*", "?", "?", "?", "?",],
|
||||
["?", "?", "?", "?", "?", "?", "?", "?", "?", "?",],
|
||||
["?", "*", "?", "*", "?", "?", "?", "*", "?", "*",],
|
||||
["?", "?", "?", "?", "?", "?", "?", "?", "?", "?",],
|
||||
["?", "*", "?", "?", "*", "*", "?", "?", "*", "?",],
|
||||
["?", "?", "*", "?", "?", "?", "?", "*", "?", "?",]]
|
||||
|
||||
Obviously the grid will be randomly generated on run to fit
|
||||
within the bounds of the terminal window.
|
||||
Notice that you can access the state of any tile on the grid with
|
||||
the simple command "board[x][y]"
|
||||
i.e. a = board[0][0] makes a == "?", a = board[0][9] makes a == "*"
|
||||
NOTE: I subsequently changed the code to use nested dictionaries,
|
||||
rather than lists to represent the board. The general idea is
|
||||
still the same...
|
||||
If we use a dictionary rather than a list in the following
|
||||
function, we will get a KeyError if we try to access a
|
||||
negative index, assuming we construct the dictionary such
|
||||
that it has identical indexes to the list equivalent.
|
||||
i.e. dictionary = {0:{0:" ", 1:" ", 2"*"}, 1:{0:"*", 1:" ", 2:" "}}
|
||||
This will be helpful, as it will negate the need to explicitly
|
||||
check whether a particular coordinate is legitimate. i.e. a
|
||||
dictionary won't match negative values for x, y, but a list will..."""
|
||||
|
||||
""" At the moment we are getting the window size before curses is
|
||||
initialised, which means that we have to use "stty size". If
|
||||
we can move this code into the curses section, we can use the
|
||||
built in window.getmaxyx(). This will make it easier to use
|
||||
windows smaller than the size of the terminal for the game,
|
||||
which will in turn allow us to add timers and minecounts."""
|
||||
|
||||
def __init__(self):
|
||||
global width, height
|
||||
width = 10
|
||||
height = 10
|
||||
|
||||
def options(self):
|
||||
totalTiles = width * height
|
||||
|
||||
#possible choices of tile: either "*" or " "
|
||||
self.mineNumber = int(setDifficulty * totalTiles)
|
||||
choices = list(self.mineNumber * "*")
|
||||
choices.extend(list((totalTiles-len(choices))*" "))
|
||||
return choices
|
||||
|
||||
# For every x and y, check all the squares around to see if there is a mine,
|
||||
# add together the number of mines touching the original square and replace
|
||||
# the original square with the final count.
|
||||
def numberise(self, board):
|
||||
for x in xrange(width):
|
||||
for y in xrange(height):
|
||||
count = 0
|
||||
if board[x][y] != "*":
|
||||
for i in xrange(-1, 2):
|
||||
for n in xrange(-1, 2):
|
||||
try:
|
||||
if board[x+i][y+n] == "*":
|
||||
count += 1
|
||||
except KeyError:
|
||||
pass
|
||||
if count != 0:
|
||||
board[x][y] = str(count)
|
||||
|
||||
def create(self):
|
||||
self.mineCoords = []
|
||||
choices = self.options()
|
||||
board = {}
|
||||
for i in xrange(0, width):
|
||||
board[i] = {}
|
||||
for n in xrange(0, height):
|
||||
board[i][n] = choices.pop(choices.index(random.choice(choices)))
|
||||
if board[i][n] == "*":
|
||||
self.mineCoords.append([i,n])
|
||||
|
||||
self.numberise(board)
|
||||
for i in xrange(width):
|
||||
for n in xrange(height):
|
||||
minecraftAddBlock(i, n, 1, board[i][n])
|
||||
|
||||
return board
|
||||
|
||||
def visibleScreen(self):
|
||||
board = {}
|
||||
for i in xrange(0, width):
|
||||
board[i] = {}
|
||||
for n in xrange(0, height):
|
||||
board[i][n] = " "
|
||||
return board
|
||||
|
||||
def minecraftAddBlock(X, Y, Z, mineAttribute):
|
||||
# This equates values passed through mineAttribute with the actual
|
||||
# block IDs from Minecraft.
|
||||
# 0 is Air, 5 is Wood Planks, 4 is cobblestone, coal is 16
|
||||
# Iron is 15, Gold is 14, Diamond is 56, Gold Block is 41,
|
||||
# Diamond Block is 57
|
||||
mineDict = {"dirt":3, "*":46, " ":20, 0:0, "1":5, "2":4, "3":16, "4":15, "5":14, "6":56, "7":41, "8":57}
|
||||
mc.setBlock(X, Y, Z, mineDict[mineAttribute])
|
||||
|
||||
def explore(x, y, Z): # Z is capitalised because it doesn't
|
||||
# need to be changed by the function.
|
||||
""" This is the bit that happens when you click on a blank square
|
||||
First it checks the squares directly around the clicked square
|
||||
If the square it checks is a number, it will display it, and
|
||||
if the square it checks is blank, it will add the blank square's
|
||||
coordinates to a list or dictionary, then it will keep doing the
|
||||
same process to all the coordinates in the list, deleting squares
|
||||
that have been checked, and adding new squares, until the list is
|
||||
empty. At that point, the area around the original square will be
|
||||
revealed, as you would expect to happen in minesweeper."""
|
||||
|
||||
checked = [[x,y]] # Has been checked and contains either a number or ' '
|
||||
toBeCentre = [[x, y]] # Each point in this list will be checked on all sides for the above conditions
|
||||
centred = [] # These points have already been checked on all sides
|
||||
global cleared
|
||||
cleared = []
|
||||
|
||||
while len(toBeCentre) > 0:
|
||||
X, Y = toBeCentre.pop(0)
|
||||
centred.append([X,Y])
|
||||
minecraftAddBlock(X, Y, Z, 0)
|
||||
if [X,Y] not in cleared:
|
||||
cleared.append([X,Y])
|
||||
for i in xrange(-1, 2):
|
||||
for n in xrange(-1, 2):
|
||||
|
||||
# When I was writing this section, it wouldn't work, and wouldn't work
|
||||
# and then after changing it around a million times, suddenly it started working...
|
||||
# The only problem is that I don't actually know what I did to make it work... =P
|
||||
try:
|
||||
if ((newBoard[X+i][Y+n] in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'])and ([X+i, Y+n] not in checked)):
|
||||
minecraftAddBlock(X+i, Y+n, Z, 0) #newBoard[X+i][Y+n])
|
||||
checked.append([X+i, Y+n])
|
||||
if [X+i,Y+n] not in cleared:
|
||||
cleared.append([X+i,Y+n])
|
||||
|
||||
elif newBoard[X+i][Y+n] == " ":
|
||||
if (([X+i, Y+n] not in checked) and ([X+i, Y+n] not in toBeCentre)):
|
||||
toBeCentre.append([X+i, Y+n])
|
||||
checked.append([X+i, Y+n])
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
class WinningCheckThread (threading.Thread):
|
||||
|
||||
def __init__(self, mineCoords, mineNumber, z):
|
||||
self.mineCoords = mineCoords
|
||||
self.mineNumber = mineNumber
|
||||
self.z = z
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
def run(self):
|
||||
global running
|
||||
running = True
|
||||
mc = minecraft.Minecraft.create()
|
||||
while running:
|
||||
### This is the winning condition... ###
|
||||
flagCount = 0
|
||||
correctFlagCount = 0
|
||||
|
||||
for x in xrange(width):
|
||||
for y in xrange(height):
|
||||
if mc.getBlock(x, y, 0-1) == 50:
|
||||
flagCount += 1
|
||||
if [x,y] in self.mineCoords:
|
||||
correctFlagCount += 1
|
||||
|
||||
if (self.mineNumber == correctFlagCount) and (self.mineNumber == flagCount):
|
||||
for x in xrange(width):
|
||||
for y in xrange(height):
|
||||
mc.setBlock(x, y, self.z, 20)
|
||||
|
||||
mc.postToChat("You Win!!!")
|
||||
running = False
|
||||
sys.exit()
|
||||
|
||||
class BlockCheckThread(threading.Thread):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
threading.Thread.__init__(self)
|
||||
def run(self):
|
||||
global running
|
||||
running = True
|
||||
mc = minecraft.Minecraft.create()
|
||||
while running:
|
||||
|
||||
event = mc.events.pollBlockHits()
|
||||
|
||||
if event:
|
||||
# mc.postToChat("Hit detected")
|
||||
eventSplit = str(event[0]).split()
|
||||
eventSplit = [eventSplit[1][0], eventSplit[2][0], eventSplit[3][0]]
|
||||
cursorX, cursorY, cursorZ = eventSplit
|
||||
cursorX = int(cursorX)
|
||||
cursorY = int(cursorY)
|
||||
cursorZ = int(cursorZ)
|
||||
if newBoard[cursorX][cursorY] == "*":
|
||||
for y in xrange(height):
|
||||
for x in xrange(width):
|
||||
# This bit of code's dodgy, because it relies on the
|
||||
# creation of "newBoard" external to the function...
|
||||
mc.setBlock(x, y, z, 0) # (If you hit a mine it clears the board.)
|
||||
mc.postToChat("You Lose!")
|
||||
running = False
|
||||
sys.exit()
|
||||
|
||||
if newBoard[cursorX][cursorY] in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:
|
||||
#visibleScreen[x][y] = newBoard[x][y]
|
||||
mc.setBlock(cursorX, cursorY, cursorZ, 0) # We just remove the top layer.
|
||||
|
||||
if newBoard[cursorX][cursorY] == " ":
|
||||
explore(cursorX, cursorY, cursorZ)
|
||||
|
||||
#def main():
|
||||
global running
|
||||
running = True
|
||||
mc = minecraft.Minecraft.create(server.address)
|
||||
board = board()
|
||||
newBoard = board.create()
|
||||
visibleScreen = board.visibleScreen()
|
||||
|
||||
for x in xrange(width):
|
||||
for y in xrange(height):
|
||||
mc.setBlock(x,y,-1,0)
|
||||
|
||||
z = 0 # For now... We can make this dynamic later.
|
||||
for y in xrange(height):
|
||||
for x in xrange(width):
|
||||
# This bit of code's dodgy, because it relies on the
|
||||
# creation of "visibleScreen" external to the function...
|
||||
minecraftAddBlock(x, y, z, "dirt")
|
||||
|
||||
WinningCheck = WinningCheckThread(board.mineCoords, board.mineNumber, z)
|
||||
BlockCheck = BlockCheckThread()
|
||||
BlockCheck.daemon
|
||||
WinningCheck.start()
|
||||
BlockCheck.start()
|
||||
|
||||
#main()
|
0
raspberryjammod/mcpipy/dragoncurve.py
Normal file → Executable file
0
raspberryjammod/mcpipy/dragoncurve.py
Normal file → Executable file
2
raspberryjammod/mcpipy/drawing.py
Normal file → Executable file
2
raspberryjammod/mcpipy/drawing.py
Normal file → Executable file
@ -501,7 +501,7 @@ class Drawing:
|
||||
x0 = p[0]+point[0]
|
||||
y0 = p[1]+point[1]
|
||||
z0 = p[2]+point[2]
|
||||
if (x0,y0,z0) not in self.done:
|
||||
if (x0,y0,z0) not in done:
|
||||
self.mc.setBlock(x0,y0,z0,block)
|
||||
done.add((x0,y0,z0))
|
||||
|
||||
|
0
raspberryjammod/mcpipy/fancytree.py
Normal file → Executable file
0
raspberryjammod/mcpipy/fancytree.py
Normal file → Executable file
0
raspberryjammod/mcpipy/fleap_railgen.py
Executable file → Normal file
0
raspberryjammod/mcpipy/fleap_railgen.py
Executable file → Normal file
@ -1,17 +0,0 @@
|
||||
#! /usr/bin/python
|
||||
import mcpi.minecraft as minecraft
|
||||
import mcpi.block as block
|
||||
import server
|
||||
|
||||
""" clearZone clears an area and sets a stone floor
|
||||
takes two x,z pairs clears everything above 0y and then sets
|
||||
a stone floor at -1y
|
||||
@author: goldfish"""
|
||||
|
||||
def clearZone( alocx, alocz, blocx, blocz ):
|
||||
mc.setBlocks( alocx, 0, alocz, blocx, 64, blocz, block.AIR )
|
||||
mc.setBlocks( alocx, -1, alocz, blocx, -1, blocz, block.STONE )
|
||||
|
||||
if __name__ == "__main__":
|
||||
mc = minecraft.Minecraft.create( server.address )
|
||||
clearZone( -20, -20, 20, 20 )
|
0
raspberryjammod/mcpipy/gf_drawbuilding.py
Executable file → Normal file
0
raspberryjammod/mcpipy/gf_drawbuilding.py
Executable file → Normal file
0
raspberryjammod/mcpipy/glasscube.py
Normal file → Executable file
0
raspberryjammod/mcpipy/glasscube.py
Normal file → Executable file
39
raspberryjammod/mcpipy/globe.py
Normal file
39
raspberryjammod/mcpipy/globe.py
Normal file
@ -0,0 +1,39 @@
|
||||
from mc import *
|
||||
|
||||
def globe(center, radius=40, spacing_degrees=10, block=STAINED_GLASS_YELLOW):
|
||||
quality = int(radius * 2*pi * 2)
|
||||
|
||||
# longitude lines
|
||||
longitude_degrees = 0
|
||||
while longitude_degrees < 360:
|
||||
theta = longitude_degrees * 2 * pi / 360
|
||||
xmult = radius * cos(theta)
|
||||
zmult = radius * sin(theta)
|
||||
for i in range(quality):
|
||||
phi = 2 * pi * i / quality
|
||||
y = radius * sin(phi)
|
||||
x = xmult * cos(phi)
|
||||
z = zmult * cos(phi)
|
||||
mc.setBlock(center[0]+x,center[1]+y,center[2]+z,block)
|
||||
longitude_degrees += spacing_degrees
|
||||
|
||||
# latitude lines
|
||||
latitude_degrees = -90
|
||||
while latitude_degrees <= 90:
|
||||
phi = latitude_degrees * 2 * pi / 360
|
||||
y = radius * sin(phi)
|
||||
r = radius * cos(phi)
|
||||
for i in range(quality):
|
||||
theta = 2 * pi * i / quality
|
||||
x = r * cos(theta)
|
||||
z = r * sin(theta)
|
||||
mc.setBlock(center[0]+x,center[1]+y,center[2]+z,block)
|
||||
latitude_degrees += spacing_degrees
|
||||
|
||||
if __name__ == "__main__":
|
||||
mc = Minecraft()
|
||||
center = mc.player.getPos()
|
||||
radius = 40
|
||||
globe((center.x,center.y+radius,center.z), radius-1, 360./(2*pi*2*radius), STAINED_GLASS_BLUE)
|
||||
globe((center.x,center.y+radius,center.z), radius, 10, STAINED_GLASS_YELLOW)
|
||||
|
4
raspberryjammod/mcpipy/grenade.py
Normal file → Executable file
4
raspberryjammod/mcpipy/grenade.py
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
#
|
||||
#
|
||||
# Code under the MIT license by Alexander Pruss
|
||||
#
|
||||
|
||||
@ -105,4 +105,4 @@ while True:
|
||||
if t > path[-1][0]:
|
||||
break
|
||||
|
||||
mc.setBlock(path[-1][1],REDSTONE_BLOCK)
|
||||
mc.setBlock(path[-1][1],FIRE)
|
||||
|
@ -2,7 +2,7 @@ import mcpi.minecraft as minecraft
|
||||
import mcpi.block as block
|
||||
import server
|
||||
import sys
|
||||
mc = minecraft.Minecraft.create(server.address)
|
||||
mc = minecraft.Minecraft()
|
||||
mc.postToChat("Hello world!")
|
||||
playerPos = mc.player.getPos()
|
||||
mc.setBlock(playerPos.x,playerPos.y-1,playerPos.z,block.DIAMOND_ORE)
|
||||
|
0
raspberryjammod/mcpipy/hilbert.py
Normal file → Executable file
0
raspberryjammod/mcpipy/hilbert.py
Normal file → Executable file
148
raspberryjammod/mcpipy/input.py
Executable file
148
raspberryjammod/mcpipy/input.py
Executable file
@ -0,0 +1,148 @@
|
||||
#
|
||||
# Windows-only (right now)
|
||||
# Copyright (c) 2016 Alexander Pruss. MIT License
|
||||
#
|
||||
|
||||
from platform import system
|
||||
|
||||
if system() == 'Windows':
|
||||
from ctypes import windll
|
||||
|
||||
LBUTTON = 1
|
||||
RBUTTON = 2
|
||||
CANCEL = 3
|
||||
MBUTTON = 4
|
||||
BACK = 8
|
||||
TAB = 9
|
||||
CLEAR = 12
|
||||
RETURN = 13
|
||||
SHIFT = 16
|
||||
CONTROL = 17
|
||||
MENU = 18
|
||||
PAUSE = 19
|
||||
CAPITAL = 20
|
||||
KANA = 21
|
||||
HANGUL = 21
|
||||
JUNJA = 23
|
||||
FINAL = 24
|
||||
HANJA = 25
|
||||
KANJI = 25
|
||||
ESCAPE = 27
|
||||
CONVERT = 28
|
||||
NONCONVERT = 29
|
||||
ACCEPT = 30
|
||||
MODECHANGE = 31
|
||||
SPACE = 32
|
||||
PRIOR = 33
|
||||
NEXT = 34
|
||||
END = 35
|
||||
HOME = 36
|
||||
LEFT = 37
|
||||
UP = 38
|
||||
RIGHT = 39
|
||||
DOWN = 40
|
||||
SELECT = 41
|
||||
PRINT = 42
|
||||
EXECUTE = 43
|
||||
SNAPSHOT = 44
|
||||
INSERT = 45
|
||||
DELETE = 46
|
||||
HELP = 47
|
||||
LWIN = 91
|
||||
RWIN = 92
|
||||
APPS = 93
|
||||
NUMPAD0 = 96
|
||||
NUMPAD1 = 97
|
||||
NUMPAD2 = 98
|
||||
NUMPAD3 = 99
|
||||
NUMPAD4 = 100
|
||||
NUMPAD5 = 101
|
||||
NUMPAD6 = 102
|
||||
NUMPAD7 = 103
|
||||
NUMPAD8 = 104
|
||||
NUMPAD9 = 105
|
||||
MULTIPLY = 106
|
||||
ADD = 107
|
||||
SEPARATOR = 108
|
||||
SUBTRACT = 109
|
||||
DECIMAL = 110
|
||||
DIVIDE = 111
|
||||
F1 = 112
|
||||
F2 = 113
|
||||
F3 = 114
|
||||
F4 = 115
|
||||
F5 = 116
|
||||
F6 = 117
|
||||
F7 = 118
|
||||
F8 = 119
|
||||
F9 = 120
|
||||
F10 = 121
|
||||
F11 = 122
|
||||
F12 = 123
|
||||
F13 = 124
|
||||
F14 = 125
|
||||
F15 = 126
|
||||
F16 = 127
|
||||
F17 = 128
|
||||
F18 = 129
|
||||
F19 = 130
|
||||
F20 = 131
|
||||
F21 = 132
|
||||
F22 = 133
|
||||
F23 = 134
|
||||
F24 = 135
|
||||
NUMLOCK = 144
|
||||
SCROLL = 145
|
||||
LSHIFT = 160
|
||||
RSHIFT = 161
|
||||
LCONTROL = 162
|
||||
RCONTROL = 163
|
||||
LMENU = 164
|
||||
RMENU = 165
|
||||
PROCESSKEY = 229
|
||||
ATTN = 246
|
||||
CRSEL = 247
|
||||
EXSEL = 248
|
||||
EREOF = 249
|
||||
PLAY = 250
|
||||
ZOOM = 251
|
||||
NONAME = 252
|
||||
PA1 = 253
|
||||
OEM_CLEAR = 254
|
||||
XBUTTON1 = 0x05
|
||||
XBUTTON2 = 0x06
|
||||
VOLUME_MUTE = 0xAD
|
||||
VOLUME_DOWN = 0xAE
|
||||
VOLUME_UP = 0xAF
|
||||
MEDIA_NEXT_TRACK = 0xB0
|
||||
MEDIA_PREV_TRACK = 0xB1
|
||||
MEDIA_PLAY_PAUSE = 0xB3
|
||||
BROWSER_BACK = 0xA6
|
||||
BROWSER_FORWARD = 0xA7
|
||||
|
||||
def getPressState(key):
|
||||
v = windll.user32.GetAsyncKeyState(int(key))
|
||||
return bool(0x8000 & v), bool(0x0001 & v)
|
||||
|
||||
def isPressedNow(key):
|
||||
return bool(0x8000 & windll.user32.GetAsyncKeyState(int(key)))
|
||||
|
||||
def wasPressedSinceLast(key):
|
||||
return bool(0x0001 & windll.user32.GetAsyncKeyState(int(key)))
|
||||
|
||||
def clearPressBuffer(key):
|
||||
while wasPressedSinceLast(key):
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
from time import sleep
|
||||
print("Press ESC to exit. Testing spacebar.")
|
||||
while True:
|
||||
if wasPressedSinceLast(ESCAPE):
|
||||
print("Done")
|
||||
break
|
||||
now,last = getPressState(ord(' '))
|
||||
if now or last:
|
||||
print now, last
|
||||
sleep(0.01)
|
||||
|
0
raspberryjammod/mcpipy/interpreter.py
Normal file → Executable file
0
raspberryjammod/mcpipy/interpreter.py
Normal file → Executable file
0
raspberryjammod/mcpipy/jjinux_sierpinski_triangle.py
Executable file → Normal file
0
raspberryjammod/mcpipy/jjinux_sierpinski_triangle.py
Executable file → Normal file
@ -23,5 +23,5 @@ while t < 2*pi:
|
||||
z = z0+int( scale * sin(5*t) )
|
||||
if (x,y,z) not in done:
|
||||
mc.setBlock(x,y,z,GOLD_BLOCK)
|
||||
done[x,y,z] = GOLD_BLOCK
|
||||
done.add((x,y,z))
|
||||
t += 2*pi / 10000
|
||||
|
0
raspberryjammod/mcpipy/lforest.py
Normal file → Executable file
0
raspberryjammod/mcpipy/lforest.py
Normal file → Executable file
0
raspberryjammod/mcpipy/lsystem.py
Normal file → Executable file
0
raspberryjammod/mcpipy/lsystem.py
Normal file → Executable file
0
raspberryjammod/mcpipy/ltree.py
Normal file → Executable file
0
raspberryjammod/mcpipy/ltree.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mandelbrot.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mandelbrot.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mandelbulb.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mandelbulb.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mc.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mc.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mcdragoncurve.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mcdragoncurve.py
Normal file → Executable file
@ -11,7 +11,10 @@ class Block:
|
||||
self.nbt = nbt
|
||||
|
||||
def __eq__(self, rhs):
|
||||
return self.id == rhs.id and self.data == rhs.data and self.nbt == rhs.nbt
|
||||
try:
|
||||
return self.id == rhs.id and self.data == rhs.data and self.nbt == rhs.nbt
|
||||
except:
|
||||
return self.data == 0 and self.nbt is None and self.id == rhs
|
||||
|
||||
def __ne__(self, rhs):
|
||||
return not self.__eq__(rhs)
|
||||
|
@ -1,9 +1,12 @@
|
||||
|
||||
import socket
|
||||
import select
|
||||
import sys
|
||||
import atexit
|
||||
import os
|
||||
import platform
|
||||
import base64
|
||||
from hashlib import md5
|
||||
from util import flatten_parameters_to_string
|
||||
|
||||
""" @author: Aron Nieminen, Mojang AB"""
|
||||
@ -16,6 +19,7 @@ class Connection:
|
||||
RequestFailed = "Fail"
|
||||
|
||||
def __init__(self, address=None, port=None):
|
||||
self.windows = (platform.system() == "Windows" or platform.system().startswith("CYGWIN_NT"))
|
||||
if address==None:
|
||||
try:
|
||||
address = os.environ['MINECRAFT_API_HOST']
|
||||
@ -33,11 +37,11 @@ class Connection:
|
||||
self.socket.connect((address, port))
|
||||
self.readFile = self.socket.makefile("r")
|
||||
self.lastSent = ""
|
||||
if platform.system() == "Windows":
|
||||
if self.windows:
|
||||
atexit.register(self.close)
|
||||
|
||||
def __del__(self):
|
||||
if platform.system() == "Windows":
|
||||
if self.windows:
|
||||
self.close()
|
||||
try:
|
||||
atexit.unregister(self.close)
|
||||
@ -46,13 +50,26 @@ class Connection:
|
||||
|
||||
def close(self):
|
||||
try:
|
||||
self.readFile.close()
|
||||
if self.windows:
|
||||
# ugly hack to block until all sending is completed
|
||||
self.sendReceive("world.getBlock",0,0,0)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
self.socket.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def tohex(data):
|
||||
return "".join((hex(b) for b in data))
|
||||
|
||||
def authenticate(self, username, password):
|
||||
challenge = self.sendReceive("world.getBlock",0,0,0)
|
||||
if challenge.startswith("security.challenge "):
|
||||
salt = challenge[19:].rstrip()
|
||||
auth = md5(salt+":"+username+":"+password).hexdigest()
|
||||
self.send("security.authenticate", auth)
|
||||
|
||||
def drain(self):
|
||||
"""Drains the socket of incoming data"""
|
||||
|
0
raspberryjammod/mcpipy/mcpi/entity.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mcpi/entity.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mcpi/minecraft-pi-edition-LICENSE.txt
Normal file → Executable file
0
raspberryjammod/mcpipy/mcpi/minecraft-pi-edition-LICENSE.txt
Normal file → Executable file
@ -5,6 +5,7 @@ from block import Block
|
||||
import math
|
||||
from os import environ
|
||||
from util import flatten,floorFlatten
|
||||
import security
|
||||
|
||||
""" Minecraft PI low level api v0.1_1
|
||||
|
||||
@ -185,16 +186,34 @@ class Minecraft:
|
||||
else:
|
||||
self.conn = Connection()
|
||||
|
||||
if security.AUTHENTICATION_USERNAME and security.AUTHENTICATION_PASSWORD:
|
||||
self.conn.authenticate(security.AUTHENTICATION_USERNAME, security.AUTHENTICATION_PASSWORD)
|
||||
|
||||
self.camera = CmdCamera(self.conn)
|
||||
self.entity = CmdEntity(self.conn)
|
||||
|
||||
self.playerId = None
|
||||
|
||||
if autoId:
|
||||
try:
|
||||
playerId = int(environ['MINECRAFT_PLAYER_ID'])
|
||||
self.player = CmdPlayer(self.conn,playerId=playerId)
|
||||
self.playerId = int(environ['MINECRAFT_PLAYER_ID'])
|
||||
self.player = CmdPlayer(self.conn,playerId=self.playerId)
|
||||
except:
|
||||
self.player = CmdPlayer(self.conn)
|
||||
try:
|
||||
self.playerId = self.getPlayerId(environ['MINECRAFT_PLAYER_NAME'])
|
||||
self.player = CmdPlayer(self.conn,playerId=self.playerId)
|
||||
except:
|
||||
if security.AUTHENTICATION_USERNAME:
|
||||
try:
|
||||
self.playerId = self.getPlayerId(security.AUTHENTICATION_USERNAME)
|
||||
self.player = CmdPlayer(self.conn,playerId=self.playerId)
|
||||
except:
|
||||
self.player = CmdPlayer(self.conn)
|
||||
else:
|
||||
self.player = CmdPlayer(self.conn)
|
||||
else:
|
||||
self.player = CmdPlayer(self.conn)
|
||||
|
||||
self.events = CmdEvents(self.conn)
|
||||
self.enabledNBT = False
|
||||
|
||||
@ -320,7 +339,11 @@ class Minecraft:
|
||||
|
||||
def getPlayerId(self, *args):
|
||||
"""Get the id of the current player"""
|
||||
return int(self.conn.sendReceive_flat("world.getPlayerId", floorFlatten(args)))
|
||||
a = tuple(flatten(args))
|
||||
if self.playerId is not None and len(a) == 0:
|
||||
return self.playerId
|
||||
else:
|
||||
return int(self.conn.sendReceive_flat("world.getPlayerId", flatten(args)))
|
||||
|
||||
def getPlayerEntityIds(self):
|
||||
"""Get the entity ids of the connected players => [id:int]"""
|
||||
|
2
raspberryjammod/mcpipy/mcpi/security.py
Normal file
2
raspberryjammod/mcpipy/mcpi/security.py
Normal file
@ -0,0 +1,2 @@
|
||||
AUTHENTICATION_USERNAME=None
|
||||
AUTHENTICATION_PASSWORD=None
|
0
raspberryjammod/mcpipy/mcpi/settings.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mcpi/settings.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mcpipy.pyproj
Normal file → Executable file
0
raspberryjammod/mcpipy/mcpipy.pyproj
Normal file → Executable file
0
raspberryjammod/mcpipy/mcpipy.sln
Normal file → Executable file
0
raspberryjammod/mcpipy/mcpipy.sln
Normal file → Executable file
0
raspberryjammod/mcpipy/mcturtle.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mcturtle.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mengersponge.py
Normal file → Executable file
0
raspberryjammod/mcpipy/mengersponge.py
Normal file → Executable file
@ -1,190 +1,356 @@
|
||||
#
|
||||
# requires Windows and pywin32
|
||||
# requires Windows (for input.py to work)
|
||||
# Copyright (c) 2016 Alexander Pruss. MIT License.
|
||||
#
|
||||
|
||||
#
|
||||
# Make sure to have input.py and text.py in the same directory.
|
||||
#
|
||||
|
||||
|
||||
from mc import *
|
||||
from time import sleep,time
|
||||
from random import randint
|
||||
import win32con,win32api
|
||||
import input
|
||||
import text
|
||||
from fonts import FONTS
|
||||
|
||||
HEIGHT = 22
|
||||
WIDTH = 9
|
||||
FONT = 'thin9pt' #metrix7pt
|
||||
HEIGHT = 20
|
||||
WIDTH = 10
|
||||
BORDER = WOOL_BLACK
|
||||
BACKGROUND = STAINED_GLASS_BLACK
|
||||
|
||||
DELAYS = ( 0.5, 0.45, 0.4, 0.35, 0.3, 0.25, 0.2, 0.15, 0.1, 0.05)
|
||||
|
||||
PIECES = ( (('XXXX',), ('.X','.X','.X','.X')),
|
||||
(('XX','XX'),),
|
||||
(('XXX', '..X'), ('.X', '.X', 'XX'), ('X','XXX'), ('XX', 'X', 'X')),
|
||||
(('XXX', 'X'), ('XX', '.X', '.X'), ('..X', 'XXX'), ('X.', 'X.', 'XX')),
|
||||
(('XX', '.XX'), ('.X','XX', 'X.')),
|
||||
(('.XX', 'XX'), ('X.', 'XX', '.X')) )
|
||||
(('XX','XX'),),
|
||||
(('XXX', '..X'), ('.X', '.X', 'XX'), ('X','XXX'), ('XX', 'X', 'X')),
|
||||
(('XXX', 'X'), ('XX', '.X', '.X'), ('..X', 'XXX'), ('X.', 'X.', 'XX')),
|
||||
(('XX', '.XX'), ('.X','XX', 'X.')),
|
||||
(('.XX', 'XX'), ('X.', 'XX', '.X')) )
|
||||
|
||||
def inputMoveDown():
|
||||
return input.wasPressedSinceLast(input.DOWN)
|
||||
|
||||
def inputMoveLeft():
|
||||
return input.wasPressedSinceLast(input.LEFT)
|
||||
|
||||
def inputMoveRight():
|
||||
return input.wasPressedSinceLast(input.RIGHT)
|
||||
|
||||
def inputRotateLeft():
|
||||
return input.wasPressedSinceLast(input.PRIOR)
|
||||
|
||||
def inputRotateRight():
|
||||
return input.wasPressedSinceLast(input.NEXT)
|
||||
|
||||
def inputNext():
|
||||
return input.wasPressedSinceLast(ord('N'))
|
||||
|
||||
def inputLevelUp():
|
||||
return input.wasPressedSinceLast(ord('L'))
|
||||
|
||||
def inputPause():
|
||||
return input.wasPressedSinceLast(ord('P'))
|
||||
|
||||
def answerYes():
|
||||
input.clearPressBuffer(ord('Y'))
|
||||
input.clearPressBuffer(ord('N'))
|
||||
while True:
|
||||
if input.wasPressedSinceLast(ord('Y')):
|
||||
return True
|
||||
if input.wasPressedSinceLast(ord('N')):
|
||||
return False
|
||||
sleep(0.1)
|
||||
|
||||
def clearInput():
|
||||
for k in (input.DOWN, input.LEFT, input.RIGHT,
|
||||
input.PRIOR, input.NEXT, input.UP,
|
||||
ord('N'), ord('L'), ord('P'), ord('Y')):
|
||||
input.clearPressBuffer(k)
|
||||
|
||||
def drawBoard():
|
||||
mc.setBlocks(left-1, bottom-1, plane, left+WIDTH, bottom-1, plane, BORDER)
|
||||
mc.setBlocks(left-1, bottom+HEIGHT, plane, left+WIDTH, bottom+HEIGHT, plane, BORDER)
|
||||
mc.setBlocks(left-1, bottom, plane, left, bottom+HEIGHT-1, plane, BORDER)
|
||||
mc.setBlocks(left+WIDTH, bottom, plane, left+WIDTH, bottom+HEIGHT-1, plane, BORDER)
|
||||
mc.setBlocks(left-1, bottom-1, plane-1, left+WIDTH, bottom+HEIGHT, plane-1, BACKGROUND)
|
||||
mc.setBlocks(left, bottom, plane, left+WIDTH-1, bottom+HEIGHT-1, plane, AIR)
|
||||
|
||||
mc.setBlocks(left-1, bottom-1, plane, left+WIDTH, bottom-1, plane, BORDER)
|
||||
mc.setBlocks(left-1, bottom+HEIGHT, plane, left+WIDTH, bottom+HEIGHT, plane, BORDER)
|
||||
mc.setBlocks(left-1, bottom, plane, left, bottom+HEIGHT-1, plane, BORDER)
|
||||
mc.setBlocks(left+WIDTH, bottom, plane, left+WIDTH, bottom+HEIGHT-1, plane, BORDER)
|
||||
mc.setBlocks(left-1, bottom-1, plane-1, left+WIDTH, bottom+HEIGHT, plane-1, BACKGROUND)
|
||||
mc.setBlocks(left, bottom, plane, left+WIDTH-1, bottom+HEIGHT-1, plane, AIR)
|
||||
|
||||
def pieceWidth(piece):
|
||||
return max((len(a) for a in piece[orientation]))
|
||||
|
||||
return max((len(a) for a in piece))
|
||||
|
||||
def enumeratePiece(x, y, piece):
|
||||
for row in range(len(piece)):
|
||||
for col in range(len(piece[row])):
|
||||
if piece[row][col] == 'X':
|
||||
yield (x+col,y-row)
|
||||
|
||||
def erasePiece(buffer, x, y, piece):
|
||||
for (xx,yy) in enumeratePiece(x,y, piece):
|
||||
buffer[(left+xx,bottom+yy)] = AIR
|
||||
for row in range(len(piece)):
|
||||
if y-row < HEIGHT:
|
||||
for col in range(len(piece[row])):
|
||||
if piece[row][col] == 'X':
|
||||
yield (x+col,y-row)
|
||||
|
||||
def drawPiece(buffer, x, y, piece, color):
|
||||
for (xx,yy) in enumeratePiece(x,y, piece):
|
||||
if (left+xx,bottom+yy) in buffer and buffer[(left+xx,bottom+yy)] == AIR:
|
||||
del buffer[(left+xx,bottom+yy)]
|
||||
else:
|
||||
buffer[(left+xx,bottom+yy)] = color
|
||||
|
||||
def movePiece(oldX, oldY, oldPiece, x, y, piece, color):
|
||||
new = set(enumeratePiece(x, y, piece))
|
||||
if oldPiece:
|
||||
old = set(enumeratePiece(oldX, oldY, oldPiece))
|
||||
|
||||
for (x,y) in old-new:
|
||||
mc.setBlock(x+left, y+bottom, plane, AIR)
|
||||
|
||||
new = new - old
|
||||
|
||||
for (x,y) in new:
|
||||
mc.setBlock(x+left, y+bottom, plane, color)
|
||||
|
||||
def eraseNext():
|
||||
mc.setBlocks(left+WIDTH+2,bottom+3,plane,left+WIDTH+2+3,bottom+6,plane,AIR)
|
||||
|
||||
def drawNext():
|
||||
eraseNext()
|
||||
for (x,y) in enumeratePiece(WIDTH+2, 6, nextFamily[nextOrientation]):
|
||||
mc.setBlock(x+left, y+bottom, plane, nextColor)
|
||||
|
||||
def drawBuffer(buffer):
|
||||
for x,y in buffer:
|
||||
mc.setBlock(x,y,plane,buffer[(x,y)])
|
||||
for x,y in buffer:
|
||||
mc.setBlock(x,y,plane,buffer[(x,y)])
|
||||
|
||||
def makeNext():
|
||||
global nextFamily, nextColor, nextOrientation
|
||||
n = randint(0, len(PIECES)-1)
|
||||
nextFamily = PIECES[n]
|
||||
nextColor = Block(WOOL.id, (n+1) % 16)
|
||||
nextOrientation = randint(0, len(nextFamily)-1)
|
||||
|
||||
def placePiece():
|
||||
global pieceNum, color, family, orientation, x, y, fall, descendDelay
|
||||
pieceNum = randint(0, len(PIECES)-1)
|
||||
color = Block(WOOL.id, (pieceNum+1) % 16)
|
||||
family = PIECES[pieceNum]
|
||||
orientation = 0
|
||||
x = WIDTH // 2 - pieceWidth(family[orientation])
|
||||
y = HEIGHT - 1
|
||||
descendDelay = currentDescendDelay
|
||||
fall = False
|
||||
|
||||
global color, family, orientation, descendDelay, droppedFrom, didShowNext
|
||||
family = nextFamily
|
||||
orientation = nextOrientation
|
||||
color = nextColor
|
||||
makeNext()
|
||||
piece = family[orientation]
|
||||
x = WIDTH // 2 - pieceWidth(piece)
|
||||
y = HEIGHT + len(piece) - 2
|
||||
descendDelay = currentDescendDelay
|
||||
droppedFrom = None
|
||||
didShowNext = showNext
|
||||
if showNext:
|
||||
drawNext()
|
||||
return (x,y)
|
||||
|
||||
def fit(x, y, piece):
|
||||
for (xx,yy) in enumeratePiece(x, y, piece):
|
||||
if yy >= HEIGHT or yy < 0 or xx >= WIDTH or xx < 0 or board[xx][yy] is not None:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
for (xx,yy) in enumeratePiece(x, y, piece):
|
||||
if yy < 0 or xx >= WIDTH or xx < 0 or board[xx][yy] is not None:
|
||||
return False
|
||||
return True
|
||||
|
||||
def descend():
|
||||
global descendTimer
|
||||
if descendTimer + descendDelay <= time():
|
||||
descendTimer += descendDelay
|
||||
return True
|
||||
return False
|
||||
|
||||
def moveDown():
|
||||
return (win32api.GetAsyncKeyState(win32con.VK_DOWN)&1)
|
||||
|
||||
def moveLeft():
|
||||
return (win32api.GetAsyncKeyState(win32con.VK_LEFT)&1)
|
||||
|
||||
def moveRight():
|
||||
return (win32api.GetAsyncKeyState(win32con.VK_RIGHT)&1)
|
||||
global descendTimer
|
||||
if descendTimer + descendDelay <= time():
|
||||
descendTimer += descendDelay
|
||||
return True
|
||||
return False
|
||||
|
||||
def rotateLeft():
|
||||
return (win32api.GetAsyncKeyState(win32con.VK_PRIOR)&1)
|
||||
|
||||
def rotateRight():
|
||||
return (win32api.GetAsyncKeyState(win32con.VK_NEXT)&1) or (win32api.GetAsyncKeyState(win32con.VK_UP)&1)
|
||||
|
||||
def hide():
|
||||
mc.setBlocks(left, bottom, plane, left+WIDTH-1, bottom+HEIGHT-1, plane, GLASS)
|
||||
text.drawText(mc, FONTS['nicefontbold'],
|
||||
Vec3(left+WIDTH//2,bottom+5,plane),
|
||||
Vec3(1,0,0), Vec3(0,1,0),
|
||||
"P", SEA_LANTERN, align=text.ALIGN_CENTER)
|
||||
|
||||
|
||||
def restore(x, y):
|
||||
for xx in range(WIDTH):
|
||||
for yy in range(HEIGHT):
|
||||
mc.setBlock(xx+left,yy+bottom,plane,board[xx][yy] or AIR)
|
||||
movePiece(None, None, None, x, y, family[orientation], color)
|
||||
|
||||
def addPiece(x, y, piece, color):
|
||||
for (xx,yy) in enumeratePiece(x, y, piece):
|
||||
board[xx][yy] = color
|
||||
while True:
|
||||
foundRow = False
|
||||
for y in range(HEIGHT):
|
||||
full = True
|
||||
for x in range(WIDTH):
|
||||
if board[x][y] is None:
|
||||
full = False
|
||||
break
|
||||
if full:
|
||||
foundRow = True
|
||||
for y2 in range(y, HEIGHT-1):
|
||||
for x in range(WIDTH):
|
||||
b = board[x][y2+1]
|
||||
board[x][y2] = b
|
||||
mc.setBlock(left+x,bottom+y2,plane,b if b is not None else AIR)
|
||||
for x in range(WIDTH):
|
||||
board[x][HEIGHT-1] = None
|
||||
mc.setBlock(left+x,bottom+HEIGHT-1,plane,AIR)
|
||||
|
||||
if not foundRow:
|
||||
break
|
||||
global score,level,totalDropped
|
||||
|
||||
for (xx,yy) in enumeratePiece(x, y, piece):
|
||||
board[xx][yy] = color
|
||||
|
||||
dropCount = 0
|
||||
while True:
|
||||
foundRow = False
|
||||
for y in range(HEIGHT):
|
||||
full = True
|
||||
for x in range(WIDTH):
|
||||
if board[x][y] is None:
|
||||
full = False
|
||||
break
|
||||
if full:
|
||||
dropCount += 1
|
||||
foundRow = True
|
||||
for y2 in range(y, HEIGHT-1):
|
||||
for x in range(WIDTH):
|
||||
b = board[x][y2+1]
|
||||
board[x][y2] = b
|
||||
mc.setBlock(left+x,bottom+y2,plane,b if b is not None else AIR)
|
||||
for x in range(WIDTH):
|
||||
board[x][HEIGHT-1] = None
|
||||
mc.setBlock(left+x,bottom+HEIGHT-1,plane,AIR)
|
||||
|
||||
if not foundRow:
|
||||
break
|
||||
|
||||
if didShowNext:
|
||||
score += 3 + (3*(level-1))//2 + droppedFrom
|
||||
else:
|
||||
score += 5 + 2*(level-1) + droppedFrom
|
||||
if dropCount:
|
||||
totalDropped += dropCount
|
||||
level = 1 + totalDropped // 10 + extraLevels
|
||||
updateScoreAndLevel()
|
||||
|
||||
def updateText(buffer,x,y,s,align):
|
||||
newBuffer = {}
|
||||
if s is not None:
|
||||
text.drawText(mc, FONTS['thin9pt'],
|
||||
Vec3(x,y,plane),
|
||||
Vec3(1,0,0), Vec3(0,1,0),
|
||||
s, SEA_LANTERN, background=None, align=align, buffer=newBuffer)
|
||||
for pos in buffer:
|
||||
if pos not in newBuffer:
|
||||
mc.setBlock(pos, AIR)
|
||||
for pos in newBuffer:
|
||||
if pos not in buffer:
|
||||
mc.setBlock(pos, SEA_LANTERN)
|
||||
return newBuffer
|
||||
|
||||
def updateScoreAndLevel():
|
||||
global scoreBuffer, levelBuffer, currentDescendDelay, level
|
||||
if level > 10:
|
||||
level = 10
|
||||
scoreBuffer = updateText(scoreBuffer,left+WIDTH+2,bottom+HEIGHT-10,str(score),text.ALIGN_LEFT)
|
||||
levelBuffer = updateText(levelBuffer,left-1,bottom+HEIGHT-10,str(level),text.ALIGN_RIGHT)
|
||||
currentDescendDelay = DELAYS[level-1]
|
||||
|
||||
def clearScoreAndLevel():
|
||||
global scoreBuffer, levelBuffer, currentDescendDelay, level
|
||||
scoreBuffer = updateText(scoreBuffer,left+WIDTH+2,bottom+HEIGHT-10,None,text.ALIGN_LEFT)
|
||||
levelBuffer = updateText(levelBuffer,left-1,bottom+HEIGHT-10,None,text.ALIGN_RIGHT)
|
||||
|
||||
def game():
|
||||
global score, level, extraLevels, totalDropped, scoreBuffer, levelBuffer, showNext, didShowNext
|
||||
global orientation, board, descendTimer, droppedFrom, descendDelay
|
||||
|
||||
board = [[None for i in range(HEIGHT)] for j in range(WIDTH)]
|
||||
|
||||
drawBoard()
|
||||
score = 0
|
||||
level = 1
|
||||
extraLevels = 0
|
||||
totalDropped = 0
|
||||
scoreBuffer = {}
|
||||
levelBuffer = {}
|
||||
showNext = False
|
||||
updateScoreAndLevel()
|
||||
makeNext()
|
||||
|
||||
newPiece = True
|
||||
|
||||
while True:
|
||||
if newPiece:
|
||||
x,y = placePiece()
|
||||
oldPiece = None
|
||||
if not fit(x, y, family[orientation]):
|
||||
break
|
||||
draw = True
|
||||
newPiece = False
|
||||
fall = False
|
||||
clearInput()
|
||||
descendTimer = time()
|
||||
else:
|
||||
oldPiece = family[orientation]
|
||||
draw = False
|
||||
oldX = x
|
||||
oldY = y
|
||||
|
||||
if inputPause():
|
||||
t0 = time()
|
||||
hide()
|
||||
while not inputPause():
|
||||
sleep(0.025)
|
||||
clearInput()
|
||||
restore(x, y)
|
||||
descendTimer += time() - t0
|
||||
|
||||
if not fall:
|
||||
if inputLevelUp():
|
||||
extraLevels += 1
|
||||
level += 1
|
||||
updateScoreAndLevel()
|
||||
descendDelay = currentDescendDelay
|
||||
|
||||
if inputMoveLeft() and fit(x-1, y, family[orientation]):
|
||||
x -= 1
|
||||
draw = True
|
||||
|
||||
if inputMoveRight() and fit(x+1, y, family[orientation]):
|
||||
x += 1
|
||||
draw = True
|
||||
|
||||
if inputRotateLeft() and fit(x, y, family[(orientation-1)%len(family)]):
|
||||
orientation = (orientation-1)%len(family)
|
||||
draw = True
|
||||
|
||||
if inputRotateRight() and fit(x, y, family[(orientation+1)%len(family)]):
|
||||
orientation = (orientation+1)%len(family)
|
||||
draw = True
|
||||
|
||||
if inputMoveDown():
|
||||
fall = True
|
||||
droppedFrom = y+1-len(family[orientation])
|
||||
descendDelay = 0.05
|
||||
|
||||
if inputNext():
|
||||
showNext = not showNext
|
||||
if showNext:
|
||||
didShowNext = True
|
||||
drawNext()
|
||||
else:
|
||||
eraseNext()
|
||||
|
||||
if descend():
|
||||
if not fit(x, y-1, family[orientation]):
|
||||
if droppedFrom is None:
|
||||
droppedFrom = y+1-len(family[orientation])
|
||||
addPiece(x, y, family[orientation], color)
|
||||
newPiece = True
|
||||
else:
|
||||
draw = True
|
||||
y -= 1
|
||||
|
||||
if draw:
|
||||
movePiece(oldX, oldY, oldPiece, x, y, family[orientation], color)
|
||||
|
||||
sleep(0.025)
|
||||
|
||||
return score
|
||||
|
||||
mc = Minecraft()
|
||||
|
||||
mc.postToChat("Left/Right arrow: move")
|
||||
mc.postToChat("Up: rotate right")
|
||||
mc.postToChat("PageUp/PageDown: rotate left/right")
|
||||
mc.postToChat("N: toggle view next")
|
||||
mc.postToChat("P: pause")
|
||||
mc.postToChat("L: next level")
|
||||
|
||||
playerPos = mc.player.getTilePos()
|
||||
mc.player.setRotation(180)
|
||||
mc.player.setPitch(-30)
|
||||
mc.player.setTilePos(playerPos.x, playerPos.y, playerPos.z + 10)
|
||||
mc.player.setPitch(-26)
|
||||
mc.player.setTilePos(playerPos.x, playerPos.y, playerPos.z + 14)
|
||||
|
||||
left = playerPos.x - WIDTH // 2
|
||||
plane = playerPos.z
|
||||
bottom = playerPos.y + 1
|
||||
board = [[None for i in range(HEIGHT)] for j in range(WIDTH)]
|
||||
currentDescendDelay = 0.5
|
||||
|
||||
drawBoard()
|
||||
|
||||
newPiece = True
|
||||
|
||||
while True:
|
||||
if newPiece:
|
||||
placePiece()
|
||||
oldPiece = None
|
||||
if not fit(x, y, family[orientation]):
|
||||
mc.postToChat("Doesn't fit: End of game")
|
||||
print "no fit"
|
||||
break
|
||||
draw = True
|
||||
newPiece = False
|
||||
descendTimer = time()
|
||||
else:
|
||||
oldPiece = family[orientation]
|
||||
draw = False
|
||||
oldX = x
|
||||
oldY = y
|
||||
|
||||
if not fall:
|
||||
if moveLeft() and fit(x-1, y, family[orientation]):
|
||||
x -= 1
|
||||
draw = True
|
||||
|
||||
if moveRight() and fit(x+1, y, family[orientation]):
|
||||
x += 1
|
||||
draw = True
|
||||
|
||||
if rotateLeft() and fit(x, y, family[(orientation-1)%len(family)]):
|
||||
orientation = (orientation-1)%len(family)
|
||||
draw = True
|
||||
|
||||
if rotateRight() and fit(x, y, family[(orientation+1)%len(family)]):
|
||||
orientation = (orientation+1)%len(family)
|
||||
draw = True
|
||||
|
||||
if moveDown():
|
||||
fall = True
|
||||
descendDelay = 0.05
|
||||
|
||||
if descend():
|
||||
if not fit(x, y-1, family[orientation]):
|
||||
addPiece(x, y, family[orientation], color)
|
||||
newPiece = True
|
||||
else:
|
||||
draw = True
|
||||
y -= 1
|
||||
|
||||
if draw:
|
||||
buffer = {}
|
||||
if oldPiece:
|
||||
erasePiece(buffer, oldX, oldY, oldPiece)
|
||||
drawPiece(buffer, x, y, family[orientation], color)
|
||||
drawBuffer(buffer)
|
||||
|
||||
sleep(0.1)
|
||||
|
||||
print "done"
|
||||
s = game()
|
||||
mc.postToChat("Game Over: You got %d points" % s)
|
||||
mc.postToChat("Play again? (Y/N)")
|
||||
if not answerYes():
|
||||
mc.postToChat("Goodbye!")
|
||||
break
|
||||
clearScoreAndLevel()
|
0
raspberryjammod/mcpipy/models/dragon.txt
Normal file → Executable file
0
raspberryjammod/mcpipy/models/dragon.txt
Normal file → Executable file
17
raspberryjammod/mcpipy/models/knight.txt
Normal file
17
raspberryjammod/mcpipy/models/knight.txt
Normal file
@ -0,0 +1,17 @@
|
||||
file 'knight.stl'
|
||||
swapyz 1
|
||||
urlgz https://raw.githubusercontent.com/arpruss/raspberryjammod/master/models/knight.stl.gz
|
||||
credits Knight from Chess - Classic Set by SteedMaker. CC Attribution Share Alike 3.0
|
||||
yaw 0
|
||||
pitch 0
|
||||
roll 0
|
||||
size 100
|
||||
default STAINED_GLASS_BLUE
|
||||
#order material position
|
||||
materials
|
||||
end
|
||||
|
||||
Knight from Chess - Classic Set by SteedMaker.
|
||||
http://www.thingiverse.com/thing:34017
|
||||
licensed under the Creative Commons - Attribution - Share Alike license 3.0
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
0
raspberryjammod/mcpipy/nt7s_sphere.py
Executable file → Normal file
0
raspberryjammod/mcpipy/nt7s_sphere.py
Executable file → Normal file
@ -1,86 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import mcpi.minecraft as minecraft
|
||||
import mcpi.block as block
|
||||
import time
|
||||
import server
|
||||
|
||||
|
||||
#Author: Obsidz
|
||||
#
|
||||
#Description: This is a teleport pad script.
|
||||
# To create a pad, place a nether reactor core onto a location and ring with cobbledtone blocks
|
||||
# To add to locations list walk over it
|
||||
#
|
||||
#Notes: Pads added to list by walking over them
|
||||
# Pads not removed if destroyed but can be teleported to but not from
|
||||
# You cannot teleport to the same pad without modifying script
|
||||
# Pads need to be added each time the script is run
|
||||
|
||||
# modified version - as shared on mcpipy.com
|
||||
# original post @ http://www.minecraftforum.net/topic/1691618-teleportation-python-script/
|
||||
|
||||
LPLoc = list()
|
||||
|
||||
Pads = 0
|
||||
Cpad = 0
|
||||
|
||||
# If you are running this script with the bukkit mod, then use a diamond block as the magic center block for teleporting
|
||||
# comment/uncomment below as appropriate
|
||||
magic_block = block.DIAMOND_BLOCK.id # for bukkit server
|
||||
#magic_block = block.NETHER_REACTOR_CORE.id # for raspberry pi
|
||||
|
||||
def isLaunchPad(): #checks if the the location below the player is a teleporting pad
|
||||
loc = mc.player.getPos()
|
||||
if ((mc.getBlock(loc.x,loc.y-1,loc.z) == magic_block) and
|
||||
(mc.getBlock(loc.x-1,loc.y-1,loc.z-1) == block.COBBLESTONE.id) and
|
||||
(mc.getBlock(loc.x-1,loc.y-1,loc.z) == block.COBBLESTONE.id) and
|
||||
(mc.getBlock(loc.x-1,loc.y-1,loc.z+1) == block.COBBLESTONE.id) and
|
||||
(mc.getBlock(loc.x,loc.y-1,loc.z+1) == block.COBBLESTONE.id) and
|
||||
(mc.getBlock(loc.x,loc.y-1,loc.z-1) == block.COBBLESTONE.id) and
|
||||
(mc.getBlock(loc.x+1,loc.y-1,loc.z-1) == block.COBBLESTONE.id) and
|
||||
(mc.getBlock(loc.x+1,loc.y-1,loc.z) == block.COBBLESTONE.id) and
|
||||
(mc.getBlock(loc.x+1,loc.y-1,loc.z+1) == block.COBBLESTONE.id)):
|
||||
addLPLoc(loc)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
def addLPLoc(Vec3): #Loggs the location of the pad for future use
|
||||
global Pads
|
||||
global LPLoc
|
||||
|
||||
inList = False
|
||||
if Pads > 0:
|
||||
for loc in LPLoc:
|
||||
if (loc.x == Vec3.x and loc.y == Vec3.y and loc.z == Vec3.z):
|
||||
inList = True
|
||||
|
||||
if not inList:
|
||||
LPLoc.append(Vec3)
|
||||
mc.postToChat("I'll remember this pad location!")
|
||||
Pads = len(LPLoc)
|
||||
def locCheck(): #Checks that you are not teleporting to the same pad
|
||||
|
||||
global Cpad
|
||||
global LPLoc
|
||||
loc = mc.player.getPos()
|
||||
if (loc.x == LPLoc[Cpad].x and loc.y == LPLoc[Cpad].y and loc.z == LPLoc[Cpad].z):
|
||||
Cpad = Cpad + 1
|
||||
def TPChar(): #sends the character to the next pad
|
||||
global Pads
|
||||
global Cpad
|
||||
global LPLoc
|
||||
|
||||
if Pads > 1:
|
||||
mc.player.setPos(LPLoc[Cpad].x,LPLoc[Cpad].y + 1,LPLoc[Cpad].z)
|
||||
Cpad = ( Cpad + 1) % Pads
|
||||
time.sleep(3.0)
|
||||
|
||||
if __name__ == "__main__": # The script
|
||||
|
||||
mc = minecraft.Minecraft.create(server.address)
|
||||
while True:
|
||||
if isLaunchPad():
|
||||
TPChar()
|
||||
|
||||
time.sleep(0.1)
|
BIN
raspberryjammod/mcpipy/ovalegg.png
Normal file
BIN
raspberryjammod/mcpipy/ovalegg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 261 KiB |
0
raspberryjammod/mcpipy/polyhedron.py
Normal file → Executable file
0
raspberryjammod/mcpipy/polyhedron.py
Normal file → Executable file
@ -1,12 +0,0 @@
|
||||
from mc import *
|
||||
from random import choice,randint
|
||||
|
||||
mc = Minecraft()
|
||||
nodes = mc.conn.sendReceive("world.getAllNodes").split("|")
|
||||
pos = mc.player.getTilePos()
|
||||
|
||||
for i in range(1000):
|
||||
n = choice(nodes)
|
||||
if "lava" in n or "fire" in n or "water" in n: continue
|
||||
mc.conn.send("world.setNode", pos.x+randint(0,29), pos.y+randint(0,29),
|
||||
pos.z+randint(0,29), n)
|
166
raspberryjammod/mcpipy/render.py
Normal file → Executable file
166
raspberryjammod/mcpipy/render.py
Normal file → Executable file
@ -1,3 +1,4 @@
|
||||
|
||||
#www.stuffaboutcode.com
|
||||
#Raspberry Pi, Minecraft - Create 3D Model from Obj file
|
||||
# Version 2 - draws complete faces rather than wireframes and uses materials
|
||||
@ -24,7 +25,6 @@ SOFTWARE.
|
||||
"""
|
||||
|
||||
from zipfile import ZipFile
|
||||
from StringIO import StringIO
|
||||
import sys
|
||||
import urllib2
|
||||
import struct
|
||||
@ -47,51 +47,51 @@ import re
|
||||
IDENTITY44 = ((1.,0.,0.,0.),(0.,1.,0.,0.),(0.,0.,1.,0.),(0.,0.,0.,1.))
|
||||
|
||||
def determinant44(m):
|
||||
inv00=m[1][1]*m[2][2]*m[3][3]-m[1][1]*m[3][2]*m[2][3]-m[1][2]*m[2][1]*m[3][3]+m[1][2]*m[3][1]*m[2][3]+m[1][3]*m[2][1]*m[3][2]-m[1][3]*m[3][1]*m[2][2]
|
||||
inv01=-m[0][1]*m[2][2]*m[3][3]+m[0][1]*m[3][2]*m[2][3]+m[0][2]*m[2][1]*m[3][3]-m[0][2]*m[3][1]*m[2][3]-m[0][3]*m[2][1]*m[3][2]+m[0][3]*m[3][1]*m[2][2]
|
||||
inv02=m[0][1]*m[1][2]*m[3][3]-m[0][1]*m[3][2]*m[1][3]-m[0][2]*m[1][1]*m[3][3]+m[0][2]*m[3][1]*m[1][3]+m[0][3]*m[1][1]*m[3][2]-m[0][3]*m[3][1]*m[1][2]
|
||||
inv03=-m[0][1]*m[1][2]*m[2][3]+m[0][1]*m[2][2]*m[1][3]+m[0][2]*m[1][1]*m[2][3]-m[0][2]*m[2][1]*m[1][3]-m[0][3]*m[1][1]*m[2][2]+m[0][3]*m[2][1]*m[1][2]
|
||||
return m[0][0]*inv00 + m[1][0]*inv01 + m[2][0]*inv02 + m[3][0]*inv03
|
||||
inv00 = m[1][1] * m[2][2] * m[3][3] - m[1][1] * m[3][2] * m[2][3] - m[1][2] * m[2][1] * m[3][3] + m[1][2] * m[3][1] * m[2][3] + m[1][3] * m[2][1] * m[3][2] - m[1][3] * m[3][1] * m[2][2]
|
||||
inv01 = -m[0][1] * m[2][2] * m[3][3] + m[0][1] * m[3][2] * m[2][3] + m[0][2] * m[2][1] * m[3][3] - m[0][2] * m[3][1] * m[2][3] - m[0][3] * m[2][1] * m[3][2] + m[0][3] * m[3][1] * m[2][2]
|
||||
inv02 = m[0][1] * m[1][2] * m[3][3] - m[0][1] * m[3][2] * m[1][3] - m[0][2] * m[1][1] * m[3][3] + m[0][2] * m[3][1] * m[1][3] + m[0][3] * m[1][1] * m[3][2] - m[0][3] * m[3][1] * m[1][2]
|
||||
inv03 = -m[0][1] * m[1][2] * m[2][3] + m[0][1] * m[2][2] * m[1][3] + m[0][2] * m[1][1] * m[2][3] - m[0][2] * m[2][1] * m[1][3] - m[0][3] * m[1][1] * m[2][2] + m[0][3] * m[2][1] * m[1][2]
|
||||
return m[0][0] * inv00 + m[1][0] * inv01 + m[2][0] * inv02 + m[3][0] * inv03
|
||||
|
||||
def invertMatrix44(m):
|
||||
inv = [[0 for i in range(4)] for j in range(4)]
|
||||
|
||||
inv[0][0]=m[1][1]*m[2][2]*m[3][3]-m[1][1]*m[3][2]*m[2][3]-m[1][2]*m[2][1]*m[3][3]+m[1][2]*m[3][1]*m[2][3]+m[1][3]*m[2][1]*m[3][2]-m[1][3]*m[3][1]*m[2][2]
|
||||
inv[0][1]=-m[0][1]*m[2][2]*m[3][3]+m[0][1]*m[3][2]*m[2][3]+m[0][2]*m[2][1]*m[3][3]-m[0][2]*m[3][1]*m[2][3]-m[0][3]*m[2][1]*m[3][2]+m[0][3]*m[3][1]*m[2][2]
|
||||
inv[0][2]=m[0][1]*m[1][2]*m[3][3]-m[0][1]*m[3][2]*m[1][3]-m[0][2]*m[1][1]*m[3][3]+m[0][2]*m[3][1]*m[1][3]+m[0][3]*m[1][1]*m[3][2]-m[0][3]*m[3][1]*m[1][2]
|
||||
inv[0][3]=-m[0][1]*m[1][2]*m[2][3]+m[0][1]*m[2][2]*m[1][3]+m[0][2]*m[1][1]*m[2][3]-m[0][2]*m[2][1]*m[1][3]-m[0][3]*m[1][1]*m[2][2]+m[0][3]*m[2][1]*m[1][2]
|
||||
inv[0][0] = m[1][1] * m[2][2] * m[3][3] - m[1][1] * m[3][2] * m[2][3] - m[1][2] * m[2][1] * m[3][3] + m[1][2] * m[3][1] * m[2][3] + m[1][3] * m[2][1] * m[3][2] - m[1][3] * m[3][1] * m[2][2]
|
||||
inv[0][1] = -m[0][1] * m[2][2] * m[3][3] + m[0][1] * m[3][2] * m[2][3] + m[0][2] * m[2][1] * m[3][3] - m[0][2] * m[3][1] * m[2][3] - m[0][3] * m[2][1] * m[3][2] + m[0][3] * m[3][1] * m[2][2]
|
||||
inv[0][2] = m[0][1] * m[1][2] * m[3][3] - m[0][1] * m[3][2] * m[1][3] - m[0][2] * m[1][1] * m[3][3] + m[0][2] * m[3][1] * m[1][3] + m[0][3] * m[1][1] * m[3][2] - m[0][3] * m[3][1] * m[1][2]
|
||||
inv[0][3] = -m[0][1] * m[1][2] * m[2][3] + m[0][1] * m[2][2] * m[1][3] + m[0][2] * m[1][1] * m[2][3] - m[0][2] * m[2][1] * m[1][3] - m[0][3] * m[1][1] * m[2][2] + m[0][3] * m[2][1] * m[1][2]
|
||||
|
||||
inv[1][0]=-m[1][0]*m[2][2]*m[3][3]+m[1][0]*m[3][2]*m[2][3]+m[1][2]*m[2][0]*m[3][3]-m[1][2]*m[3][0]*m[2][3]-m[1][3]*m[2][0]*m[3][2]+m[1][3]*m[3][0]*m[2][2]
|
||||
inv[1][1]=m[0][0]*m[2][2]*m[3][3]-m[0][0]*m[3][2]*m[2][3]-m[0][2]*m[2][0]*m[3][3]+m[0][2]*m[3][0]*m[2][3]+m[0][3]*m[2][0]*m[3][2]-m[0][3]*m[3][0]*m[2][2]
|
||||
inv[1][2]=-m[0][0]*m[1][2]*m[3][3]+m[0][0]*m[3][2]*m[1][3]+m[0][2]*m[1][0]*m[3][3]-m[0][2]*m[3][0]*m[1][3]-m[0][3]*m[1][0]*m[3][2]+m[0][3]*m[3][0]*m[1][2]
|
||||
inv[1][3]=m[0][0]*m[1][2]*m[2][3]-m[0][0]*m[2][2]*m[1][3]-m[0][2]*m[1][0]*m[2][3]+m[0][2]*m[2][0]*m[1][3]+m[0][3]*m[1][0]*m[2][2]-m[0][3]*m[2][0]*m[1][2]
|
||||
inv[1][0] = -m[1][0] * m[2][2] * m[3][3] + m[1][0] * m[3][2] * m[2][3] + m[1][2] * m[2][0] * m[3][3] - m[1][2] * m[3][0] * m[2][3] - m[1][3] * m[2][0] * m[3][2] + m[1][3] * m[3][0] * m[2][2]
|
||||
inv[1][1] = m[0][0] * m[2][2] * m[3][3] - m[0][0] * m[3][2] * m[2][3] - m[0][2] * m[2][0] * m[3][3] + m[0][2] * m[3][0] * m[2][3] + m[0][3] * m[2][0] * m[3][2] - m[0][3] * m[3][0] * m[2][2]
|
||||
inv[1][2] = -m[0][0] * m[1][2] * m[3][3] + m[0][0] * m[3][2] * m[1][3] + m[0][2] * m[1][0] * m[3][3] - m[0][2] * m[3][0] * m[1][3] - m[0][3] * m[1][0] * m[3][2] + m[0][3] * m[3][0] * m[1][2]
|
||||
inv[1][3] = m[0][0] * m[1][2] * m[2][3] - m[0][0] * m[2][2] * m[1][3] - m[0][2] * m[1][0] * m[2][3] + m[0][2] * m[2][0] * m[1][3] + m[0][3] * m[1][0] * m[2][2] - m[0][3] * m[2][0] * m[1][2]
|
||||
|
||||
inv[2][0]=m[1][0]*m[2][1]*m[3][3]-m[1][0]*m[3][1]*m[2][3]-m[1][1]*m[2][0]*m[3][3]+m[1][1]*m[3][0]*m[2][3]+m[1][3]*m[2][0]*m[3][1]-m[1][3]*m[3][0]*m[2][1]
|
||||
inv[2][1]=-m[0][0]*m[2][1]*m[3][3]+m[0][0]*m[3][1]*m[2][3]+m[0][1]*m[2][0]*m[3][3]-m[0][1]*m[3][0]*m[2][3]-m[0][3]*m[2][0]*m[3][1]+m[0][3]*m[3][0]*m[2][1]
|
||||
inv[2][2]=m[0][0]*m[1][1]*m[3][3]-m[0][0]*m[3][1]*m[1][3]-m[0][1]*m[1][0]*m[3][3]+m[0][1]*m[3][0]*m[1][3]+m[0][3]*m[1][0]*m[3][1]-m[0][3]*m[3][0]*m[1][1]
|
||||
inv[2][3]=-m[0][0]*m[1][1]*m[2][3]+m[0][0]*m[2][1]*m[1][3]+m[0][1]*m[1][0]*m[2][3]-m[0][1]*m[2][0]*m[1][3]-m[0][3]*m[1][0]*m[2][1]+m[0][3]*m[2][0]*m[1][1]
|
||||
inv[2][0] = m[1][0] * m[2][1] * m[3][3] - m[1][0] * m[3][1] * m[2][3] - m[1][1] * m[2][0] * m[3][3] + m[1][1] * m[3][0] * m[2][3] + m[1][3] * m[2][0] * m[3][1] - m[1][3] * m[3][0] * m[2][1]
|
||||
inv[2][1] = -m[0][0] * m[2][1] * m[3][3] + m[0][0] * m[3][1] * m[2][3] + m[0][1] * m[2][0] * m[3][3] - m[0][1] * m[3][0] * m[2][3] - m[0][3] * m[2][0] * m[3][1] + m[0][3] * m[3][0] * m[2][1]
|
||||
inv[2][2] = m[0][0] * m[1][1] * m[3][3] - m[0][0] * m[3][1] * m[1][3] - m[0][1] * m[1][0] * m[3][3] + m[0][1] * m[3][0] * m[1][3] + m[0][3] * m[1][0] * m[3][1] - m[0][3] * m[3][0] * m[1][1]
|
||||
inv[2][3] = -m[0][0] * m[1][1] * m[2][3] + m[0][0] * m[2][1] * m[1][3] + m[0][1] * m[1][0] * m[2][3] - m[0][1] * m[2][0] * m[1][3] - m[0][3] * m[1][0] * m[2][1] + m[0][3] * m[2][0] * m[1][1]
|
||||
|
||||
inv[3][0]=-m[1][0]*m[2][1]*m[3][2]+m[1][0]*m[3][1]*m[2][2]+m[1][1]*m[2][0]*m[3][2]-m[1][1]*m[3][0]*m[2][2]-m[1][2]*m[2][0]*m[3][1]+m[1][2]*m[3][0]*m[2][1]
|
||||
inv[3][1]=m[0][0]*m[2][1]*m[3][2]-m[0][0]*m[3][1]*m[2][2]-m[0][1]*m[2][0]*m[3][2]+m[0][1]*m[3][0]*m[2][2]+m[0][2]*m[2][0]*m[3][1]-m[0][2]*m[3][0]*m[2][1]
|
||||
inv[3][2]=-m[0][0]*m[1][1]*m[3][2]+m[0][0]*m[3][1]*m[1][2]+m[0][1]*m[1][0]*m[3][2]-m[0][1]*m[3][0]*m[1][2]-m[0][2]*m[1][0]*m[3][1]+m[0][2]*m[3][0]*m[1][1]
|
||||
inv[3][3]=m[0][0]*m[1][1]*m[2][2]-m[0][0]*m[2][1]*m[1][2]-m[0][1]*m[1][0]*m[2][2]+m[0][1]*m[2][0]*m[1][2]+m[0][2]*m[1][0]*m[2][1]-m[0][2]*m[2][0]*m[1][1]
|
||||
inv[3][0] = -m[1][0] * m[2][1] * m[3][2] + m[1][0] * m[3][1] * m[2][2] + m[1][1] * m[2][0] * m[3][2] - m[1][1] * m[3][0] * m[2][2] - m[1][2] * m[2][0] * m[3][1] + m[1][2] * m[3][0] * m[2][1]
|
||||
inv[3][1] = m[0][0] * m[2][1] * m[3][2] - m[0][0] * m[3][1] * m[2][2] - m[0][1] * m[2][0] * m[3][2] + m[0][1] * m[3][0] * m[2][2] + m[0][2] * m[2][0] * m[3][1] - m[0][2] * m[3][0] * m[2][1]
|
||||
inv[3][2] = -m[0][0] * m[1][1] * m[3][2] + m[0][0] * m[3][1] * m[1][2] + m[0][1] * m[1][0] * m[3][2] - m[0][1] * m[3][0] * m[1][2] - m[0][2] * m[1][0] * m[3][1] + m[0][2] * m[3][0] * m[1][1]
|
||||
inv[3][3] = m[0][0] * m[1][1] * m[2][2] - m[0][0] * m[2][1] * m[1][2] - m[0][1] * m[1][0] * m[2][2] + m[0][1] * m[2][0] * m[1][2] + m[0][2] * m[1][0] * m[2][1] - m[0][2] * m[2][0] * m[1][1]
|
||||
|
||||
invdet = 1./ (m[0][0]*inv[0][0] + m[1][0]*inv[0][1] + m[2][0]*inv[0][2] + m[3][0]*inv[0][3])
|
||||
invdet = 1. / (m[0][0] * inv[0][0] + m[1][0] * inv[0][1] + m[2][0] * inv[0][2] + m[3][0] * inv[0][3])
|
||||
for i in range(4):
|
||||
for j in range(4):
|
||||
inv[i][j] = invdet * inv[i][j]
|
||||
return inv
|
||||
|
||||
def mulMatrix44(a,b):
|
||||
return tuple( tuple(a[i][0]*b[0][j]+a[i][1]*b[1][j]+a[i][2]*b[2][j]+a[i][3]*b[3][j] for j in xrange(4)) for i in xrange(4) )
|
||||
return tuple(tuple(a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j] + a[i][3] * b[3][j] for j in xrange(4)) for i in xrange(4))
|
||||
|
||||
def applyMatrix44(a,v):
|
||||
if a is None:
|
||||
return v
|
||||
return V3(a[i][0]*v[0]+a[i][1]*v[1]+a[i][2]*v[2]+a[i][3] for i in range(3))
|
||||
return V3(a[i][0] * v[0] + a[i][1] * v[1] + a[i][2] * v[2] + a[i][3] for i in range(3))
|
||||
|
||||
def translMatrix44(v):
|
||||
return tuple( tuple((IDENTITY44[i][j] if j < 3 or i == 3 else v[i]) for j in range(4)) for i in range(4))
|
||||
return tuple(tuple((IDENTITY44[i][j] if j < 3 or i == 3 else v[i]) for j in range(4)) for i in range(4))
|
||||
|
||||
def safeEval(p):
|
||||
if '__' in p:
|
||||
@ -109,7 +109,7 @@ def parseBlock(data,default):
|
||||
b = copy(start)
|
||||
else:
|
||||
b.id = int(start)
|
||||
if len(tokens)>1:
|
||||
if len(tokens) > 1:
|
||||
b.data = int(eval(tokens[1]))
|
||||
return Block(b.id,b.data)
|
||||
|
||||
@ -122,6 +122,33 @@ class MeshFile(object):
|
||||
self.objectData = {}
|
||||
self.objects = []
|
||||
|
||||
class MeshSTLBinary(MeshFile):
|
||||
def __init__(self, filename, myopen=open, swapYZ=False):
|
||||
super(MeshSTLBinary,self).__init__()
|
||||
|
||||
with myopen(filename, "rb") as f:
|
||||
header = f.read(80)
|
||||
assert not header.startswith("solid")
|
||||
assert len(header) == 80
|
||||
|
||||
vertexCount = 0
|
||||
|
||||
numTriangles = struct.unpack("<I", f.read(4))[0]
|
||||
|
||||
for i in range(numTriangles):
|
||||
assert len(f.read(12))==12 # skip normal
|
||||
for i in range(3):
|
||||
v = struct.unpack("<3f", f.read(12))
|
||||
if swapYZ:
|
||||
v = (v[0],v[2],-v[1])
|
||||
self.vertices.append(V3(v))
|
||||
self.faces.append((0,(vertexCount,vertexCount+1,vertexCount+2)))
|
||||
vertexCount += 3
|
||||
assert len(f.read(2))==2 # skip attributes
|
||||
|
||||
assert self.vertices
|
||||
assert self.faces
|
||||
|
||||
class MeshPLY(MeshFile):
|
||||
"""
|
||||
Currently doesn't support materials or binary data or any data. :-)
|
||||
@ -138,7 +165,7 @@ class MeshPLY(MeshFile):
|
||||
if line == "end_header":
|
||||
break
|
||||
args = re.split("\\s+",line)
|
||||
if len(args)>=3 and args[0]=='element':
|
||||
if len(args) >= 3 and args[0] == 'element':
|
||||
elementCounts.append((args[1],int(args[2])))
|
||||
assert len(elementCounts) >= 2
|
||||
for element,count in elementCounts:
|
||||
@ -333,8 +360,8 @@ class Mesh3DS(MeshFile):
|
||||
self.skip(lengthRemaining)
|
||||
|
||||
def handle_KEYF_PIVOT(self,lengthRemaining):
|
||||
self.object_pivot = V3(struct.unpack("<fff", self.file.read(3*4)))
|
||||
lengthRemaining -= 3*4
|
||||
self.object_pivot = V3(struct.unpack("<fff", self.file.read(3 * 4)))
|
||||
lengthRemaining -= 3 * 4
|
||||
self.skip(lengthRemaining)
|
||||
|
||||
def handle_EDIT_OBJECT(self,lengthRemaining):
|
||||
@ -380,16 +407,16 @@ class Mesh3DS(MeshFile):
|
||||
count = struct.unpack("<H", self.file.read(2))[0]
|
||||
lengthRemaining -= 2
|
||||
for i in xrange(count):
|
||||
self.object_vertices.append(V3(struct.unpack("<fff", self.file.read(3*4))))
|
||||
lengthRemaining -= 3*4
|
||||
self.object_vertices.append(V3(struct.unpack("<fff", self.file.read(3 * 4))))
|
||||
lengthRemaining -= 3 * 4
|
||||
self.skip(lengthRemaining)
|
||||
|
||||
def handle_TRI_FACEL1(self,lengthRemaining):
|
||||
count = struct.unpack("<H", self.file.read(2))[0]
|
||||
lengthRemaining -= 2
|
||||
for i in xrange(count):
|
||||
self.object_faces.append(struct.unpack("<HHH", self.file.read(2*3)))
|
||||
lengthRemaining -= 2*3
|
||||
self.object_faces.append(struct.unpack("<HHH", self.file.read(2 * 3)))
|
||||
lengthRemaining -= 2 * 3
|
||||
self.skip(2)
|
||||
lengthRemaining -= 2
|
||||
while lengthRemaining > 0:
|
||||
@ -403,7 +430,7 @@ class Mesh3DS(MeshFile):
|
||||
lengthRemaining -= chunkLength - 6
|
||||
|
||||
def handle_TRI_LOCAL(self,lengthRemaining):
|
||||
m = [ [1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1] ]
|
||||
m = [[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1]]
|
||||
for i in xrange(4):
|
||||
for j in xrange(3):
|
||||
m[j][i] = struct.unpack("<f", self.file.read(4))[0]
|
||||
@ -420,7 +447,7 @@ class Mesh3DS(MeshFile):
|
||||
for i in xrange(count):
|
||||
faces.add(struct.unpack("<H", self.file.read(2))[0])
|
||||
lengthRemaining -= 2
|
||||
self.object_material_data.append( (name, faces) )
|
||||
self.object_material_data.append((name, faces))
|
||||
self.skip(lengthRemaining)
|
||||
|
||||
class Mesh(object):
|
||||
@ -468,7 +495,7 @@ class Mesh(object):
|
||||
self.specifiedMeshName = None
|
||||
|
||||
base,ext = os.path.splitext(infile)
|
||||
if ext.lower() == '.obj' or ext.lower() == ".3ds" or ext.lower() == ".ply":
|
||||
if ext.lower() == '.obj' or ext.lower() == ".3ds" or ext.lower() == ".ply" or ext.lower() == ".stl":
|
||||
self.meshName = infile
|
||||
self.controlFile = base + ".txt"
|
||||
else:
|
||||
@ -476,6 +503,8 @@ class Mesh(object):
|
||||
self.meshName = base + ".3ds"
|
||||
elif os.path.isfile(base + ".ply") or os.path.isfile(base + ".ply.gz"):
|
||||
self.meshName = base + ".ply"
|
||||
elif os.path.isfile(base + ".stl") or os.path.isfile(base + ".stl.gz"):
|
||||
self.meshName = base + ".stl"
|
||||
else:
|
||||
self.meshName = base + ".obj"
|
||||
|
||||
@ -542,16 +571,16 @@ class Mesh(object):
|
||||
if self.archive in Mesh.SUPPORTED_ARCHIVES:
|
||||
self.archive = self.meshName + "." + self.archive
|
||||
if self.swapYZ is None:
|
||||
self.swapYZ = self.meshName.lower().endswith(".3ds")
|
||||
self.swapYZ = self.meshName.lower().endswith(".3ds") or self.meshName.lower().endswith(".stl")
|
||||
elif rewrite:
|
||||
if not os.path.isfile(self.meshName):
|
||||
raise IOError("Cannot find mesh file")
|
||||
if self.meshName.lower().endswith(".3ds"):
|
||||
if self.meshName.lower().endswith(".3ds") or self.meshName.lower().endswith(".stl"):
|
||||
self.swapYZ = True
|
||||
self.message("Creating a default control file")
|
||||
with open(self.controlFile,"w") as f:
|
||||
self.controlFileLines = []
|
||||
self.controlFileLines.append("file "+repr(os.path.basename(self.meshName))+"\n")
|
||||
self.controlFileLines.append("file " + repr(os.path.basename(self.meshName)) + "\n")
|
||||
if self.swapYZ:
|
||||
self.controlFileLines.append("swapyz 1\n")
|
||||
else:
|
||||
@ -560,7 +589,7 @@ class Mesh(object):
|
||||
self.controlFileLines.append("yaw 0\n")
|
||||
self.controlFileLines.append("pitch 0\n")
|
||||
self.controlFileLines.append("roll 0\n")
|
||||
self.controlFileLines.append("size "+str(self.size)+"\n")
|
||||
self.controlFileLines.append("size " + str(self.size) + "\n")
|
||||
self.controlFileLines.append("default STONE\n")
|
||||
self.controlFileLines.append("#order material position\n")
|
||||
self.controlFileLines.append("materials\n")
|
||||
@ -584,14 +613,14 @@ class Mesh(object):
|
||||
raise IOError("Unsupported archive type")
|
||||
if os.path.isfile(self.meshName):
|
||||
return self.meshName, open, None
|
||||
if os.path.isfile(self.meshName+".gz"):
|
||||
return self.meshName+".gz", gzip.open, None
|
||||
if os.path.isfile(self.meshName + ".gz"):
|
||||
return self.meshName + ".gz", gzip.open, None
|
||||
if tryDownload and (self.url or self.urlgz):
|
||||
self.message("Downloading mesh")
|
||||
urlzip = False
|
||||
if self.urlgz:
|
||||
url = self.urlgz
|
||||
outName = self.meshName+".gz"
|
||||
outName = self.meshName + ".gz"
|
||||
elif self.url:
|
||||
url = self.url
|
||||
if self.archive:
|
||||
@ -599,15 +628,15 @@ class Mesh(object):
|
||||
else:
|
||||
outName = self.meshName
|
||||
content = urllib2.urlopen(url).read()
|
||||
with open(outName+".tempDownload","wb") as f:
|
||||
with open(outName + ".tempDownload","wb") as f:
|
||||
f.write(content)
|
||||
os.rename(outName+".tempDownload", outName)
|
||||
os.rename(outName + ".tempDownload", outName)
|
||||
self.message("Downloaded")
|
||||
return self.getFile()
|
||||
else:
|
||||
raise IOError("File not found")
|
||||
|
||||
def read(self, rewriteControlFile = None):
|
||||
def read(self, rewriteControlFile=None):
|
||||
if self.swapYZ:
|
||||
fix = lambda list : V3(list[0], list[2], -list[1])
|
||||
else:
|
||||
@ -622,10 +651,15 @@ class Mesh(object):
|
||||
|
||||
name,myopen,closeArchive = self.getFile()
|
||||
if self.credits:
|
||||
self.message("Credits: "+self.credits)
|
||||
self.message("Credits: " + self.credits)
|
||||
|
||||
if name.endswith(".3ds") or name.endswith(".3ds.gz") or name.endswith(".ply") or name.endswith(".ply.gz"):
|
||||
MeshFormat = Mesh3DS if name.endswith(".3ds") or name.endswith(".3ds.gz") else MeshPLY
|
||||
if name.endswith(".3ds") or name.endswith(".3ds.gz") or name.endswith(".ply") or name.endswith(".ply.gz") or name.endswith(".stl") or name.endswith(".stl.gz"):
|
||||
if name.endswith(".3ds") or name.endswith(".3ds.gz"):
|
||||
MeshFormat = Mesh3DS
|
||||
elif name.endswith(".ply") or name.endswith(".ply.gz"):
|
||||
MeshFormat = MeshPLY
|
||||
else:
|
||||
MeshFormat = MeshSTLBinary
|
||||
mesh = MeshFormat(name,myopen=myopen,swapYZ=self.swapYZ)
|
||||
self.baseVertices = mesh.vertices
|
||||
self.faces = mesh.faces
|
||||
@ -635,13 +669,13 @@ class Mesh(object):
|
||||
self.materialOrders.append(self.materialOrderDict.get(name, 0))
|
||||
self.materialBlocks.append(self.materialBlockDict.get(name, self.default))
|
||||
if name not in self.materialBlockDict and name not in warned:
|
||||
self.message("Material "+name+" not defined")
|
||||
self.message("Material " + name + " not defined")
|
||||
warned.add(name)
|
||||
if len(self.materialBlocks) == 0:
|
||||
self.materialBlocks.append(self.default)
|
||||
else:
|
||||
self.materialBlocks = [ self.default ]
|
||||
self.materialOrders = [ 0 ]
|
||||
self.materialBlocks = [self.default]
|
||||
self.materialOrders = [0]
|
||||
materialIndexDict = { Mesh.UNSPECIFIED: 0 }
|
||||
|
||||
with myopen(name) as fh:
|
||||
@ -660,7 +694,7 @@ class Mesh(object):
|
||||
for i in xrange(0, len(face)) :
|
||||
# OBJ indexies are 1 based not 0 based hence the -1
|
||||
# convert indexes to integer
|
||||
face[i] = int( face[i].split('/')[0] ) - 1
|
||||
face[i] = int(face[i].split('/')[0]) - 1
|
||||
# skip texture and normal
|
||||
# for j in xrange(0, len(face[i])) :
|
||||
# if face[i][j] != "":
|
||||
@ -677,7 +711,7 @@ class Mesh(object):
|
||||
self.materialOrders.append(self.materialOrderDict.get(name, 0))
|
||||
self.materialBlocks.append(self.materialBlockDict.get(name, self.default))
|
||||
if name not in self.materialBlockDict and name not in warned:
|
||||
self.message("Material "+name+" not defined")
|
||||
self.message("Material " + name + " not defined")
|
||||
warned.add(name)
|
||||
|
||||
if closeArchive:
|
||||
@ -686,22 +720,22 @@ class Mesh(object):
|
||||
if self.rewrite and warned:
|
||||
try:
|
||||
self.message("Rewriting control file to include missing materials")
|
||||
with open(self.controlFile+".tempFile", "w") as f:
|
||||
with open(self.controlFile + ".tempFile", "w") as f:
|
||||
f.write(''.join(self.controlFileLines[:self.endLineIndex]))
|
||||
if not self.haveMaterialArea:
|
||||
f.write('\nmaterials\n')
|
||||
for material in warned:
|
||||
f.write(material+' default\n')
|
||||
f.write(material + ' default\n')
|
||||
f.write(''.join(self.controlFileLines[self.endLineIndex:]))
|
||||
try:
|
||||
os.unlink(self.controlFile+".bak")
|
||||
os.unlink(self.controlFile + ".bak")
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
os.rename(self.controlFile, self.controlFile+".bak")
|
||||
os.rename(self.controlFile, self.controlFile + ".bak")
|
||||
except:
|
||||
pass
|
||||
os.rename(self.controlFile+".tempFile", self.controlFile)
|
||||
os.rename(self.controlFile + ".tempFile", self.controlFile)
|
||||
except:
|
||||
self.message("Couldn't rewrite control file")
|
||||
|
||||
@ -722,12 +756,12 @@ class Mesh(object):
|
||||
if maximum[i] == None or vertex[i] > maximum[i]:
|
||||
maximum[i] = vertex[i]
|
||||
|
||||
center = [(maximum[i] + minimum[i])/2 for i in range(3)]
|
||||
center = [(maximum[i] + minimum[i]) / 2 for i in range(3)]
|
||||
|
||||
maxsize = max( ( maximum[i]-minimum[i] for i in range(3) ) )
|
||||
maxsize = max(( maximum[i] - minimum[i] for i in range(3) ))
|
||||
|
||||
scale = self.size / maxsize
|
||||
translate = V3(bottomCenter.x-scale*center[0], bottomCenter.y-scale*minimum[1], bottomCenter.z-scale*center[2])
|
||||
translate = V3(bottomCenter.x - scale * center[0], bottomCenter.y - scale * minimum[1], bottomCenter.z - scale * center[2])
|
||||
|
||||
for i in range(len(self.vertices)):
|
||||
self.vertices[i] = self.vertices[i] * scale + translate
|
||||
@ -801,12 +835,12 @@ def go(filename, args=[]):
|
||||
|
||||
# main program
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv)<2:
|
||||
if len(sys.argv) < 2:
|
||||
if settings.isPE:
|
||||
go("models/RaspberryPi.txt")
|
||||
else:
|
||||
from Tkinter import *
|
||||
from tkFileDialog import askopenfilename
|
||||
from Tkinter import *
|
||||
master = Tk()
|
||||
master.wm_title("render")
|
||||
master.attributes("-topmost", True)
|
||||
@ -835,7 +869,7 @@ if __name__ == "__main__":
|
||||
c.select()
|
||||
|
||||
def selectFileAndGo():
|
||||
name=askopenfilename(initialdir='models',filetypes=['controlfile {*.txt}'])
|
||||
name = askopenfilename(initialdir='models',filetypes=['controlfile {*.txt}', 'all {*}'])
|
||||
if name:
|
||||
options = '-'
|
||||
if not clearing:
|
||||
|
0
raspberryjammod/mcpipy/sierpinski3d.py
Normal file → Executable file
0
raspberryjammod/mcpipy/sierpinski3d.py
Normal file → Executable file
0
raspberryjammod/mcpipy/simplefractaltree.py
Normal file → Executable file
0
raspberryjammod/mcpipy/simplefractaltree.py
Normal file → Executable file
0
raspberryjammod/mcpipy/simpletree.py
Normal file → Executable file
0
raspberryjammod/mcpipy/simpletree.py
Normal file → Executable file
@ -1,24 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
|
||||
# mcpipy.com retrieved from URL below, written by snowbound
|
||||
# http://www.minecraftforum.net/topic/1680160-simple-flatmap-script/
|
||||
|
||||
|
||||
import sys
|
||||
import mcpi.minecraft as minecraft
|
||||
import mcpi.block as block
|
||||
import server
|
||||
|
||||
|
||||
mc = minecraft.Minecraft.create(server.address)
|
||||
mc.setBlocks(-128,0,-128,128,64,128,0)
|
||||
if(len(sys.argv) > 1):
|
||||
bid = int(sys.argv[1])
|
||||
else:
|
||||
bid = block.SANDSTONE.id
|
||||
|
||||
if bid < 0 or bid > 108:
|
||||
bid = block.SANDSTONE.id
|
||||
|
||||
mc.setBlocks(-128,0,-128,128,-64,128,bid)
|
0
raspberryjammod/mcpipy/snowflake.py
Normal file → Executable file
0
raspberryjammod/mcpipy/snowflake.py
Normal file → Executable file
0
raspberryjammod/mcpipy/spacefill.py
Normal file → Executable file
0
raspberryjammod/mcpipy/spacefill.py
Normal file → Executable file
2
raspberryjammod/mcpipy/spiral.py
Executable file → Normal file
2
raspberryjammod/mcpipy/spiral.py
Executable file → Normal file
@ -8,7 +8,7 @@ import math
|
||||
def draw_horizontal_disc(cx, cy, cz, radius, block_type, meta):
|
||||
for x in range(-radius, radius):
|
||||
for z in range(-radius, radius):
|
||||
if (x**2 + z**2 <= radius):
|
||||
if (x**2 + z**2 <= radius**2):
|
||||
mc.setBlock(cx + x, cy, cz + z, block_type, meta)
|
||||
|
||||
def draw_spiral(mcx,mcy,mcz,major_radius,minor_radius,height,period,phase,block_type,meta):
|
||||
|
0
raspberryjammod/mcpipy/squarecurve.py
Normal file → Executable file
0
raspberryjammod/mcpipy/squarecurve.py
Normal file → Executable file
0
raspberryjammod/mcpipy/stuffaboutcode_basics.py
Executable file → Normal file
0
raspberryjammod/mcpipy/stuffaboutcode_basics.py
Executable file → Normal file
0
raspberryjammod/mcpipy/stuffaboutcode_bridge.py
Executable file → Normal file
0
raspberryjammod/mcpipy/stuffaboutcode_bridge.py
Executable file → Normal file
0
raspberryjammod/mcpipy/stuffaboutcode_clock.py
Executable file → Normal file
0
raspberryjammod/mcpipy/stuffaboutcode_clock.py
Executable file → Normal file
0
raspberryjammod/mcpipy/stuffaboutcode_hideandseek.py
Executable file → Normal file
0
raspberryjammod/mcpipy/stuffaboutcode_hideandseek.py
Executable file → Normal file
0
raspberryjammod/mcpipy/teleport.py
Normal file → Executable file
0
raspberryjammod/mcpipy/teleport.py
Normal file → Executable file
0
raspberryjammod/mcpipy/test.py
Executable file → Normal file
0
raspberryjammod/mcpipy/test.py
Executable file → Normal file
@ -6,8 +6,12 @@ import sys
|
||||
import time
|
||||
import mcpi.minecraft as minecraft
|
||||
|
||||
ALIGN_LEFT = 0
|
||||
ALIGN_RIGHT = 1
|
||||
ALIGN_CENTER = 2
|
||||
|
||||
# vectors must be minecraft.Vec3
|
||||
def drawGlyph(mc, pos, forwardVec, upVec, glyph, foreground, background=None):
|
||||
def drawGlyph(mc, pos, forwardVec, upVec, glyph, foreground, background=None, buffer=None):
|
||||
bitmap = glyph[3]
|
||||
height = len(bitmap)
|
||||
width = glyph[0]
|
||||
@ -17,36 +21,54 @@ def drawGlyph(mc, pos, forwardVec, upVec, glyph, foreground, background=None):
|
||||
for i in range(height):
|
||||
pixelPos = pos + upVec*(height-1-i) + forwardVec*offset
|
||||
for j in range(width):
|
||||
if not foreground is None and 0 != bitmap[i] & (1 << (width-1-j)):
|
||||
mc.setBlock(pixelPos, foreground)
|
||||
elif not background is None and 0 == bitmap[i] & (1 << (width-1-j)):
|
||||
mc.setBlock(pixelPos, background)
|
||||
if foreground is not None and 0 != bitmap[i] & (1 << (width-1-j)):
|
||||
if buffer is not None:
|
||||
buffer[(pixelPos.x,pixelPos.y,pixelPos.z)] = foreground
|
||||
else:
|
||||
mc.setBlock(pixelPos, foreground)
|
||||
elif background is not None and 0 == bitmap[i] & (1 << (width-1-j)):
|
||||
if buffer is not None:
|
||||
buffer[(pixelPos.x,pixelPos.y,pixelPos.z)] = background
|
||||
else:
|
||||
mc.setBlock(pixelPos, background)
|
||||
pixelPos += forwardVec
|
||||
return pos + forwardVec*delta
|
||||
|
||||
def textLength(font, text):
|
||||
l = 0
|
||||
for value in text:
|
||||
try:
|
||||
glyph = font[value]
|
||||
except:
|
||||
glyph = font[32]
|
||||
l += glyph[2]
|
||||
return l
|
||||
|
||||
def drawText(mc, font, pos, forwardVec, upVec, text, foreground, background=None):
|
||||
def drawText(mc, font, pos, forwardVec, upVec, text, foreground=None, background=None, align=ALIGN_LEFT, buffer=None):
|
||||
try:
|
||||
text = text.decode("cp1252")
|
||||
text = bytearray(text.encode("cp1252"))
|
||||
except:
|
||||
text = text.decode("iso8859_1")
|
||||
text = bytearray(text.encode("iso8859_1"))
|
||||
pixelPos = pos.clone()
|
||||
height = len(font[32][3])
|
||||
numLines = text.count("\n")+1
|
||||
pixelPos += upVec * ((numLines-1) * height)
|
||||
lines = text.split(b'\n')
|
||||
pixelPos += upVec * ((len(lines)-1)* height)
|
||||
lineStart = pixelPos.clone()
|
||||
for c in text:
|
||||
value = ord(c)
|
||||
|
||||
if value == 10:
|
||||
lineStart += upVec * (-height)
|
||||
pixelPos = lineStart.clone()
|
||||
else:
|
||||
for line in lines:
|
||||
pixelPos = lineStart.clone()
|
||||
if align == ALIGN_RIGHT:
|
||||
pixelPos -= forwardVec * textLength(font, line)
|
||||
elif align == ALIGN_CENTER:
|
||||
pixelPos -= forwardVec * (0.5 * textLength(font, line))
|
||||
|
||||
for value in line:
|
||||
try:
|
||||
glyph = font[value]
|
||||
except:
|
||||
glyph = font[32]
|
||||
pixelPos = drawGlyph(mc, pixelPos, forwardVec, upVec, glyph, foreground, background)
|
||||
pixelPos = drawGlyph(mc, pixelPos, forwardVec, upVec, glyph, foreground, background, buffer)
|
||||
|
||||
lineStart += upVec * (-height)
|
||||
return pixelPos
|
||||
|
||||
def angleToTextDirectionCardinal(angle):
|
||||
@ -87,4 +109,4 @@ if __name__ == '__main__':
|
||||
del sys.argv[0]
|
||||
text = " ".join(sys.argv)
|
||||
|
||||
drawText(mc, fonts.FONTS['tallfont'], pos, forward, minecraft.Vec3(0,1,0), text, foreground, background)
|
||||
drawText(mc, fonts.FONTS['metrix7pt'], pos, forward, minecraft.Vec3(0,1,0), text, foreground, background, align=ALIGN_RIGHT)
|
||||
|
6
raspberryjammod/mcpipy/top.py
Normal file
6
raspberryjammod/mcpipy/top.py
Normal file
@ -0,0 +1,6 @@
|
||||
from mc import *
|
||||
|
||||
mc = Minecraft()
|
||||
|
||||
playerPos = mc.player.getTilePos()
|
||||
mc.player.setPos(playerPos.x, mc.getHeight(playerPos.x, playerPos.z)+1, playerPos.z)
|
84
raspberryjammod/mcpipy/toschematic.py
Normal file
84
raspberryjammod/mcpipy/toschematic.py
Normal file
@ -0,0 +1,84 @@
|
||||
from mc import *
|
||||
from ast import literal_eval
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import mcpi.nbt as nbt
|
||||
from struct import pack
|
||||
from vehicle import getLoadPath
|
||||
|
||||
def load(filename):
|
||||
with open(filename) as f:
|
||||
data = ''.join(f.readlines())
|
||||
result = re.search("=\\s*(.*)",data)
|
||||
if result is None:
|
||||
raise ValueError
|
||||
|
||||
# Check to ensure only function called is Block() by getting literal_eval to
|
||||
# raise an exception when "Block" is removed and the result isn't a literal.
|
||||
# This SHOULD make the eval call safe, though USE AT YOUR OWN RISK. Ideally,
|
||||
# one would walk the ast parse tree and use a whitelist.
|
||||
literal_eval(result.group(1).replace("Block",""))
|
||||
|
||||
return eval(result.group(1))
|
||||
|
||||
def toSchematic(vehicle):
|
||||
x0 = min(x for (x,y,z) in vehicle)
|
||||
y0 = min(y for (x,y,z) in vehicle)
|
||||
z0 = min(z for (x,y,z) in vehicle)
|
||||
x1 = max(x for (x,y,z) in vehicle)
|
||||
y1 = max(y for (x,y,z) in vehicle)
|
||||
z1 = max(z for (x,y,z) in vehicle)
|
||||
schematic = nbt.NBTFile()
|
||||
schematic.name = "Schematic"
|
||||
schematic.tags.append(nbt.TAG_Short(name="Width", value = x1-x0+1))
|
||||
schematic.tags.append(nbt.TAG_Short(name="Height", value = y1-y0+1))
|
||||
schematic.tags.append(nbt.TAG_Short(name="Length", value = z1-z0+1))
|
||||
schematic.tags.append(nbt.TAG_String(name="Materials", value="Alpha"))
|
||||
ids = b''
|
||||
metas = b''
|
||||
|
||||
for y in range(y0,y1+1):
|
||||
for z in range(z0,z1+1):
|
||||
for x in range(x0,x1+1):
|
||||
try:
|
||||
b = vehicle[(x,y,z)]
|
||||
except:
|
||||
b = Block(0)
|
||||
ids += pack("B", b.id)
|
||||
metas += pack("B", b.data)
|
||||
|
||||
blocks = nbt.TAG_Byte_Array(name="Blocks")
|
||||
blocks.value = ids
|
||||
schematic.tags.append(blocks)
|
||||
data = nbt.TAG_Byte_Array(name="Data")
|
||||
data.value = metas
|
||||
schematic.tags.append(data)
|
||||
schematic.tags.append(nbt.TAG_List(name="Entities", type=nbt.TAG_Compound))
|
||||
schematic.tags.append(nbt.TAG_List(name="TileEntities", type=nbt.TAG_Compound))
|
||||
|
||||
return schematic
|
||||
|
||||
def vehicleToSchematic(vehiclePath, schematicPath):
|
||||
angle,highWater,vehicle = load(vehiclePath)
|
||||
nbt = toSchematic(vehicle)
|
||||
nbt.write_file(schematicPath)
|
||||
|
||||
if __name__ == '__main__':
|
||||
directory = os.path.join(os.path.dirname(sys.argv[0]),"vehicles")
|
||||
if len(sys.argv) >= 2:
|
||||
if sys.argv[1].endswith(".py"):
|
||||
name = directory + "/" + sys.argv[1]
|
||||
else:
|
||||
name = directory + "/" + sys.argv[1] + ".py"
|
||||
else:
|
||||
name = getLoadPath(directory, "py")
|
||||
|
||||
out = name
|
||||
|
||||
if out.endswith(".py"):
|
||||
out = name[:-2] + "schematic"
|
||||
else:
|
||||
out += ".schematic"
|
||||
|
||||
vehicleToSchematic(name, out)
|
0
raspberryjammod/mcpipy/trefoil.py
Executable file → Normal file
0
raspberryjammod/mcpipy/trefoil.py
Executable file → Normal file
0
raspberryjammod/mcpipy/trefoil2.py
Executable file → Normal file
0
raspberryjammod/mcpipy/trefoil2.py
Executable file → Normal file
6
raspberryjammod/mcpipy/turtleconsole.py
Normal file → Executable file
6
raspberryjammod/mcpipy/turtleconsole.py
Normal file → Executable file
@ -1,3 +1,7 @@
|
||||
#
|
||||
# WARNING: If you're running RJM on a server, do NOT include this script server-side for security reasons.
|
||||
#
|
||||
|
||||
#
|
||||
# Code under the MIT license by Alexander Pruss
|
||||
#
|
||||
@ -28,6 +32,8 @@ def inputLine(prompt):
|
||||
return 'quit()'
|
||||
elif c.message == ' ':
|
||||
return ''
|
||||
elif "__" in c.message:
|
||||
sys.exit();
|
||||
else:
|
||||
return c.message
|
||||
time.sleep(0.2)
|
||||
|
0
raspberryjammod/mcpipy/turtledonut.py
Normal file → Executable file
0
raspberryjammod/mcpipy/turtledonut.py
Normal file → Executable file
0
raspberryjammod/mcpipy/vehicle.py
Normal file → Executable file
0
raspberryjammod/mcpipy/vehicle.py
Normal file → Executable file
67
raspberryjammod/mcpipy/win32move.py
Normal file
67
raspberryjammod/mcpipy/win32move.py
Normal file
@ -0,0 +1,67 @@
|
||||
from mc import *
|
||||
from time import sleep
|
||||
from sys import argv
|
||||
import input
|
||||
|
||||
mc = Minecraft()
|
||||
|
||||
player = True
|
||||
|
||||
if len(argv)>=2 and argv[1] != "me":
|
||||
playerPos = mc.player.getPos()
|
||||
playerYaw = mc.player.getRotation()
|
||||
entity = mc.spawnEntity(argv[1], playerPos.x - sin(radians(playerYaw)), playerPos.z,
|
||||
playerPos.z + cos(radians(playerYaw)), "{NoAI:1}")
|
||||
player = False
|
||||
else:
|
||||
entity = mc.getPlayerId()
|
||||
|
||||
lastPlatform = None
|
||||
lastPlatformBlock = None
|
||||
|
||||
UNSOLID = set([WATER_FLOWING.id,WATER_STATIONARY.id,AIR.id,LAVA_FLOWING.id,LAVA_STATIONARY.id])
|
||||
|
||||
while True:
|
||||
pos = mc.entity.getPos(entity)
|
||||
yaw = mc.entity.getRotation(entity)
|
||||
move = False
|
||||
if input.wasPressedSinceLast(input.NEXT):
|
||||
pos.y -= 1
|
||||
move = True
|
||||
if input.wasPressedSinceLast(input.PRIOR):
|
||||
pos.y += 1
|
||||
move = True
|
||||
if input.wasPressedSinceLast(input.LEFT):
|
||||
yaw -= 15
|
||||
mc.entity.setRotation(entity,yaw)
|
||||
if input.wasPressedSinceLast(input.RIGHT):
|
||||
yaw += 15
|
||||
mc.entity.setRotation(entity,yaw)
|
||||
if input.wasPressedSinceLast(input.UP):
|
||||
pos.x += .5 * -sin(radians(yaw))
|
||||
pos.z += .5 * cos(radians(yaw))
|
||||
move = True
|
||||
if input.wasPressedSinceLast(input.DOWN):
|
||||
pos.x -= .5 * -sin(radians(yaw))
|
||||
pos.z -= .5 * cos(radians(yaw))
|
||||
move = True
|
||||
if move:
|
||||
if player:
|
||||
under = (int(floor(pos.x)),int(floor(pos.y))-1,int(floor(pos.z)))
|
||||
block = mc.getBlock(under)
|
||||
if block in UNSOLID:
|
||||
drew = under
|
||||
mc.setBlock(drew,GLASS)
|
||||
else:
|
||||
drew = None
|
||||
mc.entity.setPos(entity,pos)
|
||||
if lastPlatform != under:
|
||||
mc.setBlock(lastPlatform,AIR)
|
||||
lastPlatform = None
|
||||
if drew:
|
||||
lastPlatform = drew
|
||||
lastPlatformBlock = block
|
||||
else:
|
||||
mc.entity.setPos(entity,pos)
|
||||
sleep(0.2)
|
||||
|
0
raspberryjammod/mcpipy/zhuowei_rainbow.py
Executable file → Normal file
0
raspberryjammod/mcpipy/zhuowei_rainbow.py
Executable file → Normal file
Loading…
x
Reference in New Issue
Block a user