-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgenerate-ore-jsons.elv
executable file
·67 lines (58 loc) · 1.5 KB
/
generate-ore-jsons.elv
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
65
66
67
#!/usr/bin/env elvish
# SPDX-FileCopyrightText: 2023 Janet Blackquill <[email protected]>
#
# SPDX-License-Identifier: MIT
var variants = [raw nugget ingot]
var ironOres = [
&adamantite=10
&arilla=20
&mythril=30
&orichalcum=40
&palladium=50
]
var ironBases = [raw_iron iron_nugget iron_ingot]
fn makeFolders { |ores|
var keyed = [(keys $ores)]
for key $keyed {
mkdir -p assets/civcubed/models/ores/$key
mkdir -p assets/civcubed/textures/ores/$key
for variant $variants {
var json = [
&parent=minecraft:item/generated
&textures=[
&layer0=civcubed:ores/$key/$variant
]
]
put $json | to-json | jq . > assets/civcubed/models/ores/$key/$variant.json
touch assets/civcubed/textures/ores/$key/$variant.png
}
}
}
fn makeMinecraft { |ores bases|
var num = 0
for base $bases {
if (eq $base _) {
set num = (+ $num 1)
continue
}
var baseJson = [
&parent=minecraft:item/generated
&textures=[
&layer0=minecraft:item/$base
]
&overrides=[(keys $ores | order &less-than={ |a b|
< (+ $ores[$a] $num) (+ $ores[$b] $num)
} | each { |key|
put [&predicate=[&custom_model_data=(+ $ores[$key] $num)] &model=civcubed:ores/$key/$variants[$num]]
})]
]
put $baseJson | to-json | jq . > assets/minecraft/models/item/$base.json
set num = (+ $num 1)
}
var keyed = [(keys $ores)]
for key $keyed {
var value = $ores[$key]
}
}
for kind [$ironOres] { makeFolders $kind }
for tuple [[$ironOres $ironBases]] { makeMinecraft $tuple[0] $tuple[1] }