#Finding events & their methods in the KubeJS source?

45 messages · Page 1 of 1 (latest)

drifting pulsar
#

Hi. It's me. I'm back. Again. Really want to emphasize I am not looking for ProbeJS support. It breaks for me regardless of configuration, and not everyone on the modpack team wants to use VScode!

AFAIK the github source is a recommended place to look for documentation in lieu of a functional wiki for <1.19, and I want to know where to find the methods and classes that each event has access to.

rancid hullBOT
#

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

drifting pulsar
#

Finding events & their methods in the KubeJS source?

drifting pulsar
tidal cosmos
#

you can see the function names there

#

so for instance getEntity() or short is .entity

shell pumiceBOT
#

Kubejs has a feature known as beans which allows you to make scripts a tad more readable.
Anything getXy() can be gotten with xy, anything setXy(value) can be set with xy = value and anything isXy() can be checked with just xy.

This allows us to shorten our code! For example, to get a list of all online players you can do: event.getServer().getPlayers(). With beans this can be shortened to event.server.players!

Note that get and is beans only work if the method has no parameters. This means a method like getHeldItem(InteractionHand hand) cannot be shortened to heldItem.
For set the method needs to have a single parameter.

tranquil mountain
tidal cosmos
#

notepad++

tranquil mountain
#

🤷‍♂️

drifting pulsar
#

I know, but I would really rather be able to find it in the source

drifting pulsar
tranquil mountain
#

lol

drifting pulsar
tranquil mountain
#

i mean if youre looking for a set list of handlers i doubt there is one, its pretty much just lat and max putting it together like how you see in the source code like how .teleport was

#

player.tick probably inherits a lot of the other event functions

#

inherits player

drifting pulsar
#

oh youre so right

tranquil mountain
#

ye

#

really it isnt even event based

#

its object based

#

event. gives out player,server ect

#

event.player gives out username level ect

#

across events

#

if that makes sense

drifting pulsar
#

no yeah it didn't occur to me, had a bit of a brainfart

#

i do some modding myself im not sure why i hadn't realized

tranquil mountain
#

lol

#

happens Xd

#

so i mean if you were to do the Object log for event.player then those are the objects useable universally

#

same with the git documentation

#

tho im sure you realize all that now lol

drifting pulsar
#

mhm

tidal cosmos
#

for most stuff you have to look at forge/fabric

shell pumiceBOT
#

You can find online JavaDocs for Forge/NeoForge and Fabric by clicking the button.
If you want to see classes added by Minecraft, choose Forge/NeoForge.

If the page doesn't load, click the "Status" button or ping @tidal cosmos.

drifting pulsar
#

wait can i really just grab stuff from the fabric api like that with kubejs?

#

or am i misunderstanding

tranquil mountain
#

you can reflect classes

tidal cosmos
#

as an example, if you have event.entity, you can use any method from the LivingEntity class and such

#

depends on the event too ofc

drifting pulsar
#

that's v cool

#

alright
gonna close the thread 'cuz i've found out what i needed, thank you for the help!