#merge two Text. together in tooltips
17 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
idk about merging texts, but you can just use inline color codes
oh sorry forgot to close this
i found a solution
Following along with a tutorial from Sept of '23 and adjusting sections that don't work in the 1.21 version today. I've figured out most things on my own, but there's a section about tooltips that's got me stuck.
I can add multiple colors to one tooltip pretty concisely by blending old methods with the new events and arguments, but no matter what I try this first section always breaks into three separate lines.
ItemEvents.modifyTooltips(event => {
event.add('kubejs:face', Text.darkGreen(
"It's still you."
))
event.modify('kubejs:thermblock', {shift:false}, tooltip => {
tooltip.insert(1, [Text.of(`Hold `).gold(),
Text.of(`[Shoopt] `).aqua(),
Text.of(`to see description`).gold(),
])
})
event.modify('kubejs:thermblock', {shift:true}, tooltip => {
tooltip.insert(1, [
Text.of(`What fresh`).red(),
]),
tooltip.insert(2, [
Text.of(`hell is this?`).red(),
])
})
[➤](#1298529434416054303 message)
Following along with a tutorial from Sept of '23 and adjusting sections that don't work in the 1.21 version today. I've figured out most things on my own, but there's a section about tooltips that's got me stuck.
I can add multiple colors to one tooltip pretty concisely by blending old methods with the new events and arguments, but no matter what I try this first section always breaks into three separate lines.
ItemEvents.modifyTooltips(event => {
event.add('kubejs:face', Text.darkGreen(
"It's still you."
))
event.modify('kubejs:thermblock', {shift:false}, tooltip => {
tooltip.insert(1, [Text.of(`Hold `).gold(),
Text.of(`[Shoopt] `).aqua(),
Text.of(`to see description`).gold(),
])
})
event.modify('kubejs:thermblock', {shift:true}, tooltip => {
tooltip.insert(1, [
Text.of(`What fresh`).red(),
]),
tooltip.insert(2, [
Text.of(`hell is this?`).red(),
])
})
Ticket closed!
you can also use these https://htmlcolorcodes.com/minecraft-color-codes/
§0this text is black, §1this one dark blue```
Please don't, these are legacy format codes
Instead, use:
Text.ofString('Red text').color('red').append(Text.ofString('Green text').color('green')),
Benefit of that is that you can set any color, not just 16 legacy format colors
For example:
ItemEvents.modifyTooltips(event => {
event.add('minecraft:stone', [
Text.ofString('Red text').color('red').append(Text.ofString('Green text').color('green')),
])
})
results in:
You can also append to empty component if you don't want first component's settings to be inherited:
ItemEvents.modifyTooltips(event => {
event.add('minecraft:stone', [
Text.empty()
.append(Text.ofString('Red text').color('red'))
.append(Text.ofString('Green text').color('green')),
])
})
Compare to the case where you start with a text component with text that you formatted:
ItemEvents.modifyTooltips(event => {
event.add('minecraft:stone', [
Text.ofString('Red text')
.color('red')
.bold()
.append(Text.ofString('Green text').color('green')),
])
})