Datapack with functions: commands by timer and at login

Datapacks

Timer and player login commandsLearn more

Write down the commands -- you get a date pack for Minecraft from 1.20 to 26.3, which executes it itself: once in N seconds, when the player enters the server, and when the world is downloaded. Free of plagins and command blocks.

My game select version

We'll remember in this browser and set up where your version is available. Open link settings are more important than this choice; the Vicki versions do not change.

By timer

0 - every tick, twenty times per second. Frequent values: 0 - every tick, 1 - 1 s, 5 - 5 s, 30 - 30 s, 60 - 1 min, 300 - 5 minutes, 600 - 10 minutes.

When a player enters

When loading the world

In Latin: this is the function namespace - my_pack:load.

Result

Example · Archive · my_pack-datapack.zip
Timer
every 10 minutes
Player Login
first
Game versions
1.21.9 — 26.3

data/minecraft/tags/function/load.json

Load tag: the game calls the function when loading the world and after /reload.

{
  "values": ["my_pack:load"]
}

data/minecraft/tags/function/tick.json

Tick tag: the function runs every tick - 20 times per second.

{
  "values": ["my_pack:tick"]
}

data/my_pack/function/load.mcfunction

When loading the world: your commands and starting the timer.

schedule function my_pack:timer 600s
say Датапак загружен

data/my_pack/function/tick.mcfunction

Each tick: commands by tick and check who entered.

execute as @a[tag=!my_pack_joined] at @s run function my_pack:join

data/my_pack/function/timer.mcfunction

Every 10 minutes, your commands and recording yourself in line again.

say Не забудьте проголосовать за сервер — /vote
schedule function my_pack:timer 600s

data/my_pack/function/join.mcfunction

For the logged-in player: commands come from his name and from his place (@s).

title @s title "Добро пожаловать!"
give @s minecraft:bread 8
tag @s add my_pack_joined
Download datapack

How to use

  1. Download the archive

    No need to unpack: the game reads the datapack directly from the zip.

  2. Place in the world folder

    On the server - world/datapacks, in single player - saves/<world>/datapacks.

  3. Reboot

    By command /reload or restart. The timer and login check will start on their own.

  4. Check

    /datapack list will show whether it is enabled, and /function my_pack:load - whether the function will execute without errors.

What you need to know

  • A timer is a schedule, not a tick counter. Function timer at the end puts itself in the queue again, and starts it the first time load. After /reload, the second circle will not appear: schedule by default replaces the previous one.
  • There is no “player logged in” event in the game. The first entry is caught by the mark my_pack_joined, which the newcomer does not yet have, and the repeater - according to the count leave_game: It grows when the player exits. The check occurs every tick and costs almost nothing.
  • Each tick is 20 times per second. It’s better not to use heavy commands (fill, search for all entities) like this: for “every second” a timer of 1 second is enough.
  • No slash and no plugin commands. In the "/" function file at the beginning of the line is an error, and the game will not download the entire function. Plaguin commands in the datapack function are not performed at all.
  • Folders - function and tags/function. From 1.21, the game reads only them, in the plural, silently; to 1.21, exactly the opposite. Therefore, the version is chosen: folders and a format declaration in the archive, under it.

Frequently asked questions

How can I make the command run every N seconds?

The function of the date pack, which at the end puts itself in line with the command scedele function...Ns, and first starts the tag load. Without plagins and command blocks, both on the server and in a single game.

How to execute a command when a player logs into Minecraft?

There's no vanilla entry event: in the teak, they look for players without a mark (first entrance) and with a growing number of leave_game (returned after exit), they call it a function and put a mark on them. The generator collects it himself.

Why doesn't the datapack function work?

Most often in the row is a cross line, the folder is called functions instead of function or as a plagin command. Check / datapack list and /function my_pack:load – the game will show error.