Skip to content

Commit

Permalink
✨ Improved tellraw messages
Browse files Browse the repository at this point in the history
  • Loading branch information
SnaveSutit committed Nov 1, 2024
1 parent d8dbdbd commit 9a3b525
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 45 deletions.
4 changes: 2 additions & 2 deletions src/systems/datapackCompiler/1.20.4/animation.mcb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dir global {
dir errors {
function function_not_executed_as_root_entity {
#ARGS: {export_namespace: string, function_path: string}
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)', TAGS.PROJECT_ROOT('$(export_namespace)'))%>
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
}
}
}
Expand Down Expand Up @@ -144,7 +144,7 @@ dir <%export_namespace%> {
execute store result storage aj:temp y int 1 store result score #this.y aj.i run data get entity @s Pos[1] 1
execute store result storage aj:temp z int 1 store result score #this.z aj.i run data get entity @s Pos[2] 1
block outdated_tellraw { with storage aj:temp
$tellraw @a <%TELLRAW.RIG_OUTDATED(export_namespace)%>
$tellraw @a <%TELLRAW.RIG_OUTDATED()%>
}
data modify entity @s data.rigHash set value '<%rigHash%>'
execute on passengers run data merge entity @s {Glowing: 1b, glow_color_override: <%0xff0000%>}
Expand Down
4 changes: 2 additions & 2 deletions src/systems/datapackCompiler/1.20.4/static.mcb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dir global {
dir errors {
function function_not_executed_as_root_entity {
#ARGS: {export_namespace: string, function_path: string}
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)', TAGS.PROJECT_ROOT('$(export_namespace)'))%>
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
}
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ dir <%export_namespace%> {
execute store result storage aj:temp y int 1 store result score #this.y aj.i run data get entity @s Pos[1] 1
execute store result storage aj:temp z int 1 store result score #this.z aj.i run data get entity @s Pos[2] 1
block outdated_tellraw { with storage aj:temp
$tellraw @a <%TELLRAW.RIG_OUTDATED(export_namespace)%>
$tellraw @a <%TELLRAW.RIG_OUTDATED()%>
}
data modify entity @s data.rigHash set value '<%rigHash%>'
execute on passengers run data merge entity @s {Glowing: 1b, glow_color_override: <%0xff0000%>}
Expand Down
4 changes: 2 additions & 2 deletions src/systems/datapackCompiler/1.20.5/animation.mcb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dir global {
dir errors {
function function_not_executed_as_root_entity {
#ARGS: {export_namespace: string, function_path: string}
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)', TAGS.PROJECT_ROOT('$(export_namespace)'))%>
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
}
}
}
Expand Down Expand Up @@ -144,7 +144,7 @@ dir <%export_namespace%> {
execute store result storage aj:temp y int 1 store result score #this.y aj.i run data get entity @s Pos[1] 1
execute store result storage aj:temp z int 1 store result score #this.z aj.i run data get entity @s Pos[2] 1
block outdated_tellraw { with storage aj:temp
$tellraw @a <%TELLRAW.RIG_OUTDATED(export_namespace)%>
$tellraw @a <%TELLRAW.RIG_OUTDATED()%>
}
data modify entity @s data.rigHash set value '<%rigHash%>'
execute on passengers run data merge entity @s {Glowing: 1b, glow_color_override: <%0xff0000%>}
Expand Down
4 changes: 2 additions & 2 deletions src/systems/datapackCompiler/1.20.5/static.mcb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dir global {
dir errors {
function function_not_executed_as_root_entity {
#ARGS: {export_namespace: string, function_path: string}
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)', TAGS.PROJECT_ROOT('$(export_namespace)'))%>
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
}
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ dir <%export_namespace%> {
execute store result storage aj:temp y int 1 store result score #this.y aj.i run data get entity @s Pos[1] 1
execute store result storage aj:temp z int 1 store result score #this.z aj.i run data get entity @s Pos[2] 1
block outdated_tellraw { with storage aj:temp
$tellraw @a <%TELLRAW.RIG_OUTDATED(export_namespace)%>
$tellraw @a <%TELLRAW.RIG_OUTDATED()%>
}
data modify entity @s data.rigHash set value '<%rigHash%>'
execute on passengers run data merge entity @s {Glowing: 1b, glow_color_override: <%0xff0000%>}
Expand Down
4 changes: 2 additions & 2 deletions src/systems/datapackCompiler/1.21.2/animation.mcb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dir global {
dir errors {
function function_not_executed_as_root_entity {
#ARGS: {export_namespace: string, function_path: string}
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)', TAGS.PROJECT_ROOT('$(export_namespace)'))%>
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
}
}
}
Expand Down Expand Up @@ -144,7 +144,7 @@ dir <%export_namespace%> {
execute store result storage aj:temp y int 1 store result score #this.y aj.i run data get entity @s Pos[1] 1
execute store result storage aj:temp z int 1 store result score #this.z aj.i run data get entity @s Pos[2] 1
block outdated_tellraw { with storage aj:temp
$tellraw @a <%TELLRAW.RIG_OUTDATED(export_namespace)%>
$tellraw @a <%TELLRAW.RIG_OUTDATED()%>
}
data modify entity @s data.rigHash set value '<%rigHash%>'
execute on passengers run data merge entity @s {Glowing: 1b, glow_color_override: <%0xff0000%>}
Expand Down
4 changes: 2 additions & 2 deletions src/systems/datapackCompiler/1.21.2/static.mcb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dir global {
dir errors {
function function_not_executed_as_root_entity {
#ARGS: {export_namespace: string, function_path: string}
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)', TAGS.PROJECT_ROOT('$(export_namespace)'))%>
$tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
}
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ dir <%export_namespace%> {
execute store result storage aj:temp y int 1 store result score #this.y aj.i run data get entity @s Pos[1] 1
execute store result storage aj:temp z int 1 store result score #this.z aj.i run data get entity @s Pos[2] 1
block outdated_tellraw { with storage aj:temp
$tellraw @a <%TELLRAW.RIG_OUTDATED(export_namespace)%>
$tellraw @a <%TELLRAW.RIG_OUTDATED()%>
}
data modify entity @s data.rigHash set value '<%rigHash%>'
execute on passengers run data merge entity @s {Glowing: 1b, glow_color_override: <%0xff0000%>}
Expand Down
94 changes: 64 additions & 30 deletions src/systems/datapackCompiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,43 @@ namespace OBJECTIVES {
// ▓ □〓≡ ╝╚╔╗╬ ╓ ╩┌ ┐└ ┘ ↑ ↓ → ← ↔ ▀▐ ░ ▒▬ ♦ ◘
// → ✎ ❣ ✚ ✔ ✖ ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ⊻ ⊼ ⊽ ⋃ ⌀ ⌂

const TELLRAW_PREFIX = new JsonText([
{ text: '[', color: 'gray' },
{ text: 'AJ', color: 'aqua' },
{ text: '] ' },
])
const TELLRAW_PREFIX = () =>
new JsonText([
{ text: '\n[', color: 'gray' },
{ text: 'AJ', color: 'aqua' },
'] ',
[
{ text: '(from ', color: 'gray', italic: true },
Project!.animated_java.export_namespace,
')',
],
' -> ',
])

const TELLRAW_ERROR_PREFIX = () =>
new JsonText([TELLRAW_PREFIX(), { text: 'ERROR: ', color: 'red' }, '\n '])

const TELLRAW_SUFFIX = () => new JsonText(['\n'])

const TELLRAW_LEARN_MORE_LINK = (url: string) =>
new JsonText([
'\n ',
{
text: 'Click here to learn more',
color: 'blue',
underlined: true,
italic: true,
clickEvent: { action: 'open_url', value: url },
},
])

namespace TELLRAW {
export const RIG_OUTDATED = (exportNamespace: string) =>
export const RIG_OUTDATED = () =>
new JsonText([
'',
TELLRAW_PREFIX,
{ text: 'Error: ', color: 'red' },
TELLRAW_ERROR_PREFIX(),
{ text: 'The ', color: 'red' },
{ text: exportNamespace, color: 'yellow' },
{ text: Project!.animated_java.export_namespace, color: 'yellow' },
{ text: ' rig instance at', color: 'red' },
[
{ text: ' [', color: 'yellow' },
Expand All @@ -123,6 +146,9 @@ namespace TELLRAW {
color: 'aqua',
underlined: true,
},
// '\n',
// TELLRAW_LEARN_MORE_LINK(''),
TELLRAW_SUFFIX(),
])
export const RIG_OUTDATED_TEXT_DISPLAY = () =>
new JsonText([
Expand All @@ -132,35 +158,42 @@ namespace TELLRAW {
color: 'red',
},
])
export const FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR = (functionName: string, rootTag: string) =>
export const FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR = (functionName: string) =>
new JsonText([
'',
TELLRAW_PREFIX,
{ text: 'Error: ', color: 'red' },
{ text: 'The function ', color: 'red' },
{ text: functionName, color: 'yellow' },
{ text: ' must be executed as the root entity.', color: 'red' },
{ text: '\n You can use ', color: 'red' },
{ text: `execute as @e[tag=${rootTag}] run ...`, color: 'aqua' },
{ text: ' to run the function as the root.', color: 'red' },
TELLRAW_ERROR_PREFIX(),
{
text: 'This function',
color: 'blue',
underlined: true,
hoverEvent: {
action: 'show_text',
contents: [{ text: functionName, color: 'yellow' }],
},
},
{ text: " must be executed as the rig's root entity.", color: 'red' },
'\n',
TELLRAW_LEARN_MORE_LINK(
'https://animated-java.dev/docs/exported-rigs/controlling-a-rig-instance'
),
TELLRAW_SUFFIX(),
])
// Summon Function
export const VARIANT_CANNOT_BE_EMPTY = () =>
new JsonText([
'',
TELLRAW_PREFIX,
{ text: 'Error: ', color: 'red' },
TELLRAW_ERROR_PREFIX(),
{ text: 'variant', color: 'yellow' },
{ text: ' cannot be an empty string.', color: 'red' },
TELLRAW_SUFFIX(),
])
export const INVALID_VARIANT = (
variantName: string,
variants: Record<string, IRenderedVariant>
) =>
new JsonText([
'',
TELLRAW_PREFIX,
{ text: 'Error: ', color: 'red' },
TELLRAW_ERROR_PREFIX(),
{ text: 'The variant ', color: 'red' },
{ text: variantName, color: 'yellow' },
{ text: ' does not exist.', color: 'red' },
Expand All @@ -177,28 +210,28 @@ namespace TELLRAW {
{ text: variant.name, color: 'yellow' },
])
),
TELLRAW_SUFFIX(),
])
export const ANIMATION_CANNOT_BE_EMPTY = () =>
new JsonText([
'',
TELLRAW_PREFIX,
{ text: 'Error: ', color: 'red' },
TELLRAW_ERROR_PREFIX(),
{ text: 'animation', color: 'yellow' },
{ text: ' cannot be an empty string.', color: 'red' },
TELLRAW_SUFFIX(),
])
export const FRAME_CANNOT_BE_NEGATIVE = () =>
new JsonText([
'',
TELLRAW_PREFIX,
{ text: 'Error: ', color: 'red' },
TELLRAW_ERROR_PREFIX(),
{ text: 'frame', color: 'yellow' },
{ text: ' must be a non-negative integer.', color: 'red' },
TELLRAW_SUFFIX(),
])
export const INVALID_ANIMATION = (animationName: string, animations: IRenderedAnimation[]) =>
new JsonText([
'',
TELLRAW_PREFIX,
{ text: 'Error: ', color: 'red' },
TELLRAW_ERROR_PREFIX(),
{ text: 'The animation ', color: 'red' },
{ text: animationName, color: 'yellow' },
{ text: ' does not exist.', color: 'red' },
Expand All @@ -215,13 +248,14 @@ namespace TELLRAW {
{ text: anim.safe_name, color: 'yellow' },
])
),
TELLRAW_SUFFIX(),
])
export const NO_VARIANTS = () =>
new JsonText([
'',
TELLRAW_PREFIX,
{ text: 'Error: ', color: 'red' },
TELLRAW_ERROR_PREFIX(),
{ text: 'No variants are available.', color: 'red' },
TELLRAW_SUFFIX(),
])
}

Expand Down
6 changes: 3 additions & 3 deletions test_blueprints/armor_stand.ajblueprint
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"meta": {
"format": "animated_java_blueprint",
"format_version": "1.4.2",
"format_version": "1.5.1",
"uuid": "167b27cd-b559-3f13-a97c-0841fe21f1d1",
"save_location": "D:\\github-repos\\animated-java\\animated-java\\test_blueprints\\armor_stand.ajblueprint",
"last_used_export_namespace": "armor_stand"
Expand All @@ -14,7 +14,7 @@
"enable_plugin_mode": false,
"resource_pack_export_mode": "raw",
"data_pack_export_mode": "raw",
"target_minecraft_version": "1.21.2",
"target_minecraft_version": "1.21.0",
"display_item": "minecraft:white_dye",
"custom_model_data_offset": 0,
"enable_advanced_resource_pack_settings": false,
Expand Down Expand Up @@ -1502,7 +1502,7 @@
"default": {
"name": "default",
"display_name": "Default",
"uuid": "f4dcc928-5c84-758e-5d82-b98c3df3433e",
"uuid": "b50c8aba-ac7c-5591-10e0-1ee8c74df465",
"texture_map": {},
"excluded_nodes": [],
"is_default": true
Expand Down

0 comments on commit 9a3b525

Please sign in to comment.