#Updated KubeJS, tooltip issues

122 messages · Page 1 of 1 (latest)

fossil plaza
#

So I have this script in client scripts

ItemEvents.modifyTooltips(event => {
  if (global.nukelist.length > 0) {
    event.add(global.nukelist, Text.red('This item has been disabled, if obtained please file a bug report')) 
  }
})

And I put an item into the nukelist, then I ran

  • /kubejs reload startup-scripts
  • /reload
  • /kubejs reload lang

However, the tooltip did not apply to the item

In KubeJS v2101.7.1-build.181, adding an item to the nukelist and running those commands would give that item the tooltip. However, in KubeJS v2101.7.2-build.348 this doesn't work anymore, and I need to run F3+T for it to work. Does anybody know if tooltips have changed sometime between these updates?

steady nimbusBOT
#

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

late mauve
#

How is global.nukelist defined?

#

Is it in a script that has high priority header?

#
// priority: 100
#

Because this might be an issue of how the scripts are ordered to run

fossil plaza
#

it doesn't have a priority header, but neither did it in the older version

#

but don't you think, even if it was running after the client script reload, the command order would rectify that?

late mauve
fossil plaza
#

wdym by initialising

#

@late mauve

#

just adding it to the top?

#

Startup Script

// priority: 100

global.nukelist = [
'minecraft:oak_planks'
]
late mauve
#

Show me your scripts

late mauve
#

If that's the whole script, that's fine

fossil plaza
#

there is more below

#

wait no, tere's more in a different file

late mauve
#

If you don't refer to things with lower priority, that's fine

#

To make sure you don't do that, just initialize all globals in scripts with high priority

fossil plaza
#

I have a server script which removes recipes and tags and stuff from items in the list

late mauve
#

And do everything else in scripts with normal priority

fossil plaza
late mauve
fossil plaza
#

so i've done this, but the tooltip still doesn't work?

#

this is after adding to that list, and running the commands

#

I can run F3+T to get the tooltip to apply, but it's weird it didn't already do this?

late mauve
#

BTW - why are you applying tooltips in client scripts instead of startup scripts anyway?

fossil plaza
#

i thought it was a clienty thing

#

can you reload tooltips within startup scripts during the game?

late mauve
#

I don't think so (why would you want to do that?)

#

Or wait, is tooltip modification even in startup?

fossil plaza
late mauve
#

I didn't use tooltips for so long

fossil plaza
late mauve
#

Also, can you log your global.nukelist or Ingredient.of(global.nukelist)?

#

To see what's going on here

fossil plaza
#

wdym

#

how do i do that

late mauve
#
console.log(global.nukelist)
console.log(Ingredient.of(global.nukelist))
fossil plaza
#

where should I put that

late mauve
#

Anywhere

fossil plaza
#

in the client script?

late mauve
#

Yes

#

I want to see what's going on here

#

This will print stuff into the console

fossil plaza
#

should i send the latest log then

late mauve
#

Yes

#
  Ingredient.of(global.nukelist).itemIds.forEach(itemID => {
    console.log(itemID)
  })
fossil plaza
hollow mothBOT
#

Paste version of mclo.gs/sp2zhMb from @fossil plaza

late mauve
#

I see no console logs here - maybe add some searchable log to see where the logging starts

fossil plaza
#

wdym

late mauve
#
console.log("Logging ingredient!")
fossil plaza
#

try search for "ok I've added spruce planks to the nukelist now, as a new thing to test"

#

i said that in chat before i reloaded if thats useful

late mauve
#

No

#

There are no logs coming from client scripts

fossil plaza
#

oh ok

#

well thats odd

late mauve
#
ItemEvents.modifyTooltips(event => {
  console.log("Logging ingredient!")
  Ingredient.of(global.nukelist).itemIds.forEach(itemID => {
    console.log(itemID)
  })
  if (global.nukelist.length > 0) {
    event.add(global.nukelist, Text.red('This item has been disabled, if obtained please file a bug report')) 
  }
})
#

Do it with this script

fossil plaza
hollow mothBOT
#

Paste version of mclo.gs/DzkY68d from @fossil plaza

late mauve
#

I cannot find the phrase "Logging ingredient!"

fossil plaza
#

i'll try add that same thing to the server script

#

to see if that works

#

well that showed up

late mauve
#

For me, it shows on client too

#
[11:06:06] [Render thread/INFO] [KubeJS Client/]: Logging ingredient!
[11:06:06] [Render thread/INFO] [KubeJS Client/]: minecraft:stone
#

And I have these scripts:

  • Startup script (the only one)
global.nukelist = [
  "minecraft:stone"
]
  • Client script
ItemEvents.modifyTooltips(event => {
  console.log("Logging ingredient!")
  Ingredient.of(global.nukelist).itemIds.forEach(itemID => {
    console.log(itemID)
  })
})
fossil plaza
#

you're on the same kubejs vrsions right

late mauve
#

KubeJS 2101.7.2-build.348

#

The newest one available

fossil plaza
#

yeah same

#
ItemEvents.modifyTooltips(event => {
  console.log("Logging ingredient!")
  Ingredient.of(global.nukelist).itemIds.forEach(itemID => {
    console.log(itemID)
  })
  if (global.nukelist.length > 0) {
    event.add(global.nukelist, Text.red('This item has been disabled, if obtained please file a bug report')) 
  }
})
#

if you put this in what does it do

late mauve
#

OK, did you make sure to save your files?\

fossil plaza
#

yeah pretty sure

late mauve
fossil plaza
#

i'm not sure where this came from in the log

late mauve
#

Oh, you found it

#

And now your script runs fine?

fossil plaza
#

yet the tooltips still aren't working

#

i might just quickly disable a tooltip mod i have installed in case that would do anything

#

which it shouldn't, given it worked on the older kubejs version, but still

late mauve
#

For me, it works fine even with more elements in the array

fossil plaza
late mauve
#

So I can't help much because it Works on my machine™

fossil plaza
#

well my tooltips work now, but it could be because i reloaded the entire game

#

i'll add something else to the list

late mauve
#

global is only assignable to in startup scripts

#

So reloading client scripts only if you change global won't change things inside global

fossil plaza
#

wdym

#

you mean i should reload startup scripts as well?

late mauve
#

Yes (if you change what's inside global)

fossil plaza
#

i do that already

#

so what files have you got?

#

that work

late mauve
#

The startup script:

global.nukelist = [
  "minecraft:stone",
  "minecraft:cobblestone",
  "minecraft:deepslate"
]

The client script:

ItemEvents.modifyTooltips(event => {
  console.log("Logging ingredient!")
  Ingredient.of(global.nukelist).itemIds.forEach(itemID => {
    console.log(itemID)
  })
  if (global.nukelist.length > 0) {
    event.add(global.nukelist, Text.red('This item has been disabled, if obtained please file a bug report')) 
  }
})
fossil plaza
#

yeah that doesn't work for me

#

would this somehow be screwing with it

#

F3+T still reloads the tooltips, but idk why reloading kubejs doesn't do that already

late mauve
#

Because /kubejs reload lang does not reload tooltip events

late mauve
#

F3 + T

fossil plaza
#

is that how you're reloading yours

late mauve
#

No, for me it works on initial load

#

Initial load should work too

fossil plaza
#

what commands are you runninh

late mauve
#

None

fossil plaza
#

are you restarting your entire game

late mauve
#

Yes

fossil plaza
#

ohh

#

well yeah that works for me too

#

i'm trying to get something where i can reload it midgame