跳到正文

VerSion

作者:SubBurban

Technical API pack providing the currently running version and pack format.

收藏

截图

介绍

中文介绍正在准备中,下面暂时显示原文。

Showcase of VerSion printing the current Minecraft version 26.3-snap3 into the chat.

Please report any issues you have with wrong versions or any other unexpected behaviour on GitHub. Thank you!

VerSion

In Minecraft Vanilla, there is no simple command (or any source, that is) providing the currently running Minecraft Version or data pack format to datapacks.

VerSion addresses this issue and may be used as an API by other datapacks to get the current pack format. Using overlays, VerSion achieves this goal in an inexpensive, light-weight and future-proof manner.

In contrast to existing alternatives (like Version Detector, which at least supports earlier versions), VerSion covers way more formats, does not throw faulty errors (when in reality, everything’s working) or display excessive amounts of notices, and thus may be used elegantly and in any form of datapack project you plan to implement. Of course, it is free of charge and open-source forever.

How to use

Functions:

  • function ver:sion, returns current pack format as an int (available 23w44a and later)
  • function ver:load to reload version info (runs automatically on world startup and /reload)
  • function ver:print to print current version info to the executor

On every reload, VerSion stores the current pack format as an Integer and the name of the (last) Minecraft version using that format as a String inside a data storage. If lost, this information may always be refetched by running /function ver:load.

#get the pack format
data get storage ver:sion Format

#get the version
data get storage ver:sion Name

To make use of that information in your pack, use execute store ... run data get storage ver:sion Format or data modify ... from storage ver:sion (Format|Name).

For formats beginning with 23 (versions 23w44a and later), the most convenient way to get the pack format is function ver:sion which simply returns the current pack format.

Supported versions

If the datapack is marked as being for an older/newer version when investigated, that means no correct version info will be supplied. Due to the way VerSion works out the current pack format, only version 1.20.2 and later (specifically, beginning 23w31a) may be detected. For simplicity, only the major format number is taken into account.

Currently, all versions up to 26.3 – pack format 121 – are detected, however this will be quickly expanded when Minecraft updates progress further.

常见问题

VerSion 支持哪些 Minecraft 版本?

VerSion 支持 Minecraft Java 版 1.20–26.3,共 24 个版本,可用的加载器:Fabric / Forge / NeoForge / Quilt。下载时注意选择和你游戏版本一致的文件。

VerSion 怎么安装?

新建世界时在「数据包」里把下载的 .zip 拖进去;已有的存档,把文件放进存档目录下的 datapacks 文件夹,进游戏输入 /reload 即可生效。服务器同样放在世界目录的 datapacks 里。

评论

登录后评论和评分

SubBurban 的其他作品

查看全部 →