D Better Schedule 图标

D Better Schedule

作者:rebot | 分类:模组

价格:0 墨喵币 下载量:0 点赞:0 版本 1.3
本资源为搬运资源,原资源地址: https://modrinth.com/mod/d-better-schedule
资源信息

Minecraft 版本: 1.21 1.21.1 24w33a 24w34a 24w35a 24w36a 24w37a 24w38a 24w39a 24w40a 1.21.2-pre1 1.21.2-pre2 1.21.2 1.21.3 24w44a 24w45a 24w46a 1.21.4 1.21.5 1.21.6 1.21.7 1.21.8 1.21.9 1.21.10 1.21.11 26.1 26.1.1 26.1.2 26.2

平台: datapack

标签: library

资源介绍

中文

Introduction

D's Better Schedule is a library that provides a scheduler that keeps the context.
It will record the executor, location, rotation, and in some cases, dimension(see below) of the current context.
It also focuses on the behavior when the executor entity is offline, dead, or unloaded at the time of execution.

How to Use

To use the scheduler, first put the required data in storage dah.sch:new new. Fields:

run: #[command] string The command to run as a string. No slash. REQUIRED

time: int The number of ticks to wait before running the command. REQUIRED

offline: string
What to do if the target entity is not found at the time of execution (offline, dead, or unloaded). Defaults to discard:

  • discard: Do nothing and remove the task.
  • delay: PLAYER ONLY The timer ticks when the player is offline, but only executes until the player go back online
  • pause: PLAYER ONLY Timer freezes when the player is offline.
  • by_server: The command will be executed by the server instead.

max_retry: int If offline is set to discard or by_server, then if entity is not found at execution time, the task will be re-attempted on the next tick, up to max_retry number of times. If all retries failed then it proceeds to be discarded or executed by server accroding to offline. Defaults to 0.

flags: [string] Defines extra behaviors for the task. May includes:

  • no_executer: The executor will not be included in the context; the command will be run by server.
  • location_less: The Location and Rotation will not be included in the context; command will be run at world spawn
  • debug: Output debug information to chat.
  • try_dimension: It will try to find the current dimension. The library will read it from entity data if the executor is a player, or it trys if it is overworld, the_nether or the_end. Otherwise it assumes overworld. You may add other custom dimensions into the function tag #dah.sch:known_dimensions, running execute at @s if predicate {condition:"location_check",predicate:{dimension:"foo:bar"}} run data modify storage dah.sch:task this.in set value "foo:bar" to extend the trial and error list.

in: #[id="dimension"] string Specifies a dimension to run the command in. This will be overwritten by the try_dimension flag.

Then execute function dah.sch:new in the desired context to schdule the command.

Example:

# teleport the executor back to the current loction after 1s.
data modify storage dah.sch:new new set value {run:"tp ~ ~ ~",time:20}
function dah.sch:new

# setblock stone at current location after 1s, try to find the current dimension and spit out debug info.
data modify storage dah.sch:new new set value {run:"setblock ~ ~ ~ stone",time:20,flags:["debug","try_dimension"]}
function dah.sch:new

# Remove this player's attribute modifier after 10s. If the player goes offline in 10s then remove it after they log back in.
data modify storage dah.sch:new new set value {run:"attribute @s attack_damage modifier remove foo:bar",time:200,offline:"delay"}
function dah.sch:new

A simple macro version of the schduler is also provided as function dah.sch:set. It can only take in the time and run parameter:

function dah.sch:set {run:'say 1', time: 20}

Dependency File

A DBS-Dependency.zip is included in the release. Put this file anywhere on your computer, then by creating a spyglass.json file at the root of your workspace, the Spyglass extension will provides you the completion and error checking of all the functions, storages, and tags you need to write to use this library.

Example content of the spyglass.json file. See Spyglass Documentation for more.

{
    "env": {
        "dependencies": [
            "file:///C:/path/to/DBS-Dependency.zip",
            "@vanilla-mcdoc",
            "@vanilla-resourcepack",
            "@vanilla-mcdoc"
        ],
        "gameVersion": "1.21.5"
    }
}

Remeber to Reload Vscode. If something about this somehow goes wrong, make Vs Code run the Spyglass: Reset Project Cahce command.

Compatibility

This library, by itself, overrides no vanilla namespaces, does not modify/create/remove any world elements (blocks, entities, etc.), and all ids have the dah.sch prefix or namespace. Yes, this makes it follows the Smithed and essential MC Datapacks Discord Server Conventions. There should be zero worries about its compatibility.

Uninstall

Because of how this library is implemented, it is not possible to unload the datapack data while it is enabled.

Thus, first remove the datapack, reload, then you may execute the commands listed in the unload.mcfunction file provided in the root folder to delete the remaining data. Follow the instructions in that file.

Links

A gu library is included to convert UUIDs

Repository: https://github.com/Dahesor/D-Better-Schedule

Modrinth: https://modrinth.com/project/d-better-schedule

下载太慢?试试 墨喵加速站,支持 Modrinth 和外网直链高速下载! 用的人越多,下载的越快!
下载与版本
评论(0)
登录 后发表评论。

暂无评论,抢个沙发吧~

举报此资源

请登录后举报

🔥 相关推荐
More Enchantments

价格:0 墨喵币
下载量:0

查看详情
XpOrbs HUD

价格:0 墨喵币
下载量:0

查看详情
Kid Survival

价格:0 墨喵币
下载量:0

查看详情
creepebucketlib

价格:0 墨喵币
下载量:0

查看详情