#Cant run command in forge event, just crashing the game.
27 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
You can write your code in a codeblock by typing it between the codeblock delimiters:
```js :arrow_left:
onEvent('recipes', e => {
e.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
``` :arrow_left:
As an example, :arrow_up: will look like this:
onEvent('recipes', e => {
e.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
Util.server.runCommandSilent('time set noon')
Strange
[21:57:03] [Server thread/ERROR] [minecraft/MinecraftServer]: Exception stopping the server
dev.latvian.mods.rhino.EcmaError: ReferenceError: "Util" is not defined. (server_scripts:script.js#22)
try Utils
its work perfectly now, i really appreciate your help 🙏
However, where can i get all utils.server methods?
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.
thanks 🙏
When i will done with all, i am going send finished work here
ok, guess i need a little bit more help, look
//server
global.WakeUp = (event) =>{
console.log('Worked')
//event.player.runCommand('dragon-altar')
Utils.server.runCommandSilent('execute as ${event.player.username} run dragon-altar')
}
How can i do a event.player.runCommandSilent?
Because when i try it, it just crash the game, as the event.server.runCommandSilent
it would be event.entity.runCommandSilent
you can't just expect variables to be there when you're not using kjs based events
Thanks for advice, now it works 🙏
you can look up events in the javadoc and see what's available
https://lexxie.site/forge-javadocs/1.19.2/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.html
you can see that you can do event.updateLevel(), event.wakeImmediately(), and because it's a PlayerEvent it inherits event.getEntity()
that's why event.server was also failing
Ok, now its really done, so when u tipsy and wake up, start's command that open GUI to change from human to dragon. Yes i spendet like 4-6 hours for that
. Thanks to everyone there who help me in that coward code 🙏
//server
global.WakeUp = (event) =>{
console.log('Worked')
//event.player.runCommand('dragon-altar') !!NOT WORK
//Utils.server.runCommandSilent('execute as ${event.player.name} run dragon-altar') !!NOT WORK
if(event.entity.hasEffect('brewinandchewin:tipsy')){
event.entity.runCommandSilent('dragon-altar')}
}
Ticket re-opened!
Ok i have one little question, how can i run that part with higher permission?
if(event.entity.hasEffect('brewinandchewin:tipsy')){
event.entity.runCommandSilent('dragon-altar')}
}
I mean, this command only for OP's, but i need run it for normal player
I can make it with luckyperms, but than player will be abile to use command on start
And when i tryed use
Utils.server.runCommandSilent('execute as ${playerName} run dragon-altar')
Server just dies
