-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.py
117 lines (98 loc) · 3.22 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
import json
level_1_mobs = [
'zombie',
'skeleton',
'creeper',
'spider',
'cow',
'chicken',
'pig',
'sheep',
'cod',
'salmon',
'squid',
'bee',
'bat',
'rabbit',
'horse'
]
level_2_mobs = [
'axolotl',
'glow_squid',
'goat',
'enderman',
'dolphin',
'drowned',
'witch',
'iron_golem',
'piglin',
'hoglin',
'ghast',
'strider',
'magma_cube',
'zombified_piglin'
]
level_3_mobs = [
'zoglin',
'blaze',
'wither_skeleton',
'piglin_brute',
'guardian'
]
scores = [
1, 3, 10
]
all_mobs = level_1_mobs + level_2_mobs + level_3_mobs
def get_display_name(mob):
return mob.replace('_', ' ').title()
def get_level(mob):
if mob in level_1_mobs:
return 1
elif mob in level_2_mobs:
return 2
elif mob in level_3_mobs:
return 3
return 0
def get_scoreboard_name(mob):
return 'md_' + mob[:12]
with open('data/mob_dash/functions/create_target_scoreboards.mcfunction', 'w') as file:
file.write('# Create all target scoreboards (auto-generated file)\n\n')
for mob in all_mobs:
display_name = get_display_name(mob)
scoreboard_name = get_scoreboard_name(mob)
file.write('scoreboard objectives add ' + scoreboard_name + ' minecraft.killed:minecraft.' + mob + ' "Mob Dash ' + display_name + ' Kills"\n')
with open('data/mob_dash/functions/create_targets.mcfunction', 'w') as file:
file.write('# Create target data (auto-generated file)\n\n')
i = 1
for mob in all_mobs:
display_name = get_display_name(mob)
level = get_level(mob)
extra_tags = ''
if i < 3:
extra_tags = ',"md_random"'
if i < 2:
extra_tags += ',"md_true"'
file.write('summon area_effect_cloud ~ 1 ~ {Duration:2147483647,Tags:["md_target","md_level_' + str(level) + '"' + extra_tags + '], CustomName:\'"' + display_name + '"\', Color:' + str(i) + '}\n')
i += 1
file.write('\nexecute as @e[type=area_effect_cloud,tag=md_target] store result score @s md_target run data get entity @s Color\n')
for i in range(1, 4):
file.write('scoreboard players set @e[type=area_effect_cloud,tag=md_level_' + str(i) + '] md_level ' + str(i) + '\n')
file.write('scoreboard players set @e[type=area_effect_cloud,tag=md_level_' + str(i) + '] md_reward ' + str(scores[i - 1]) + '\n')
with open('data/mob_dash/functions/detect_kill.mcfunction', 'w') as file:
file.write('# Detect if a target has been killed (auto-generated file)\n\n')
i = 1
for mob in all_mobs:
scoreboard_name = get_scoreboard_name(mob)
file.write('execute if score $Target md_state matches ' + str(i) + ' as @a[scores={' + scoreboard_name + '=1..}] run function mob_dash:award_kill\n')
file.write('scoreboard players reset * ' + scoreboard_name + '\n')
i += 1
with open('tiers.md', 'w') as file:
file.write('### Tier 1\n')
for mob in level_1_mobs:
file.write(f'- {get_display_name(mob)}\n')
file.write('\n### Tier 2\n')
for mob in level_2_mobs:
file.write(f'- {get_display_name(mob)}\n')
file.write('\n### Tier 3\n')
for mob in level_3_mobs:
file.write(f'- {get_display_name(mob)}\n')