mojira.dev
MC-117360

gameLoopFunction function runs after entities were updated while command blocks run before

The bug

The gameLoopFunction function runs after entities were updated while command blocks run before entities are updated. This makes it difficult to convert command block commands to function commands and vice versa.

How to reproduce

  1. Place a repeating command block with the following command

    /scoreboard players tag @e add hurt {HurtTime:10s}
  2. Place two always active chain command blocks with the following commands behind it

    /say @e[tag=hurt]
    /scoreboard players tag @e[tag=hurt] remove hurt
  3. Power the repeating command block and hit a mob
    → The command block says the name of the mob you hit

  4. Place the attached function

[media]
  1. in the following directory of your world folder

    data/functions/custom
  2. Set the function custom:hurt_test as gameLoopFunction

    /gamerule gameLoopFunction custom:hurt_test
  3. Hit a mob
    → The function does not say the name of the mob; changing the NBT test to HurtTime:9s solves this

Linked issues

Attachments

Comments 2

Solution: run functions in a repeating command block if it's important to run them before the entity updates.
Functions are not a replacement for command blocks, they are an addition.

Is there any reason why gameLoopFunction functions have to run at this position? Placing a repeating command block in your world just to make sure a function is activated at the right time can be pretty annoying since:

  • you need to find to spawn chunks

  • changing the function name requires you to find the command block and change it there again

  • it requires enable-command-block to be true (likely not needed for functions themself) even though you only want to use functions

Functions are not a replacement for command blocks, they are an addition.

Currently it is likely the case that many players try to convert command block commands to functions and this behavior makes it pretty difficult to do this.

Additionally I am pretty sure while building with command blocks and using functions you might switch because something works better with command blocks respectively functions and you want to test which way works the best.

Emlyn

michael

Confirmed

command_block, entity, function, gameLoopFunction

Minecraft 1.12 Pre-Release 1, Minecraft 1.12 Pre-Release 2

Retrieved