generated from UniversalMinecraftTool/extension-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
64 lines (59 loc) · 1.3 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
NBT_Value_to_Text = {
styler = {
type = EXTENSION_TYPE.NBT_EDITOR_STYLE,
recursive = true
}
}
NBT_Value_to_Text.valueMappings = {
rain = {
[0] = "no rain",
[1] = "rain"
},
hardcore = {
[0] = "false",
[1] = "true"
},
initialized = {
[0] = "false",
[1] = "true"
},
allowCommands = {
[0] = "false",
[1] = "true"
},
DifficultyLocked = {
[0] = "false",
[1] = "true"
},
raining = {
[0] = "false",
[1] = "true"
},
thundering = {
[0] = "false",
[1] = "true"
},
wasModded = {
[0] = "false",
[1] = "true"
}
}
function NBT_Value_to_Text:convertValue(key, value)
local mappings = self.valueMappings[key]
return mappings and mappings[value] or value
end
function NBT_Value_to_Text:convertNBTValues(root, context)
self:traverseNBT(root, context)
end
function NBT_Value_to_Text:traverseNBT(node, context)
if type(node) == "table" then
for key, value in pairs(node) do
if type(value) == "table" then
self:traverseNBT(value, context)
else
node[key] = self:convertValue(key, value)
end
end
end
end
return NBT_Value_to_Text