Skip to content

Commit 0b24a7b

Browse files
committed
mc2snucode
1 parent 5cca9b8 commit 0b24a7b

File tree

4 files changed

+241
-11
lines changed

4 files changed

+241
-11
lines changed

src/.vscode/launch.json

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
{
2+
// IntelliSense를 사용하여 가능한 특성에 대해 알아보세요.
3+
// 기존 특성에 대한 설명을 보려면 가리킵니다.
4+
// 자세한 내용을 보려면 https://go.microsoft.com/fwlink/?linkid=830387을(를) 방문하세요.
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python",
9+
"type": "python",
10+
"request": "launch",
11+
"stopOnEntry": true,
12+
"pythonPath": "${config:python.pythonPath}",
13+
"program": "${file}",
14+
"cwd": "${workspaceFolder}",
15+
"env": {},
16+
"envFile": "${workspaceFolder}/.env",
17+
"debugOptions": [
18+
"RedirectOutput"
19+
]
20+
},
21+
{
22+
"name": "Python: Attach",
23+
"type": "python",
24+
"request": "attach",
25+
"localRoot": "${workspaceFolder}",
26+
"remoteRoot": "${workspaceFolder}",
27+
"port": 3000,
28+
"secret": "my_secret",
29+
"host": "localhost"
30+
},
31+
{
32+
"name": "Python: Terminal (integrated)",
33+
"type": "python",
34+
"request": "launch",
35+
"stopOnEntry": true,
36+
"pythonPath": "${config:python.pythonPath}",
37+
"program": "${file}",
38+
"cwd": "",
39+
"console": "integratedTerminal",
40+
"env": {},
41+
"envFile": "${workspaceFolder}/.env",
42+
"debugOptions": []
43+
},
44+
{
45+
"name": "Python: Terminal (external)",
46+
"type": "python",
47+
"request": "launch",
48+
"stopOnEntry": true,
49+
"pythonPath": "${config:python.pythonPath}",
50+
"program": "${file}",
51+
"cwd": "",
52+
"console": "externalTerminal",
53+
"env": {},
54+
"envFile": "${workspaceFolder}/.env",
55+
"debugOptions": []
56+
},
57+
{
58+
"name": "Python: Django",
59+
"type": "python",
60+
"request": "launch",
61+
"stopOnEntry": true,
62+
"pythonPath": "${config:python.pythonPath}",
63+
"program": "${workspaceFolder}/manage.py",
64+
"cwd": "${workspaceFolder}",
65+
"args": [
66+
"runserver",
67+
"--noreload",
68+
"--nothreading"
69+
],
70+
"env": {},
71+
"envFile": "${workspaceFolder}/.env",
72+
"debugOptions": [
73+
"RedirectOutput",
74+
"DjangoDebugging"
75+
]
76+
},
77+
{
78+
"name": "Python: Flask (0.11.x or later)",
79+
"type": "python",
80+
"request": "launch",
81+
"stopOnEntry": false,
82+
"pythonPath": "${config:python.pythonPath}",
83+
"program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter",
84+
"cwd": "${workspaceFolder}",
85+
"env": {
86+
"FLASK_APP": "${workspaceFolder}/quickstart/app.py"
87+
},
88+
"args": [
89+
"run",
90+
"--no-debugger",
91+
"--no-reload"
92+
],
93+
"envFile": "${workspaceFolder}/.env",
94+
"debugOptions": [
95+
"RedirectOutput"
96+
]
97+
},
98+
{
99+
"name": "Python: Flask (0.10.x or earlier)",
100+
"type": "python",
101+
"request": "launch",
102+
"stopOnEntry": false,
103+
"pythonPath": "${config:python.pythonPath}",
104+
"program": "${workspaceFolder}/run.py",
105+
"cwd": "${workspaceFolder}",
106+
"args": [],
107+
"env": {},
108+
"envFile": "${workspaceFolder}/.env",
109+
"debugOptions": [
110+
"RedirectOutput"
111+
]
112+
},
113+
{
114+
"name": "Python: PySpark",
115+
"type": "python",
116+
"request": "launch",
117+
"stopOnEntry": true,
118+
"osx": {
119+
"pythonPath": "${env:SPARK_HOME}/bin/spark-submit"
120+
},
121+
"windows": {
122+
"pythonPath": "${env:SPARK_HOME}/bin/spark-submit.cmd"
123+
},
124+
"linux": {
125+
"pythonPath": "${env:SPARK_HOME}/bin/spark-submit"
126+
},
127+
"program": "${file}",
128+
"cwd": "${workspaceFolder}",
129+
"env": {},
130+
"envFile": "${workspaceFolder}/.env",
131+
"debugOptions": [
132+
"RedirectOutput"
133+
]
134+
},
135+
{
136+
"name": "Python: Module",
137+
"type": "python",
138+
"request": "launch",
139+
"stopOnEntry": true,
140+
"pythonPath": "${config:python.pythonPath}",
141+
"module": "module.name",
142+
"cwd": "${workspaceFolder}",
143+
"env": {},
144+
"envFile": "${workspaceFolder}/.env",
145+
"debugOptions": [
146+
"RedirectOutput"
147+
]
148+
},
149+
{
150+
"name": "Python: Pyramid",
151+
"type": "python",
152+
"request": "launch",
153+
"stopOnEntry": true,
154+
"pythonPath": "${config:python.pythonPath}",
155+
"cwd": "${workspaceFolder}",
156+
"env": {},
157+
"envFile": "${workspaceFolder}/.env",
158+
"args": [
159+
"${workspaceFolder}/development.ini"
160+
],
161+
"debugOptions": [
162+
"RedirectOutput",
163+
"Pyramid"
164+
]
165+
},
166+
{
167+
"name": "Python: Watson",
168+
"type": "python",
169+
"request": "launch",
170+
"stopOnEntry": true,
171+
"pythonPath": "${config:python.pythonPath}",
172+
"program": "${workspaceFolder}/console.py",
173+
"cwd": "${workspaceFolder}",
174+
"args": [
175+
"dev",
176+
"runserver",
177+
"--noreload=True"
178+
],
179+
"env": {},
180+
"envFile": "${workspaceFolder}/.env",
181+
"debugOptions": [
182+
"RedirectOutput"
183+
]
184+
}
185+
]
186+
}
1.69 KB
Binary file not shown.

