{{" />
your current location:首页 > news>Kubejs [timing instruction] [KJS] Kubejs Minecraft Game

Kubejs [timing instruction] [KJS] Kubejs Minecraft Game

2024-12-10 17:52:52|Myriagame |source:minecraft skins

Code: It is suitable for Kubejs, which is suitable for version 1.18. The low version needs to change the level.

 var cNT = 0;

Onevent ("Level.Tick", (Event) => {

If (event.level.localtime%24000 == 6000)

CNT ++;

if (cNT == 3)

{{

event.server.runcommandsilent (`say 12:00 now`)

cnt = 0;

}

})

Effect: At 12:00 on the mc day (tick = 6000), execute instructions `say 12:00 now`

Note:

First, event.Level.LocalTime%24000 == 6000, first make mold transportation and then determine the reason for tick.

A mc day is 24000tick. If it is simply written as event.level.localtime == 6000 will only be judged to pass at 12:00 on the 0th day of the 0th day;

Second, why should you add a counting variable CNT, because the judgment and execution of the Kubejs incident are executed 3 times per TICK, that is, the game time is passed by the 6000Tick time event judgment, and the statement will be executed 3 times in total;

If you do n’t need CNT, instructions `say 12:00 Now` will be executed 3 times; the number of times the execution of the sentence execution through variable CNT statistics, then run at 3 times` say 12:00 now`, then reset the CNT, the event executionAfter 3 times, the game time will become 6001Tick, and the judgment will not pass again afterwards;