#Advanced tooltips (hold shift to show more for example)

66 messages · Page 1 of 1 (latest)

subtle scarab
#

I did this before in 1.20.1 forge, however in neoforge it has changed.
this is the ol' 1.20.1 forge script that I need to convert to neoforge 1.21.1

ItemEvents.tooltip(event => {
    event.addAdvanced(["createbb:cyanide"], (item, advanced, text) => {
        text.add(1, [
            Text.of('You should probably not consume this.').red()
        ])
        if (!event.isShift()) {
            text.add(2, [
                Text.of('Hold ').gold(),
                Text.of('[Shift] ').yellow(),
                Text.of('to see description').gold()
            ])
        } else if (event.isShift()) {
            text.add(2, [
                text.of('Can be combined with any food item.')
            ])
        }
    })
})
empty knollBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

vernal pine
#

the event was renamed to ItemEvents.modifyTooltips

#

try that and see if it works

subtle scarab
#

gotta be something else

#
 event.add("createbb:cyanide", text)
#

hol up

vernal pine
#

well at least the event is working, leme see the functions

#

try the modify functions

#
public void modify(Ingredient filter, Consumer<TextActionBuilder> consumer)
subtle scarab
#

i c

#

consumer.dynamic expects an id
and consumer.add is prob just this

        consumer.add(1, [
            Text.of('hi').red()
        ])
#

where would I even get shift from

vernal pine
#

um

#

wait

#

what do you get when you try the dynamicTooltips event instead of modifyTooltips

#

that one has a bunch of stuff hmmm

subtle scarab
#

idk what extra is tho

vernal pine
#

where do you see extra hmmm

subtle scarab
#

extra can't be the item right

vernal pine
#

oh

#

wait

subtle scarab
vernal pine
#

EventTargetType hmmm

#

i think its like 'item'

subtle scarab
#

oh

vernal pine
#

cuz in jei you can have items, fluids, entities, etc

#

im assuming

subtle scarab
#

ohhhhhh

#

maybe so

#

I'll try

#

but like

#

where do I define what item

vernal pine
#

um

#

im a bit confused myself, this event looks completely different from all other events in the source code

#

maybe try an if statement with item
something like

if (event.item.id == 'minecraft:stick') {
  event.add('tooltip text')
}
subtle scarab
#
ItemEvents.dynamicTooltips("item", event => {
    if (event.item.id == 'minecraft:stick') {
        event.add([
            Text.of('This is a stick.').gray()
        ])
    }
})

tried this and that and it didn't show anything

vernal pine
#

leme try it in a test instance

subtle scarab
#

I did both reload and f3 + t

vernal pine
#

so it should be something like this

ItemEvents.modifyTooltips(e => {
  e.modify('minecraft:stick', 'shift', [
    Text.of('This is a stick.').gray()
  ])
})

but i cant figure out what should go in place of the "shift"

#
public void add(Ingredient filter, TooltipRequirements requirements, List<Component> text)

thats the method, with the requirements

#

but like.. wtf is this XD

#

does your probe show how to use it

#

assuming youre using probe

azure mantle
#

In place of TooltipRequirements, you pass in a JS object as it's a record

#

Like { shift: true } to make the tooltip appear with shift pressed

vernal pine
#

oh hmmm

azure mantle
#

true -> Tristate.TRUE
false -> Tristate.FALSE
null -> Tristate.DEFAULT
Strings "false", 'true', 'default' also work from my memory

subtle scarab
#

erm erm erm

vernal pine
# subtle scarab erm erm erm
ItemEvents.modifyTooltips(e => {
  e.modify('minecraft:stick', { shift: true }, [
    Text.of('This is a stick.').gray()
  ])
})
subtle scarab
#

oh

subtle scarab
# vernal pine ```js ItemEvents.modifyTooltips(e => { e.modify('minecraft:stick', { shift: tr...
[31May2026 19:11:52.701] [Render thread/ERROR][KubeJS Client/]: createbb_client.js#6: Error in 'ItemEvents.modifyTooltips': dev.latvian.mods.rhino.EvaluatorException: Cannot convert [literal{This is a stick.}[style={color=gray}]] to java.util.function.Consumer
[31May2026 19:11:52.707] [Render thread/ERROR][KubeJS Client/]: …rhino.EvaluatorException: Cannot convert [literal{This is a stick.}[style={color=gray}]] to java.util.function.Consumer (client_scripts:createbb_client.js#6)
#

Gulp

azure mantle
#
ItemEvents.modifyTooltips(e => {
  e.modify('minecraft:stick', { shift: true }, text => {
    text.add([Text.of('This is a stick.').gray()])
  })
})
subtle scarab