#send from startup to server

35 messages · Page 1 of 1 (latest)

tulip dagger
#

i hate that i have to restart the game every time i want to try anything in this code is there a way to code on server instead?

const GunReloadEvent = Java.loadClass("com.tacz.guns.api.event.common.GunReloadEvent");
ForgeEvents.onEvent(GunReloadEvent, event => {
    if (!event.getLogicalSide().isServer()) return;

    const entity = event.getEntity()
    const item = event.getGunItemStack()

    console.log(`${entity.getName().getString()} reloaded ${item.id}`)
    
})```
sinful gullBOT
#

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

onyx pike
#

you can do a little trick leme show

#
const GunReloadEvent = Java.loadClass("com.tacz.guns.api.event.common.GunReloadEvent")

let gunReload = (event) => {
  if (!event.getLogicalSide().isServer()) return

  const entity = event.getEntity()
  const item = event.getGunItemStack()

  console.log(`${entity.getName().getString()} reloaded ${item.id}`)
}

ForgeEvents.onEvent(GunReloadEvent, event => gunReload(event))
#

and if im not wrong, you should be able to do /kubejs reload startup_scripts

tulip dagger
onyx pike
#

hmm

tulip dagger
#

i was working on my script while waiting just with restarting so this is what it is now

let gunReload = (event) => {
    if (!event.getLogicalSide().isServer()) return;
    const entity = event.getEntity()
    const item = event.getGunItemStack()
    const server = entity.level.getServer()
    console.log(`${entity.getName().getString()} reloaded ${item.id}`)
    server.runCommandSilent(`say testing`)
    shellData.forEach(shell => {

        server.runCommandSilent(
            `summon item ${entity.x} ${entity.y+1} ${entity.z} {Item:{id:"kubejs:casing_45_70",Count:1b,tag:{myGun:"${shell.gunID}"}},PickupDelay:40}`
        )
    })
}

ForgeEvents.onEvent(GunReloadEvent, event => gunReload(event))

did i do something wrong?

onyx pike
#

it didnt print the testing part?

#

wait

#

hol up

tulip dagger
#

no, it was "test" and i canged it to "testing" in the runtime but that didnt work

#

oki

onyx pike
#

what happens if you add and then change an actual console.log()

#

i dont know if server.runCommandSilent() would even work here cuz its not the KJS class

#

i'll check the javadocs hmmm

tulip dagger
#

ti does

onyx pike
#

hm it doesnt exist in the base minecraft

tulip dagger
#

it spawns it

#

i changed it to say reloading but it still says reloaded

#

[27/02/2026 15:57:39 PM] [Server thread/INFO] MINECRAFTUSERNAME reloaded tacz:modern_kinetic_gun

junior shoalBOT
#

Global functions allow you to reload startup scripts via /kubejs reload startup_scripts command.
This avoids having to constantly restart your game to reload your scripts.

onyx pike
#

try this

#

this is what i was trying to do from memory

tulip dagger
#

ok

#

1 min

#

i dont quite understand that to put where
like he uses .onEntityColision but i need something spesific to the mod dont it?

#

he also uses event.modify

waxen locust
#

the main point is that Liopyu is using global functions to keep things reloadable

tulip dagger
#

im trying to figure out how to do exactly that with my code, what do i get from you saying that

#

tbh i didnt really care

onyx pike
#
global.gunReload = (event) => {
    if (!event.getLogicalSide().isServer()) return
    const entity = event.getEntity()
    const item = event.getGunItemStack()
    const server = entity.level.getServer()
    console.log(`${entity.getName().getString()} reloaded ${item.id}`)
    server.runCommandSilent(`say testing`)
    shellData.forEach(shell => {

        server.runCommandSilent(
            `summon item ${entity.x} ${entity.y+1} ${entity.z} {Item:{id:"kubejs:casing_45_70",Count:1b,tag:{myGun:"${shell.gunID}"}},PickupDelay:40}`
        )
    })
}

ForgeEvents.onEvent(GunReloadEvent, event => global.gunReload(event))
tulip dagger
#

omg it works

#

TYSM!!