Skip to content

Commit d387a2d

Browse files
committed
🐛 Fix interaction error tellraw before 1.21.5
- SNBT text components failed to parse, so the interaction functions never loaded - helper serializes the component per target version
1 parent 0c8d1f7 commit d387a2d

5 files changed

Lines changed: 20 additions & 44 deletions

File tree

‎src/systems/datapackCompiler/1.20.4/global.mcb‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,17 +329,7 @@ dir global {
329329
$$(on_<%direction === 'interaction' ? 'interact' : 'attack'%>_function)
330330
scoreboard players set #check <%OBJECTIVES.I()%> 1
331331
}
332-
execute if score #check <%OBJECTIVES.I()%> matches 0 run tellraw @a [ \
333-
{text: '', color: red}, \
334-
{text:'ɪɴᴛᴇʀᴀᴄᴛɪᴏɴꜱ', color:'light_purple'}, \
335-
{text:'\n(<%global.root%>.mcb)', color:'dark_gray'}, \
336-
'\n→ ᴇʀʀᴏʀ:\n\sFailed to handle <%direction === 'interaction' ? 'right' : 'left'%> click interaction from ', \
337-
{selector: '@p[tag=<%TAGS.INTERACTING_PLAYER()%>]', color: gold}, \
338-
':\n\s\sInvalid command: ', \
339-
{nbt: 'data.animated_java.on_<%direction === 'interaction' ? 'interact' : 'attack'%>_function', entity: '@s', color: aqua}, \
340-
'\n\s\sfrom ', \
341-
{text: 'data.animated_java.on_<%direction === 'interaction' ? 'interact' : 'attack'%>_function ', color: yellow}, \
342-
]
332+
execute if score #check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.INTERACTION_FUNCTION_FAILED(direction)%>
343333
# Only remove the interaction if it's consumed.
344334
data remove entity @s <%direction%>
345335
}

‎src/systems/datapackCompiler/1.21.0/global.mcb‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -331,17 +331,7 @@ dir global {
331331
$$(on_<%direction === 'interaction' ? 'interact' : 'attack'%>_function)
332332
scoreboard players set #check <%OBJECTIVES.I()%> 1
333333
}
334-
execute if score #check <%OBJECTIVES.I()%> matches 0 run tellraw @a [ \
335-
{text: '', color: red}, \
336-
{text:'ɪɴᴛᴇʀᴀᴄᴛɪᴏɴꜱ', color:'light_purple'}, \
337-
{text:'\n(<%global.root%>.mcb)', color:'dark_gray'}, \
338-
'\n→ ᴇʀʀᴏʀ:\n\sFailed to handle <%direction === 'interaction' ? 'right' : 'left'%> click interaction from ', \
339-
{selector: '@p[tag=<%TAGS.INTERACTING_PLAYER()%>]', color: gold}, \
340-
':\n\s\sInvalid command: ', \
341-
{nbt: 'data.animated_java.on_<%direction === 'interaction' ? 'interact' : 'attack'%>_function', entity: '@s', color: aqua}, \
342-
'\n\s\sfrom ', \
343-
{text: 'data.animated_java.on_<%direction === 'interaction' ? 'interact' : 'attack'%>_function ', color: yellow}, \
344-
]
334+
execute if score #check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.INTERACTION_FUNCTION_FAILED(direction)%>
345335
# Only remove the interaction if it's consumed.
346336
data remove entity @s <%direction%>
347337
}