src/convert.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var map = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 4, 0, 0, 0, 0, 0, 0, 0, 2, 17, 5, 0, 0, 0, 0, 0, 0, 0, 16, 6, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
2+
var i = 0
3+
4+
for(x = 0; x < 5; x++) {
5+
for(y = 0; y < 2; y++) {
6+
for(z = 0; z < 5; z++) {
7+
cube(x, z, y, map[i]);
8+
i++;
9+
}
10+
}
11+
}

src/mc2snucode.py

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import mcpi.minecraft as minecraft
2-
import mcpi.block as block
2+
import mcpi.block as Block
33
import math
44

55
def Convert(x1, y1, z1, x2, y2, z2):
@@ -15,27 +15,60 @@ def Convert(x1, y1, z1, x2, y2, z2):
1515

1616
array = []
1717

18-
# blocks = []
1918
for x in range(xhigh - xlow + 1):
20-
# blocks.append([])
2119
for y in range(yhigh - ylow + 1):
22-
# blocks[x].append([])
2320
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)
21+
blockType = mc.getBlockWithData(xlow + x, ylow + y, zlow + z)
22+
print(xlow + x, ylow + y, zlow + z, blockType)
23+
block = 5
24+
25+
# http://www.stuffaboutcode.com/p/minecraft-api-reference.html
26+
if blockType == Block.Block(3, 0):
27+
block = 1
28+
elif blockType == Block.Block(17, 0):
29+
block = 2
30+
elif blockType == Block.Block(35, 14):
31+
block = 4
32+
elif blockType == Block.Block(35, 11):
33+
block = 5
34+
elif blockType == Block.Block(57, 0):
35+
block = 6
36+
elif blockType == Block.Block(45, 0):
37+
block = 7
38+
elif blockType == Block.Block(5, 0):
39+
block = 8
40+
elif blockType == Block.Block(1, 0):
41+
block = 9
42+
elif blockType == Block.Block(17, 2):
43+
block = 12
44+
elif blockType == Block.Block(80, 7):
45+
block = 15
46+
elif blockType == Block.Block(79, 0):
47+
block = 16
48+
elif blockType == Block.Block(35, 4):
49+
block = 17
50+
elif blockType == Block.AIR:
51+
block = 0
52+
2753
array.append(block)
28-
rawTextData = str(xlow + x) + "," + str(ylow + y) + "," + str(zlow + z) + "," + str(block) + "\n"
29-
# blocks[x][y][z] = block
3054

3155

3256
tempX = xhigh - xlow
3357
tempY = yhigh - ylow
3458
tempZ = xhigh - xlow
3559

60+
array.reverse()
3661

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"
62+
textData = "var map = " + str(array) + ";\n"
63+
textData += "var i = 0\n"
64+
textData += "\n"
65+
textData += "for(x = 0; x < " + str(tempX + 1) + "; x++) {\n"
66+
textData += " for(y = 0; y < " + str(tempY + 1) + "; y++) {\n"
67+
textData += " for(z = 0; z < " + str(tempZ + 1) + "; z++) {\n"
68+
textData += " cube(x, z, y, map[i]);\n" + " i++;\n"
69+
textData += " }\n"
70+
textData += " }\n"
71+
textData += "}\n"
3972

4073
file.write(textData)
4174
file.close()

0 commit comments

Comments
 (0)