← Назад к ресурсам

datapack function library

This data pack provides developers with some useful functions and is compatible with all versions of Minecraft (except for those versions where data packs cannot be installed).

Modrinth adventure game-mechanics management

Описание

中文介绍:[GitHub](https://github.com/TouchController/E1epack/blob/main/subprojects/datapack-function-library/README.md#%E5%89%8D%E8%A8%80) | [MC 百科](https://www.mcmod.cn/class/17244.html) # Preface *This datapack is licensed under the [GNU LESSER GENERAL PUBLIC LICENSE](https://www.gnu.org/licenses/lgpl-3.0.txt "Go to this open source license page").* **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:** ```mcfunction #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](https://zh.minecraft.wiki/w/Java%E7%89%88%E5%87%BD%E6%95%B0#%E5%AE%8F). When using them, you need to pass parameters through `{:""}` (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](https://github.com/TouchController/E1epack/issues/new/choose) 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` - Fall damage; - Fire damage; - Freeze damage; - Drowning damage. ### Fix the respawn point to 0 0 Function usage: `/function dfl:start/set_world_spawn` - Set the world respawn point to 0 0 0; - Set the respawn point radius to 0; - At this time, the player will be fixed to respawn on the highest block at coordinate 0 0. ### Enable death leaderboard Function usage: `/function dfl:start/show/enable_death_scoreboard` - Create a scoreboard item named death; - The number of deaths will be displayed on the right side of the screen; - The number of player deaths is sorted from high to low; - Note: The death leaderboard will not be displayed when it is first enabled, and it will be displayed only after any player dies. ### Display player health Function usage: `/function dfl:start/show/display_health_below_name` - Create a scoreboard item named health; - The player's health will be displayed below the player's ID; - It will not be displayed if the distance is slightly far (only the player's ID is displayed); - Note: When it is first enabled, the health will be displayed as 0, and it will be displayed only after the value is updated (such as being injured). ### Display player experience level Function usage: `/function dfl:start/show/display_level_in_tab` - Create a scoreboard item named level; - The experience level of each player will be displayed in the Tab bar (player list bar); - Note: When it is first enabled, the experience level will be displayed as 0, and it will be displayed only after the value is updated (such as leveling up). ### Display player health bar Function usage: `/function dfl:start/show/display_health_in_tab` - Create a scoreboard item named health; - The health bar of each player will be displayed in the Tab bar (player list bar). - The effect is as follows: ![[DFL] Datapack Function Support Library (datapack function library)-Image 1](https://raw.githubusercontent.com/TouchController/E1epack/main/subprojects/datapack-function-library/README/Scoreboard_Display_List_Hearts.gif) ### Quickly create a new team Function usage: `/function dfl:start/create_teams {team_blue:"blue",team_red:"red",prefix_blue:"blue",prefix_red:"red"}` - Create two teams named {team_blue} and {team_red}; - The colors are blue and red respectively; - Disable friendly fire for players in the same team; - Players can only collide with entities not on the same team; - The player name prefixes are {prefix_blue}_ and {prefix_red}_ respectively. ## 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"}` - Note: The executor of this function must be the player to be **banned**, you can use the `/execute` command; - Realize a soft ban by continuously tp the player to 0 0 0, setting the mode to adventure, and continuously giving the player negative buffs; - Must be executed every Tick; - Title is {title}, subtitle is {subtitle}; - Example: `/execute as @a[tag=ban] run 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](https://raw.githubusercontent.com/TouchController/E1epack/main/subprojects/datapack-function-library/README/tick.ban.png) ### Beacon elytra take-off Function usage: `/function dfl:tick/beacon_fly` - When there are iron blocks, gold blocks, emerald blocks, diamond blocks or netherite blocks under the beacon, the player will be teleported upwards (spectators will not be teleported); - The heights are 20, 40, 60, 80, and 100 blocks in order; - The same blocks can be stacked to increase the height (the highest is 400 blocks, using four netherite blocks). If the blocks are different, the block closest to the beacon will be used. ### 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` - Teleport the player upwards when standing between two iron blocks, one above the other; - The maximum teleportation distance is 6 blocks, that is, the maximum distance between two iron blocks is 5 blocks; - Will not teleport spectators; - Will teleport creatures and non-creature entities. ### Clear entities if there are too many Function usage: `/function dfl:tick/kill_excess_entities {num:"1000"}` - Clear all non-player entities when the number of non-player entities is greater than {num}; - Will not clear entities with the need tag; - Entities with the need tag will not be counted in the number of entities here; - Create a scoreboard item named dfl_scoreboard. - After execution, a prompt will be displayed in the chat bar, the effect is as follows: ![[DFL] Datapack Function Support Library (datapack function library)-Image 3](https://raw.githubusercontent.com/TouchController/E1epack/main/subprojects/datapack-function-library/README/tick.kill.png) ### 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` - Make all entities clear these entities when the number of entities within 10 blocks is greater than {num}; - Will not kill players; - Will not kill villagers; - Will not kill entities with the need tag; - Will not leave traces in the chat bar. ### Minecraft is too hard Function usage: `/function dfl:tick/mith` - Enable keep inventory on death; - Give the executor night vision; - Give the executor glowing; - Remove the executor's darkness effect. ### Display the number of entities Function usage: `/function dfl:tick/display_entity_count` Prerequisite function: `/function dfl:lib/get_entity_count` - Display the real-time number of entities in the player's action bar (above the shortcut bar). - The effect is as follows: ![[DFL] Datapack Function Support Library (datapack function library)-Image 4](https://raw.githubusercontent.com/TouchController/E1epack/main/subprojects/datapack-function-library/README/tick.show_entity.png) ### Disable player friendly fire and collision Function usage: `/function dfl:tick/disable_friendly_fire` - Add a team named dfl and add all players to this team; - Note: Since the same entity cannot join multiple teams, please do not enable this function if you want to use the player team function; - Disable team friendly fire; - Disable collision within the team; - If this function is not run every Tick, please make sure to run this function once after each new player joins. ### Clear TNT if the TNT entity density is too high Function usage: `/function dfl:tick/kill_tnt_by_density {num:"200"}` - Clear these TNT entities when the number of TNT entities within five blocks of the TNT is greater than {num}; - Create a scoreboard item named dfl_tntdensity. ### Suicide for players without permission Function usage: `/function dfl:tick/trigger_suicide` - Create a scoreboard item named kill; - Enter `/trigger kill` to commit suicide (this command does not require any permission). ### Replace blocks in a large area Function usage: `/function dfl:tick/change_block {new:"glass",old:"stone",num:"30"}` - Replace {old} with {new} in a {num}3 *8 range around the player; - Change the game rule commandModificationBlockLimit to 2147483647. ### Always day + always sunny Function usage: `/function dfl:tick/always_sunny` - Turn off the day-night cycle; - Turn off weather changes; - Set the time to day; - Set the weather to clear. ### Clear a single item and execute a command Function usage: `/function dfl:tick/clear_and_execute_single {name:"stone",run:"tp ~ 100 ~"}` - Clear one {name} from all players and execute {run}; - Note: There should be no extra spaces at the beginning and end of the command in the run parameter, and there should be no slash before the command. ### Clear specified items and execute commands multiple times Function usage: `/function dfl:tick/clear_and_execute_multiple {name:"sand",run:"give @s anvil"}` - Clear all {name} of the function executor and execute the corresponding number of {run} **(within the same tick)**; - Note: There should be no extra spaces at the beginning and end of the command in the run parameter, and there should be no slash before the command. ### Keep having an item Function usage: `/function dfl:tick/maintain_item_count {name:"slime_block",num:"64"}` - Let the command executor have exactly the specified number of items. ### Self-rescue platform Function usage: `/function dfl:tick/create_rescue_platform` Prerequisite function: `/function dfl:lib/get_game_time` - Create a scoreboard item named dfl_slime_marker_temp to store the time when the slime platform is generated; - Generate a 3*3 slime platform under the player with the dfl_slime tag and remove the tag. The slime platform can only cover air blocks; - The slime blocks at the slime platform position will be cleared after `