‎src/systems/datapackCompiler/1.21.5/global.mcb‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,7 @@ dir global {
345345
$$(on_<%direction === 'interaction' ? 'interact' : 'attack'%>_function)
346346
scoreboard players set #check <%OBJECTIVES.I()%> 1
347347
}
348-
execute if score #check <%OBJECTIVES.I()%> matches 0 run tellraw @a [ \
349-
{text: '', color: red}, \
350-
{text:'ɪɴᴛᴇʀᴀᴄᴛɪᴏɴꜱ', color:'light_purple'}, \
351-
{text:'\n(<%global.root%>.mcb)', color:'dark_gray'}, \
352-
'\n→ ᴇʀʀᴏʀ:\n\sFailed to handle <%direction === 'interaction' ? 'right' : 'left'%> click interaction from ', \
353-
{selector: '@p[tag=<%TAGS.INTERACTING_PLAYER()%>]', color: gold}, \
354-
':\n\s\sInvalid command: ', \
355-
{nbt: 'data.animated_java.on_<%direction === 'interaction' ? 'interact' : 'attack'%>_function', entity: '@s', color: aqua}, \
356-
'\n\s\sfrom ', \
357-
{text: 'data.animated_java.on_<%direction === 'interaction' ? 'interact' : 'attack'%>_function ', color: yellow}, \
358-
]
348+
execute if score #check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.INTERACTION_FUNCTION_FAILED(direction)%>
359349
# Only remove the interaction if it's consumed.
360350
data remove entity @s <%direction%>
361351
}

‎src/systems/datapackCompiler/26.2/global.mcb‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,7 @@ dir global {
344344
$$(on_<%direction === 'interaction' ? 'interact' : 'attack'%>_function)
345345
scoreboard players set #check <%OBJECTIVES.I()%> 1
346346
}
347-
execute if score #check <%OBJECTIVES.I()%> matches 0 run tellraw @a [ \
348-
{text: '', color: red}, \
349-
{text:'ɪɴᴛᴇʀᴀᴄᴛɪᴏɴꜱ', color:'light_purple'}, \
350-
{text:'\n(<%global.root%>.mcb)', color:'dark_gray'}, \
351-
'\n→ ᴇʀʀᴏʀ:\n\sFailed to handle <%direction === 'interaction' ? 'right' : 'left'%> click interaction from ', \
352-
{selector: '@p[tag=<%TAGS.INTERACTING_PLAYER()%>]', color: gold}, \
353-
':\n\s\sInvalid command: ', \
354-
{nbt: 'data.animated_java.on_<%direction === 'interaction' ? 'interact' : 'attack'%>_function', entity: '@s', color: aqua}, \
355-
'\n\s\sfrom ', \
356-
{text: 'data.animated_java.on_<%direction === 'interaction' ? 'interact' : 'attack'%>_function ', color: yellow}, \
357-
]
347+
execute if score #check <%OBJECTIVES.I()%> matches 0 run tellraw @a <%TELLRAW.INTERACTION_FUNCTION_FAILED(direction)%>
358348
# Only remove the interaction if it's consumed.
359349
data remove entity @s <%direction%>
360350
}

‎src/systems/datapackCompiler/tellraw.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { toSmallCaps } from '../../util/minecraftUtil'
44
import { type IRenderedAnimation } from '../animationRenderer'
55
import { type IRenderedVariant } from '../rigRenderer'
66
import OBJECTIVES from './objectives'
7+
import TAGS from './tags'
78

89
const TELLRAW_PREFIX = () =>
910
new TextComponent([
@@ -407,6 +408,21 @@ namespace TELLRAW {
407408
{ text: alternative, color: 'aqua' },
408409
' instead.',
409410
])
411+
412+
/** Shared by every blueprint, so it doesn't name one like {@link TELLRAW_PREFIX} does. */
413+
export const INTERACTION_FUNCTION_FAILED = (direction: 'interaction' | 'attack') => {
414+
const functionPath = `data.animated_java.on_${direction === 'interaction' ? 'interact' : 'attack'}_function`
415+
return new TextComponent([
416+
{ text: '', color: 'red' },
417+
{ text: toSmallCaps('Interactions'), color: 'light_purple' },
418+
`\n→ ${toSmallCaps('error')}:\n Failed to handle ${direction === 'interaction' ? 'right' : 'left'} click interaction from `,
419+
{ selector: `@p[tag=${TAGS.INTERACTING_PLAYER()}]`, color: 'gold' },
420+
':\n Invalid command: ',
421+
{ nbt: functionPath, entity: '@s', color: 'aqua' },
422+
'\n from ',
423+
{ text: functionPath, color: 'yellow' },
424+
])
425+
}
410426
}
411427

412428
export default TELLRAW

0 commit comments

Comments
 (0)