HomeJavaDatapacksdatapack function library
datapack function library
DatapacksJava

datapack function library

by white_elephant · on Modrinth

This data pack provides developers with some useful functions and is compatible with all versions of Minecraft (except for those versions where data packs…

Which build do you need?

This mod ships a separate file for every mod loader and every version of the game. Pick both, then download — the wrong build installs fine and then does nothing in the game.

Mod loader

Minecraft version

⬇ Download for 1.21.3–1.21.10 · Data pack⬇ Download for 1.21.3–1.21.10 · Fabric⬇ Download for 1.21.3–1.21.10 · Forge⬇ Download for 1.21.3–1.21.10 · NeoForge⬇ Download for 1.21.3–1.21.10 · Quilt
I don't know my version or loader
Open the Minecraft launcher and look at the profile you play on — it names both, like fabric-loader-1.21.4. The version also shows in the bottom-right corner of the game's main menu.
No loader in the profile name? Then it's plain Minecraft, and these mods won't run — you need Fabric or NeoForge installed first.
datapack function library — screenshot 1

中文介绍:GitHub | MC 百科

Preface

This datapack is licensed under the GNU LESSER GENERAL PUBLIC LICENSE.

This datapack provides developers with some practical functions (and some dialogs), compatible with all versions of Minecraft (except for versions that cannot install datapacks).

However, due to the large number of commands involved in the datapack, lower versions may not be able to use all functions. The applicable versions of all functions will not be specified below.

Please install the resource pack at the same time to use localized content (v3.2+). Otherwise, the datapack language will default to zh_cn.

The mod version of this datapack is packaged through Modrinth, and the content is exactly the same as the datapack version, but it is not necessarily the latest version. Please try to use the datapack version.

This datapack provides a dfl:dfl_enable function, which can set the score of all entities in this scoreboard to 1, which is convenient for datapacks or mods that depend on this datapack to detect whether this datapack is loaded.

Example:

#Execute when the datapack is loaded:
scoreboard objectives add dfl_scoreboard dummy
scoreboard players set dfl_enable dfl_scoreboard 0
#If not loaded:
function dfl:dfl_enable
execute unless score dfl_enable dfl_scoreboard matches 1
#If loaded:
function dfl:dfl_enable
execute if score dfl_enable dfl_scoreboard matches 1

Note: Some functions have "prerequisite functions" attached to their usage. These functions must be executed once before executing them.

Some function usages are followed by {xx:"xx"}. These functions are macro functions. When using them, you need to pass parameters through {<parameter name>:"<content>"} (the parameters in the usage are the recommended parameters tested by the author during development, or the parameters used by the author for testing). The parameter name (such as num) is expressed as: {num} in the text. The parameter format can refer to the function usage, and special formats will be explained.

If you encounter any problems, please click here to give feedback.


Function Description

Start

Functions in this category are recommended to be executed when the datapack is loaded (reloaded).

Disable Special Damage

Function usage: /function dfl:start/disable_special_damage

Fix the respawn point to 0 0

Function usage: /function dfl:start/set_world_spawn

Enable death leaderboard

Function usage: /function dfl:start/show/enable_death_scoreboard

Display player health

Function usage: /function dfl:start/show/display_health_below_name

Display player experience level

Function usage: /function dfl:start/show/display_level_in_tab

Display player health bar

Function usage: /function dfl:start/show/display_health_in_tab

[DFL] Datapack Function Support Library (datapack function library)-Image 1

Quickly create a new team

Function usage: /function dfl:start/create_teams {team_blue:"blue",team_red:"red",prefix_blue:"blue",prefix_red:"red"}

Tick

Functions in this category are recommended to be executed every Tick.

Soft ban player

Function usage: /function dfl:tick/soft_ban_player {title:"Ban Reason",subtitle:"Note"}

The effect is as follows:

[DFL] Datapack Function Support Library (datapack function library)-Image 2

Beacon elytra take-off

Function usage: /function dfl:tick/beacon_fly

One-click negative Buff

Function usage: /function dfl:tick/apply_debuffs

Give the function executor the following Debuffs:

  1. slowness
  2. mining_fatigue
  3. nausea
  4. darkness
  5. hunger
  6. weakness
  7. poison
  8. unluck
  9. trial_omen

Iron block elevator

Function usage: /function dfl:tick/iron_block_elevator

Clear entities if there are too many

Function usage: /function dfl:tick/kill_excess_entities {num:"1000"}

[DFL] Datapack Function Support Library (datapack function library)-Image 3

Clear entities if the entity density is too high

Function usage: /function dfl:tick/kill_by_density {num:"50"}

Prerequisite function: /function dfl:lib/get_entity_density

Minecraft is too hard

Function usage: /function dfl:tick/mith

Display the number of entities

Function usage: /function dfl:tick/display_entity_count

Prerequisite function: /function dfl:lib/get_entity_count

[DFL] Datapack Function Support Library (datapack function library)-Image 4

Disable player friendly fire and collision

Function usage: /function dfl:tick/disable_friendly_fire

Clear TNT if the TNT entity density is too high

Function usage: /function dfl:tick/kill_tnt_by_density {num:"200"}

Suicide for players without permission

Function usage: /function dfl:tick/trigger_suicide

Replace blocks in a large area

Function usage: /function dfl:tick/change_block {new:"glass",old:"stone",num:"30"}

Always day + always sunny

Function usage: /function dfl:tick/always_sunny

Clear a single item and execute a command

Function usage: /function dfl:tick/clear_and_execute_single {name:"stone",run:"tp ~ 100 ~"}

Clear specified items and execute commands multiple times

Function usage: /function dfl:tick/clear_and_execute_multiple {name:"sand",run:"give @s anvil"}

Keep having an item

Function usage: /function dfl:tick/maintain_item_count {name:"slime_block",num:"64"}

Self-rescue platform

Function usage: /function dfl:tick/create_rescue_platform

Prerequisite function: /function dfl:lib/get_game_time

Convert items to experience

Function usage: /function dfl:tick/things_to_xp {name:"tnt",xp:"1"}

tpa

Function usage: /function dfl:tick/tpa

Prerequisite function: /function dfl:lib/generate_player_id

Auto-smelting

Function usage: /function auto_smelt:smelt {input:"raw_iron",output:"iron_ingot"}

Timer

Functions in this category are recommended to be executed after a period of time. (You can use the /schedule command)

Clean up dropped items

Function usage: /function dfl:timer/clear_items

[DFL] Datapack Function Support Library (datapack function library)-Image 5

Display entity quantity information

Function usage: /function dfl:timer/display_entity_info

Prerequisite functions:

/function dfl:lib/get_entity_count

/function dfl:lib/get_item_count

/function dfl:lib/non_player_entities

The effect of this function is as follows:

[DFL] Datapack Function Support Library (datapack function library)-Image 6

Lib

Functions in this category have no effect when executed alone or do not fit into the above categories.

Force death drop

Function usage: /function dfl:lib/force_death_drops

  1. Turn off keep inventory on death.
  2. Kill the function executor.
  3. Turn on keep inventory on death.

Get the number of entities

Function usage: /function dfl:lib/get_entity_count

Get entity density

Function usage: /function dfl:lib/get_entity_density

Get the number of dropped items

Function usage: /function dfl:lib/get_item_count

Get the number of non-player entities

Function usage: /function dfl:lib/non_player_entities

Get the number of game days

Function usage: /function dfl:lib/get_game_day

Get the time of day

Function usage: /function dfl:lib/get_day_time

Surround the player with glass

Function usage: /function dfl:lib/create_glass_box

Get game time

Function usage: /function dfl:lib/get_game_time

Get the number of players

Function usage: /function dfl:lib/get_player_count

Modify maximum health

Function usage: /function dfl:lib/change_max_health {num:"100"}

Generate UID

Function usage: /function dfl:lib/generate_player_id

Detect the number of items

Function usage: /function dfl:lib/count_items {name:"stone"}

Batch generate dummies

Function usage: /function dfl:lib/spawn_dummies

Dialog Description

GNU GPL License Text

Dialog usage: /dialog show dfl:gpl

GNU LGPL License Text

Dialog usage: /dialog show dfl:lgpl

Verified by MCModsHub

These come from our own check of the pack file, not from the source page.

Explore more