-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.py
140 lines (126 loc) · 4.13 KB
/
generate.py
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import json
scoreboard_types = {}
scoreboard_seen = []
scoreboard_counter = 0
def get_id(type):
return type.lower().replace(' ', '_')
def get_scoreboard_id(type_name):
type = get_id(type_name)
if type in scoreboard_types.keys():
return scoreboard_types[type]
short = type[0:12]
if short in scoreboard_seen:
short = type[0:10] + str(scoreboard_counter)
scoreboard_counter += 1
scoreboard_seen.append(short)
scoreboard_types[type] = short
return short
def write_predicate(mob_type):
data = {
'condition': 'value_check',
'value': {
'type': 'score',
'score': 'ew_temp',
'target': {
'type': 'fixed',
'name': '$' + get_id(mob_type)
}
},
'range': {
'min': {
'type': 'score',
'score': 'ew_temp',
'target': {
'type': 'fixed',
'name': '$Max'
}
}
}
}
with open('data/ew/predicates/types/' + get_id(mob_type) + '.json', 'w') as file:
json.dump(data, file, indent=4)
def write_function(type):
with open('data/ew/functions/types/' + get_id(type) + '.mcfunction', 'w') as file:
file.write('# ' + type + ' killed!\n')
file.write('execute store result score $Count ew_temp run data get storage ew:temp tag.kills.' + get_id(type) + ' 1\n')
file.write('scoreboard players operation $Count ew_temp += @s ew_' + get_scoreboard_id(type) + '\n')
file.write('execute store result storage ew:temp tag.kills.' + get_id(type) + ' int 1 run scoreboard players get $Count ew_temp\n')
file.write('scoreboard players reset @s ew_' + get_scoreboard_id(type) + '\n')
def get_copy_score_line(type):
return 'execute store result score $' + get_id(type) + ' ew_temp run data get storage ew:temp tag.kills.' + get_id(type) + ' 1'
def get_dispatch_line(type):
return 'execute if score @s ew_' + get_scoreboard_id(type) + ' matches 1.. run function ew:types/' + get_id(type)
def get_scoreboard_line(type):
return 'scoreboard objectives add ew_' + get_scoreboard_id(type) + ' minecraft.killed:minecraft.' + get_id(type) + ' "' + type + ' Killed"'
def get_lore_table(type):
lore = []
for i in range(5):
lore.append({
'function': 'set_lore',
'entity': 'this',
'conditions': [
{
'condition': 'reference',
'name': 'ew:types/' + get_id(type)
},
{
'condition': 'reference',
'name': 'ew:level' + str(i + 1)
}
],
'lore': [
{
'nbt': get_id(type) + '[' + str(i) + ']',
'storage': 'ew:lore',
'color': 'white'
}
],
'replace': True
})
return lore
types = [
'Blaze',
'Cave Spider',
'Creeper',
'Drowned',
'Enderman',
'Endermite',
'Evoker',
'Ghast',
'Guardian',
'Hoglin',
'Husk',
'Magma Cube',
'Phantom',
'Piglin',
'Piglin Brute',
'Pillager',
'Ravager',
'Shulker',
'Silverfish',
'Skeleton',
'Slime',
'Spider',
'Stray',
'Vex',
'Vindicator',
'Witch',
'Wither Skeleton',
'Zoglin',
'Zombie',
'Zombie Villager',
'Zombified Piglin'
]
set_lore = []
with open('data/ew/functions/copy_kill_scores.mcfunction', 'w') as kill_file,\
open('data/ew/functions/dispatch_types.mcfunction', 'w') as dispatch_file,\
open('data/ew/functions/create_type_scoreboards.mcfunction', 'w') as scoreboard_file:
for type in types:
write_predicate(type)
write_function(type)
kill_file.write(get_copy_score_line(type) + '\n')
dispatch_file.write(get_dispatch_line(type) + '\n')
scoreboard_file.write(get_scoreboard_line(type) + '\n')
set_lore.extend(get_lore_table(type))
with open('data/ew/item_modifiers/set_lore.json', 'w') as lore_file:
json.dump(set_lore, lore_file, indent=4)