mojira.dev
MC-297656

Setblock commands don't register inside scheduled functions

When scheduling a function in a datapack using the “schedule” command, the setblock command doesn’t set the specified blocks, regardless of “replace”, “destroy”, “strict” etc. setting. It does work when using the normal “function” command

Comments 4

Are you using any relative coordinates in the command? Scheduled functions always execute at the world spawn.

Hello my name is David I usually help Mojira -look below-

If you're having trouble with setblock not working in a scheduled function, it's likely because of how the schedule command works. When you schedule a function, it runs later without any entity context, and in some cases, the chunk where the setblock should happen might not be loaded.

Here’s how to fix it:

1. Make sure the chunk is loaded — you can use forceload add x z to keep the area loaded.

2. Avoid relying on @s or any entity context — scheduled functions don’t have one unless you explicitly set it with execute.

3. If you're trying to run it from an entity (like a player or mob), use:

execute as @p at @s run schedule function yourpack:yourfunc 10t

4. You can add a debug message like say ran! in the scheduled function to confirm it’s executing.

I did not use any relative coordinates in the set lock command, the chunks were already forceloaded, I used no entity context, but ran the schedule command both from a datapack function and from the player terminal, neither worked. I also did make sure that the function was executing using tellraw, and that command worked

Would you be able to attach the data pack you are using?

Caleb Starkenburg

(Unassigned)

Unconfirmed

(Unassigned)

1.21.5

Retrieved