Skip to content

Commit 77db831

Browse files
committed
mc2snucode
0 parents  commit 77db831

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

mc2snucode.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import mcpi.minecraft as minecraft
2+
import mcpi.block as block
3+
import math
4+
5+
def Convert(x1, y1, z1, x2, y2, z2):
6+
mc = minecraft.Minecraft.create()
7+
file = open("convert.txt", 'w')
8+
9+
xhigh = max(x1, x2)
10+
xlow = min(x1, x2)
11+
yhigh = max(y1, y2)
12+
ylow = min(y1, y2)
13+
zhigh = max(z1, z2)
14+
zlow = min(z1, z2)
15+
16+
array = []
17+
18+
# blocks = []
19+
for x in range(xhigh - xlow + 1):
20+
# blocks.append([])
21+
for y in range(yhigh - ylow + 1):
22+
# blocks[x].append([])
23+
for z in range(zhigh - zlow + 1):
24+
# blocks[x][y].append([])
25+
block = mc.getBlock(xlow + x, ylow + y, zlow + z)
26+
print(xlow + x, ylow + y, zlow + z, block)
27+
array.append(block)
28+
rawTextData = str(xlow + x) + "," + str(ylow + y) + "," + str(zlow + z) + "," + str(block) + "\n"
29+
# blocks[x][y][z] = block
30+
31+
32+
tempX = xhigh - xlow
33+
tempY = yhigh - ylow
34+
tempZ = xhigh - xlow
35+
36+
37+
38+
textData = "var map = " + str(array) + ";\n" + "var i = 0\n" + "\n" + "for(x = 0; x < " + str(tempX + 1) + "; x++) {\n" + " for(y = 0; y < " + str(tempY + 1) + "; y++) {\n" + " for(z = 0; z < " + str(tempZ + 1) + "; z++) {\n" + " cube(x+5, z+5, y+5, map[i]);\n" + " i++;\n" + " }\n" + " }\n" + "}\n"
39+
40+
file.write(textData)
41+
file.close()
42+
# return blocks

mcCommand.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import mcpi.minecraft as minecraft
2+
import mcpi.block as block
3+
import mc2snucode
4+
import cmd
5+
import math
6+
7+
class Commands(cmd.Cmd):
8+
mc = minecraft.Minecraft.create()
9+
10+
def __init__(self):
11+
cmd.Cmd.__init__(self)
12+
self.prompt = ">> "
13+
self.intro = ""
14+
15+
def do_exit(self, args):
16+
# exit
17+
return -1
18+
19+
def do_convert(self, args):
20+
mc2snucode.Convert(self.startPos.x, self.startPos.y, self.startPos.z,
21+
self.endPos.x, self.endPos.y, self.endPos.z)
22+
23+
24+
def do_setPos1(self, args):
25+
self.startPos = self.mc.player.getTilePos()
26+
# self.startPos = minecraft.Vec3(681, 4, 79)
27+
print(str(self.startPos))
28+
29+
def do_setPos2(self, args):
30+
self.endPos = self.mc.player.getTilePos()
31+
# self.endPos = minecraft.Vec3(679, 4, 81)
32+
print(str(self.endPos))
33+
34+
35+
def do_EOF(self, line):
36+
return True
37+
38+
39+
if __name__ == "__main__":
40+
Commands().cmdloop()

0 commit comments

Comments
 (0)