Skip to content

Commit 2ee38ec

Browse files
committed
Add MineClone2 support, fix dedup issues, and a fix for 'vm:set_lighting' errors in Minetest v5.x.
1 parent 9f0bd09 commit 2ee38ec

8 files changed

+2019
-159
lines changed

Map_Content_Documentation.txt

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
===================================================================
2+
Documentation for "map_content.txt" and "mcl2_map_content.txt":
3+
===================================================================
4+
5+
Documentation originally derived from: https://github.com/dgm3333/mcblocks/blob/master/map_content.txt
6+
Updated by MysticTempest
7+
--------------------------------------
8+
The format of this file is:
9+
MCID data modname:blockname param2
10+
17 0 mcblocks:Oak_Wood 4 //U
11+
12+
or with optional preprocessor commands
13+
#if MORETREES
14+
18 4,12 default:leaves 1
15+
#else
16+
17 default:tree // TODO: Trunk orientation
17+
#endif
18+
19+
!!!! WHITESPACE TYPE (space or tab) IS CRITICAL:- !!!!
20+
21+
({tab})MCID({space}MCData1(,MCData2(...))){tab}MTnodename({space}param2){tab}<==Everything beyond this tab is ignored.
22+
Tab characters at the beginning of the line are ignored.
23+
It is critical that tabs and spaces not be mixed up or the line won't be recognised correctly,
24+
and the parsing may fail to progress beyond that point.
25+
26+
MCID and MCData must be separated by a space/s.
27+
MCData1,2,etc must be separated by commas but no spaces.
28+
There must also be no spaces before MCID or between MCData and the following tab.
29+
MCData must not be >=16, or the remainder of the file will be totally ignored.
30+
MCID/Data and MTnodename are separated by tabs.
31+
MTnodename and param2 are separated by a space/s.
32+
If MCData1 is omitted, the line will match MCIDs with MCData values from 0-15 (and any subsequent entries will be ignored)
33+
Any data following '//' is parsed and not processed
34+
preprocessor commands #if {NAME}, #else and #endif are recognised and intervening lines will be parsed
35+
out or retained dependant on flags in the content.read_content call
36+
37+
Extra reference documentation:
38+
https://github.com/minetest/minetest/blob/2992b774fe65410a8acd3d06ae82dcd1eb260413/doc/lua_api.txt#L905
39+
http://dev.minetest.net/minetest.dir_to_wallmounted
40+
http://dev.minetest.net/minetest.dir_to_facedir
41+
===============================================================================
42+
Minetest uses these values for Wall-Mounted nodes(eg. torches, vines, etc..).
43+
Note that for Y values; it equates to which half of an air node it's in.
44+
Example:
45+
Ladders attached to the bottom of blocks are in the upper half of an air node. Hence are, 0.
46+
Ladders attached to the top of blocks are in the lower half of an air node. Hence are, 1.
47+
param2 direction
48+
0 //U +Y
49+
1 //D -Y
50+
4 //N +Z
51+
2 //E +x
52+
5 //S -Z
53+
3 //W -X
54+
55+
56+
--------------------------------------------------------------------------------
57+
Minetest uses these values for nodebox face directions(eg. chests, Jack O'Lanterns, etc..).
58+
Values range from 0-23, and involve multiple vectors/rotations.
59+
A node's param2 value direction is dependent on a player's face direction.
60+
(ie. A player faces North, but a Jack O'Lantern faces South towards the player with a param2 value of '0'.)
61+
Default values for a node; vector pointing upwards:
62+
param2 direction
63+
0 //N
64+
1 //E
65+
2 //S
66+
3 //W
67+
68+
------------------------
69+
Vectors:
70+
------------------------
71+
Vector points Up; rotation is around the North/South/East/West faces.
72+
0,1,2,3
73+
Vector points North; rotation is around the East/West/Up/Down faces.
74+
4,5,6,7
75+
Vector points South; rotation is around the East/West/Up/Down faces.
76+
8,9,10,11
77+
Vector points East; rotation is around the North/South/Up/Down faces.
78+
12,13,14,15
79+
Vector points West; rotation is around the North/South/Up/Down faces.
80+
16,17,18,19
81+
Vector points Down; rotation is around the North/South/East/West faces.
82+
20,21,22,23
83+
------------------------
84+
Faces:
85+
------------------------
86+
Player faces Down, node(eg. Jack O'Lantern) faces Upwards.
87+
0 degree: 4
88+
90 degree: 13
89+
180 degree: 10
90+
270 degree: 19
91+
92+
Player faces Up, Jack O'Lantern faces Downwards.
93+
0 degree: 8
94+
90 degree: 15
95+
180 degree: 6
96+
270 degree: 17
97+
98+
Player faces North, Jack O'Lantern faces South.
99+
0 degree: 0
100+
90 degree: 12
101+
180 degree: 20
102+
270 degree: 16
103+
104+
Player faces East, Jack O'Lantern faces West.
105+
0 degree: 1
106+
90 degree: 9
107+
180 degree: 23
108+
270 degree: 5
109+
110+
Player faces South, Jack O'Lantern faces North.
111+
0 degree: 2
112+
90 degree: 18
113+
180 degree: 22
114+
270 degree: 14
115+
116+
Player faces West, Jack O'Lantern faces East.
117+
0 degree: 3
118+
90 degree: 7
119+
180 degree: 21
120+
270 degree: 11
121+
122+
123+
--------------------------------------------------------------------------------
124+
Lastly, it appears some Minecraft Blockstates can be converted to data values.
125+
At least blockstates for axes(eg. Purpur Pillar, Bone Block, etc..).
126+
Example:
127+
Purpur pillar; default & on its side facing N,E,S,W; blockstate translation for X,Y,Z axes.
128+
202 0 mcl_end:purpur_pillar //Default, vector pointing upward, with a MC blockstate for Y
129+
202 4 mcl_end:purpur_pillar 12 //East,West pointing vectors with a MC blockstate for X
130+
202 8 mcl_end:purpur_pillar 6 //North,South pointing vectors with a MC blockstate for Z
131+
132+
=====================================================================================

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,38 @@ script without any parameters. This takes you through a bunch of
5656
screens that you can use to select a world and configure a few
5757
settings.
5858

59+
60+
# Extra Notes:
61+
62+
Now allows a choice of conversion to Minetest Game or MineClone2.
63+
Currrently compatible with Minecraft Worlds up to, & including v1.12.2
64+
65+
66+
##### Coordinate Conversion from Minecraft to Minetest:
67+
```
68+
X = Approximately the same in both.
69+
Y = Approximately -64 nodes.
70+
Z = The number is approximately inverted.
71+
72+
Example of converted coordinates:
73+
Minecraft: 704, 4, -318
74+
Minetest: 720, -60, 334
75+
```
76+
77+
78+
##### For previously converted worlds in Minetest v5.x:
79+
Take note that Minetest v5.x will now spam errors related to the lightfix code in the converted world's "/worldmods/mcimport/init.lua" file.
80+
81+
Example Warning Message:
82+
```
83+
WARNING[Emerge-0]: VoxelManip:set_lighting called for a non-mapgen VoxelManip object
84+
```
85+
86+
It's recommended to comment it out to avoid this issue.
87+
```
88+
-- vm:set_lighting({day = 15, night = 0}, minp, maxp)
89+
```
90+
5991
# License:
6092

6193
Copyright (C) 2016 - Nore, dgm555, sofar and others

block.py

+37-3
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,6 @@ def isdoor(b):
270270
# rotate lily pads randomly
271271
elif blocks[i] == 111:
272272
param2[i] = random.randint(0,3)
273-
# melon/pumpkin blocks
274-
elif blocks[i] == 86 or blocks[i] == 103:
275-
param2[i] = random.randint(0,23)
276273
# grass of varying length randomly
277274
elif blocks[i] == 31 and data[i] == 1:
278275
content[i], param2[i] = conversion_table[931][random.randint(0,4)]
@@ -290,6 +287,43 @@ def isdoor(b):
290287
alt = 964
291288
if blocks[i] == 71:
292289
alt = 966
290+
if blocks[i] == 193:
291+
alt = 968
292+
if blocks[i] == 194:
293+
alt = 970
294+
if blocks[i] == 195:
295+
alt = 972
296+
if blocks[i] == 196:
297+
alt = 974
298+
if blocks[i] == 197:
299+
alt = 976
300+
content[i], param2[i] = conversion_table[alt][d_face|d_open|(d_right<<3)]
301+
if d_right == 1:
302+
self.metadata[(i & 0xf, (i>>8) & 0xf, (i>>4) & 0xf)] = ({ "right": "1" }, {})
303+
# re-add code for converting top part of door for MineClone2, ignored for Minetest Game
304+
elif isdoor(blocks[i]) and data[i] >= 8: # top part
305+
below = i - 256
306+
if (below < 0):
307+
logger.warning('Unable to fix door - bottom part is across block boundary! (%d < 0)' % below)
308+
elif isdoor(blocks[below]) and data[below] >= 8:
309+
logger.warning('Unable to fix door - top part 0x%x below top part 0x%x!', data[i], data[below])
310+
else:
311+
d_right = data[i] & 1 # 0 - left, 1 - right
312+
d_open = data[below] & 4 # 0 - closed, 1 - open
313+
d_face = data[below] & 3 # n,e,s,w orientation
314+
alt = 965
315+
if blocks[i] == 71:
316+
alt = 967
317+
if blocks[i] == 193:
318+
alt = 969
319+
if blocks[i] == 194:
320+
alt = 971
321+
if blocks[i] == 195:
322+
alt = 973
323+
if blocks[i] == 196:
324+
alt = 975
325+
if blocks[i] == 197:
326+
alt = 977
293327
content[i], param2[i] = conversion_table[alt][d_face|d_open|(d_right<<3)]
294328
if d_right == 1:
295329
self.metadata[(i & 0xf, (i>>8) & 0xf, (i>>4) & 0xf)] = ({ "right": "1" }, {})

content.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#!/bin/env python
2+
3+
import os
4+
15

26
def preprocess(lines, flags):
37
output = []
@@ -33,8 +37,13 @@ def get_id(name_id_mapping, name):
3337
name_id_mapping.append(name)
3438
return len(name_id_mapping)-1
3539

40+
if os.environ["GAME_ID"] == "MTG":
41+
map_content_gameID = "map_content.txt"
42+
elif os.environ["GAME_ID"] == "MCL2":
43+
map_content_gameID = "mcl2_map_content.txt"
44+
3645
def read_content(flags):
37-
with open("map_content.txt", "r") as f:
46+
with open(map_content_gameID, "r") as f:
3847
lines = f.readlines()
3948

4049
lines = preprocess(lines, flags)

0 commit comments

Comments
 (0)