Skip to content

Commit 9a3b525

Browse files
committed
✨ Improved tellraw messages
1 parent d8dbdbd commit 9a3b525

File tree

8 files changed

+79
-45
lines changed

8 files changed

+79
-45
lines changed

src/systems/datapackCompiler/1.20.4/animation.mcb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dir global {
4545
dir errors {
4646
function function_not_executed_as_root_entity {
4747
#ARGS: {export_namespace: string, function_path: string}
48-
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)', TAGS.PROJECT_ROOT('$(export_namespace)'))%>
48+
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
4949
}
5050
}
5151
}
@@ -144,7 +144,7 @@ dir <%export_namespace%> {
144144
execute store result storage aj:temp y int 1 store result score #this.y aj.i run data get entity @s Pos[1] 1
145145
execute store result storage aj:temp z int 1 store result score #this.z aj.i run data get entity @s Pos[2] 1
146146
block outdated_tellraw { with storage aj:temp
147-
$tellraw @a <%TELLRAW.RIG_OUTDATED(export_namespace)%>
147+
$tellraw @a <%TELLRAW.RIG_OUTDATED()%>
148148
}
149149
data modify entity @s data.rigHash set value '<%rigHash%>'
150150
execute on passengers run data merge entity @s {Glowing: 1b, glow_color_override: <%0xff0000%>}

src/systems/datapackCompiler/1.20.4/static.mcb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dir global {
3838
dir errors {
3939
function function_not_executed_as_root_entity {
4040
#ARGS: {export_namespace: string, function_path: string}
41-
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)', TAGS.PROJECT_ROOT('$(export_namespace)'))%>
41+
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
4242
}
4343
}
4444
}
@@ -122,7 +122,7 @@ dir <%export_namespace%> {
122122
execute store result storage aj:temp y int 1 store result score #this.y aj.i run data get entity @s Pos[1] 1
123123
execute store result storage aj:temp z int 1 store result score #this.z aj.i run data get entity @s Pos[2] 1
124124
block outdated_tellraw { with storage aj:temp
125-
$tellraw @a <%TELLRAW.RIG_OUTDATED(export_namespace)%>
125+
$tellraw @a <%TELLRAW.RIG_OUTDATED()%>
126126
}
127127
data modify entity @s data.rigHash set value '<%rigHash%>'
128128
execute on passengers run data merge entity @s {Glowing: 1b, glow_color_override: <%0xff0000%>}

src/systems/datapackCompiler/1.20.5/animation.mcb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dir global {
4545
dir errors {
4646
function function_not_executed_as_root_entity {
4747
#ARGS: {export_namespace: string, function_path: string}
48-
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)', TAGS.PROJECT_ROOT('$(export_namespace)'))%>
48+
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
4949
}
5050
}
5151
}
@@ -144,7 +144,7 @@ dir <%export_namespace%> {
144144
execute store result storage aj:temp y int 1 store result score #this.y aj.i run data get entity @s Pos[1] 1
145145
execute store result storage aj:temp z int 1 store result score #this.z aj.i run data get entity @s Pos[2] 1
146146
block outdated_tellraw { with storage aj:temp
147-
$tellraw @a <%TELLRAW.RIG_OUTDATED(export_namespace)%>
147+
$tellraw @a <%TELLRAW.RIG_OUTDATED()%>
148148
}
149149
data modify entity @s data.rigHash set value '<%rigHash%>'
150150
execute on passengers run data merge entity @s {Glowing: 1b, glow_color_override: <%0xff0000%>}

src/systems/datapackCompiler/1.20.5/static.mcb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dir global {
3838
dir errors {
3939
function function_not_executed_as_root_entity {
4040
#ARGS: {export_namespace: string, function_path: string}
41-
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)', TAGS.PROJECT_ROOT('$(export_namespace)'))%>
41+
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
4242
}
4343
}
4444
}
@@ -122,7 +122,7 @@ dir <%export_namespace%> {
122122
execute store result storage aj:temp y int 1 store result score #this.y aj.i run data get entity @s Pos[1] 1
123123
execute store result storage aj:temp z int 1 store result score #this.z aj.i run data get entity @s Pos[2] 1
124124
block outdated_tellraw { with storage aj:temp
125-
$tellraw @a <%TELLRAW.RIG_OUTDATED(export_namespace)%>
125+
$tellraw @a <%TELLRAW.RIG_OUTDATED()%>
126126
}
127127
data modify entity @s data.rigHash set value '<%rigHash%>'
128128
execute on passengers run data merge entity @s {Glowing: 1b, glow_color_override: <%0xff0000%>}

src/systems/datapackCompiler/1.21.2/animation.mcb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dir global {
4545
dir errors {
4646
function function_not_executed_as_root_entity {
4747
#ARGS: {export_namespace: string, function_path: string}
48-
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)', TAGS.PROJECT_ROOT('$(export_namespace)'))%>
48+
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
4949
}
5050
}
5151
}
@@ -144,7 +144,7 @@ dir <%export_namespace%> {
144144
execute store result storage aj:temp y int 1 store result score #this.y aj.i run data get entity @s Pos[1] 1
145145
execute store result storage aj:temp z int 1 store result score #this.z aj.i run data get entity @s Pos[2] 1
146146
block outdated_tellraw { with storage aj:temp
147-
$tellraw @a <%TELLRAW.RIG_OUTDATED(export_namespace)%>
147+
$tellraw @a <%TELLRAW.RIG_OUTDATED()%>
148148
}
149149
data modify entity @s data.rigHash set value '<%rigHash%>'
150150
execute on passengers run data merge entity @s {Glowing: 1b, glow_color_override: <%0xff0000%>}

src/systems/datapackCompiler/1.21.2/static.mcb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dir global {
3838
dir errors {
3939
function function_not_executed_as_root_entity {
4040
#ARGS: {export_namespace: string, function_path: string}
41-
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)', TAGS.PROJECT_ROOT('$(export_namespace)'))%>
41+
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
4242
}
4343
}
4444
}
@@ -122,7 +122,7 @@ dir <%export_namespace%> {
122122
execute store result storage aj:temp y int 1 store result score #this.y aj.i run data get entity @s Pos[1] 1
123123
execute store result storage aj:temp z int 1 store result score #this.z aj.i run data get entity @s Pos[2] 1
124124
block outdated_tellraw { with storage aj:temp
125-
$tellraw @a <%TELLRAW.RIG_OUTDATED(export_namespace)%>
125+
$tellraw @a <%TELLRAW.RIG_OUTDATED()%>
126126
}
127127
data modify entity @s data.rigHash set value '<%rigHash%>'
128128
execute on passengers run data merge entity @s {Glowing: 1b, glow_color_override: <%0xff0000%>}

src/systems/datapackCompiler/index.ts

Lines changed: 64 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,43 @@ namespace OBJECTIVES {
8585
// ▓ □〓≡ ╝╚╔╗╬ ╓ ╩┌ ┐└ ┘ ↑ ↓ → ← ↔ ▀▐ ░ ▒▬ ♦ ◘
8686
// → ✎ ❣ ✚ ✔ ✖ ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ⊻ ⊼ ⊽ ⋃ ⌀ ⌂
8787

88-
const TELLRAW_PREFIX = new JsonText([
89-
{ text: '[', color: 'gray' },
90-
{ text: 'AJ', color: 'aqua' },
91-
{ text: '] ' },
92-
])
88+
const TELLRAW_PREFIX = () =>
89+
new JsonText([
90+
{ text: '\n[', color: 'gray' },
91+
{ text: 'AJ', color: 'aqua' },
92+
'] ',
93+
[
94+
{ text: '(from ', color: 'gray', italic: true },
95+
Project!.animated_java.export_namespace,
96+
')',
97+
],
98+
' -> ',
99+
])
100+
101+
const TELLRAW_ERROR_PREFIX = () =>
102+
new JsonText([TELLRAW_PREFIX(), { text: 'ERROR: ', color: 'red' }, '\n '])
103+
104+
const TELLRAW_SUFFIX = () => new JsonText(['\n'])
105+
106+
const TELLRAW_LEARN_MORE_LINK = (url: string) =>
107+
new JsonText([
108+
'\n ',
109+
{
110+
text: 'Click here to learn more',
111+
color: 'blue',
112+
underlined: true,
113+
italic: true,
114+
clickEvent: { action: 'open_url', value: url },
115+
},
116+
])
93117

94118
namespace TELLRAW {
95-
export const RIG_OUTDATED = (exportNamespace: string) =>
119+
export const RIG_OUTDATED = () =>
96120
new JsonText([
97121
'',
98-
TELLRAW_PREFIX,
99-
{ text: 'Error: ', color: 'red' },
122+
TELLRAW_ERROR_PREFIX(),
100123
{ text: 'The ', color: 'red' },
101-
{ text: exportNamespace, color: 'yellow' },
124+
{ text: Project!.animated_java.export_namespace, color: 'yellow' },
102125
{ text: ' rig instance at', color: 'red' },
103126
[
104127
{ text: ' [', color: 'yellow' },
@@ -123,6 +146,9 @@ namespace TELLRAW {
123146
color: 'aqua',
124147
underlined: true,
125148
},
149+
// '\n',
150+
// TELLRAW_LEARN_MORE_LINK(''),
151+
TELLRAW_SUFFIX(),
126152
])
127153
export const RIG_OUTDATED_TEXT_DISPLAY = () =>
128154
new JsonText([
@@ -132,35 +158,42 @@ namespace TELLRAW {
132158
color: 'red',
133159
},
134160
])
135-
export const FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR = (functionName: string, rootTag: string) =>
161+
export const FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR = (functionName: string) =>
136162
new JsonText([
137163
'',
138-
TELLRAW_PREFIX,
139-
{ text: 'Error: ', color: 'red' },
140-
{ text: 'The function ', color: 'red' },
141-
{ text: functionName, color: 'yellow' },
142-
{ text: ' must be executed as the root entity.', color: 'red' },
143-
{ text: '\n You can use ', color: 'red' },
144-
{ text: `execute as @e[tag=${rootTag}] run ...`, color: 'aqua' },
145-
{ text: ' to run the function as the root.', color: 'red' },
164+
TELLRAW_ERROR_PREFIX(),
165+
{
166+
text: 'This function',
167+
color: 'blue',
168+
underlined: true,
169+
hoverEvent: {
170+
action: 'show_text',
171+
contents: [{ text: functionName, color: 'yellow' }],
172+
},
173+
},
174+
{ text: " must be executed as the rig's root entity.", color: 'red' },
175+
'\n',
176+
TELLRAW_LEARN_MORE_LINK(
177+
'https://animated-java.dev/docs/exported-rigs/controlling-a-rig-instance'
178+
),
179+
TELLRAW_SUFFIX(),
146180
])
147181
// Summon Function
148182
export const VARIANT_CANNOT_BE_EMPTY = () =>
149183
new JsonText([
150184
'',
151-
TELLRAW_PREFIX,
152-
{ text: 'Error: ', color: 'red' },
185+
TELLRAW_ERROR_PREFIX(),
153186
{ text: 'variant', color: 'yellow' },
154187
{ text: ' cannot be an empty string.', color: 'red' },
188+
TELLRAW_SUFFIX(),
155189
])
156190
export const INVALID_VARIANT = (
157191
variantName: string,
158192
variants: Record<string, IRenderedVariant>
159193
) =>
160194
new JsonText([
161195
'',
162-
TELLRAW_PREFIX,
163-
{ text: 'Error: ', color: 'red' },
196+
TELLRAW_ERROR_PREFIX(),
164197
{ text: 'The variant ', color: 'red' },
165198
{ text: variantName, color: 'yellow' },
166199
{ text: ' does not exist.', color: 'red' },
@@ -177,28 +210,28 @@ namespace TELLRAW {
177210
{ text: variant.name, color: 'yellow' },
178211
])
179212
),
213+
TELLRAW_SUFFIX(),
180214
])
181215
export const ANIMATION_CANNOT_BE_EMPTY = () =>
182216
new JsonText([
183217
'',
184-
TELLRAW_PREFIX,
185-
{ text: 'Error: ', color: 'red' },
218+
TELLRAW_ERROR_PREFIX(),
186219
{ text: 'animation', color: 'yellow' },
187220
{ text: ' cannot be an empty string.', color: 'red' },
221+
TELLRAW_SUFFIX(),
188222
])
189223
export const FRAME_CANNOT_BE_NEGATIVE = () =>
190224
new JsonText([
191225
'',
192-
TELLRAW_PREFIX,
193-
{ text: 'Error: ', color: 'red' },
226+
TELLRAW_ERROR_PREFIX(),
194227
{ text: 'frame', color: 'yellow' },
195228
{ text: ' must be a non-negative integer.', color: 'red' },
229+
TELLRAW_SUFFIX(),
196230
])
197231
export const INVALID_ANIMATION = (animationName: string, animations: IRenderedAnimation[]) =>
198232
new JsonText([
199233
'',
200-
TELLRAW_PREFIX,
201-
{ text: 'Error: ', color: 'red' },
234+
TELLRAW_ERROR_PREFIX(),
202235
{ text: 'The animation ', color: 'red' },
203236
{ text: animationName, color: 'yellow' },
204237
{ text: ' does not exist.', color: 'red' },
@@ -215,13 +248,14 @@ namespace TELLRAW {
215248
{ text: anim.safe_name, color: 'yellow' },
216249
])
217250
),
251+
TELLRAW_SUFFIX(),
218252
])
219253
export const NO_VARIANTS = () =>
220254
new JsonText([
221255
'',
222-
TELLRAW_PREFIX,
223-
{ text: 'Error: ', color: 'red' },
256+
TELLRAW_ERROR_PREFIX(),
224257
{ text: 'No variants are available.', color: 'red' },
258+
TELLRAW_SUFFIX(),
225259
])
226260
}
227261

test_blueprints/armor_stand.ajblueprint

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"meta": {
33
"format": "animated_java_blueprint",
4-
"format_version": "1.4.2",
4+
"format_version": "1.5.1",
55
"uuid": "167b27cd-b559-3f13-a97c-0841fe21f1d1",
66
"save_location": "D:\\github-repos\\animated-java\\animated-java\\test_blueprints\\armor_stand.ajblueprint",
77
"last_used_export_namespace": "armor_stand"
@@ -14,7 +14,7 @@
1414
"enable_plugin_mode": false,
1515
"resource_pack_export_mode": "raw",
1616
"data_pack_export_mode": "raw",
17-
"target_minecraft_version": "1.21.2",
17+
"target_minecraft_version": "1.21.0",
1818
"display_item": "minecraft:white_dye",
1919
"custom_model_data_offset": 0,
2020
"enable_advanced_resource_pack_settings": false,
@@ -1502,7 +1502,7 @@
15021502
"default": {
15031503
"name": "default",
15041504
"display_name": "Default",
1505-
"uuid": "f4dcc928-5c84-758e-5d82-b98c3df3433e",
1505+
"uuid": "b50c8aba-ac7c-5591-10e0-1ee8c74df465",
15061506
"texture_map": {},
15071507
"excluded_nodes": [],
15081508
"is_default": true

0 commit comments

Comments
 (0)