在此阶段,该库需要额外的资源包。您可以使用 Weld 将资源包与自己的合并,或告知用户从此处或 GitHub 下载。
资源包 GitHub 链接:
此数据包库旨在建立一套标准化的法力/魔法系统,供多个数据包共同使用,而不会相互冲突或让用户感到困惑。
基本功能
法力是施放任何形式魔法的主要资源。
默认情况下,玩家最多可以持有 1000 点法力,达到上限后,法力将不再恢复。在没有其他修正的情况下,每秒恢复 5 点法力。
通过盔甲、药水或其他来源,不仅可以增加玩家每秒恢复的法力量,还可以解锁多达 1000 点的溢出法力。
每一点溢出法力允许玩家在通常的 1000 点最大值之上额外存储一点法力,从而允许最多存储 2000 点法力。
设置
请不要将此包与您自身的数据包合并。相反,请将玩家引导至 Modrinth 页面或本 GitHub 仓库,以便他们下载此包并与您的包一起使用。这样,您就无需在库更新时每次都更新您的包。如果您要将包上传到 Modrinth,最佳做法是将此包列为依赖项。不过,为了方便起见,您可以合并资源包,并根据喜好更改纹理。请注意,当玩家使用不同的资源包修改这些纹理时,列表中位置较高的资源包会覆盖位置较低的包。
对于未使用该库且未注明出处者,严禁使用资源包中提供的纹理。
确保玩家安装库
大量证据表明,有些玩家在下载新包之前根本不阅读包的说明。
为了通知那些需要安装库的玩家,请在您的 load 函数中包含以下内容:execute unless score %installed hexenkraft.util matches 777 run tellraw @a ["",{color:"yellow",text:"["},{color:"#CB81FF",text:"Hexenkraft Library"},{color:"yellow",text:"] "},{color:"red",text:"One of the datapacks you're using requires the "},{color:"#CB81FF",text:"Hexenkraft Mana Library "},{color:"red",text:"to function"},". ",{color:"gray",text:"["},{color:"#AFFFAC",text:"Download",click_event:{action:"open_url",url:"https://modrinth.com/datapack/hexenkraft"},hover_event:{action:"show_text",value:["",{text:"Click to download on Modrinth!"}]}},{color:"gray",text:"]"}]。您可以随意修改文本,但请确保在消息中包含直接下载链接。
与库交互
使用法力的能力/物品:
若要使用指定数量的法力,请运行:
function hexenkraft:_public/mana/use {amount:<AMOUNT>}(例如配合 execute store result 使用)
仅当玩家拥有足够的法力时才会消耗法力,此时函数将返回 1;如果玩家没有足够的法力,函数将返回 -1 并向玩家提供听觉反馈。此外,所需法力数量将在玩家的血条中以红色高亮显示。
提供额外法力恢复/溢出的物品
要使任何物品增加法力恢复或溢出,只需将以下内容添加到物品的 "minecraft:custom_data" 组件中:
{hexenkraft:{attributes:{<SLOT TYPE>:true,<MODIFIER TYPE>:true,<MODIFIER TYPE>_amount:<AMOUNT>}}}
<SLOT TYPE>:激活修正所需的物品槽位。可以是以下任意一个或多个:armor(盔甲)、offhand(副手)或 mainhand(主手)。
<MODIFIER TYPE>:修正的类型。可以是以下任意一个或多个:overflow(溢出)、regen(恢复)。
<AMOUNT>:每秒额外恢复的法力量或释放的溢出法力量。可以是任意整数,但溢出法力不能为负数。
在不使用物品的情况下提供额外法力恢复/溢出
要增加任何玩家的法力恢复/溢出属性,请以玩家身份运行 function hexenkraft:_public/attribute/add_modifier {type:<MODIFIER TYPE>,duration:<DURATION>,amount:<AMOUNT>,id:<ID>,persistent:<PERSITENCE>
<MODIFIER TYPE>:修正的类型。可以是 overflow(溢出)或 regen(恢复)。
<AMOUNT>:添加到玩家的恢复/溢出量。
<DURATION>:这些修正持续的时长(以刻为单位)。如果不想让它们消失,请设置为 -1。
<ID>:修正的唯一 ID。例如 namespace:mana_potion、namespace:bossfight_modifier 等。
<PERSISTENCE>:布尔值。True -> 玩家死亡时修正会自动移除。False -> 即使玩家死亡,修正仍会保留
您可以使用 function hexenkraft:_public/attribute/remove_modifier {id:<ID>} 在修正过期前移除现有修正。
尝试为玩家添加具有相同 ID 的多个修正是无效的,旧修正将被新修正覆盖。
读取法力值
所有法力值都存储在记分板中:
hexenkraft.mana.amount -> 当前存储的法力量
hexenkraft.mana.overflow -> 理论上可访问的溢出法力量
hexenkraft.mana.max -> 玩家的最大法力值,包括当前的溢出法力
hexenkraft.mana.regen -> 每秒恢复的法力量
hexenkraft.mana.amount_used -> 存储玩家最后使用/尝试使用的法力量。
请勿直接修改这些记分板,因为这样做可能会破坏库的核心功能或与其他包的兼容性。如果您觉得需要更改其中任何内容,且在库中找不到原生方法来实现,请通过 GitHub Issue 或在链接的 Discord 服务器中请求此类功能!
如果你出于某些原因想获取玩家当前的法力值百分比,只需运行:
function hexenkraft:_public/get/mana_percentage
然后从计分板 hexenkraft.mana.percentage 中读取数值。
“事件处理器” / 函数标签
如果你想让你的整合包响应特定事件,可以将函数添加到特定的标签中,当事件发生时这些函数就会被调用。所有这些函数都以玩家身份(as)在玩家位置(at)执行。
hexenkraft:call_on_mana_use_attempt -> 每当玩家尝试使用法力时调用,无论成功与否
hexenkraft:call_on_mana_use_fail -> 每当玩家尝试使用法力但失败时调用(例如因为法力不足)
hexenkraft:call_on_mana_use_success -> 每当玩家尝试使用法力并成功时调用
实用函数
其他用于与玩家法力值交互的函数。
/function hexenkraft:_public/mana/add {amount:<AMOUNT>} -> 增加玩家指定数量的法力值
/function hexenkraft:_public/mana/deplete -> 将玩家当前法力值设为 0
/function hexenkraft:_public/mana/fill -> 完全填满玩家的法力值,包括溢出部分
/function hexenkraft:_public/mana/no_overflow -> 完全填满玩家的法力值,不包括溢出部分
/function hexenkraft:_public/mana/set {amount:<AMOUNT>} -> 将玩家法力值设置为指定数量
/function hexenkraft:_public/mana/remove {amount:<AMOUNT>} -> 从玩家身上移除指定数量的法力值。请勿将此用于法术等仅在玩家拥有特定数量法力时才应生效的效果。有关此类情况,请参阅上方的 使用法力的能力/物品。
开发者设置
这些设置需要 OP 权限,可能有助于你在开发整合包时进行调试。
/function hexenkraft:_public/z_debug/toggle_debug_bar - 切换调试栏,这是一个替代的法力条,以数字形式显示当前法力、最大法力、溢出值及恢复速度。它在所有游戏模式中均会显示,并替换所有操作栏文本。
/function hexenkraft:_public/z_debug/toggle_debug_messages - 切换调试消息。带有额外信息的调试消息会在例如对玩家应用或移除属性修饰符时发送。未来可能会添加更多调试消息。
用户设置
- 任何玩家都可以通过以下命令禁用因法力不足而无法执行动作时播放的声音:
/trigger hexenkraft.settings.toggle_sounds
再次运行该命令可重新启用声音。
给开发者的建议
- 虽然内部机制允许存储高达 1000/2000 的法力值,但建议向玩家展示为 100/200。例如:5 点法力 -> 0.5 法力,500 -> 50 法力,以此类推。
- 不要运行
_public 文件夹以外的任何函数 :P
- 当添加法力恢复修饰符时,始终要考虑玩家需要多长时间才能恢复到最大值 2000 法力(这是单个法术的最高消耗)。此外,还要考虑到其他整合包可能会在你的基础上额外增加恢复速度的提升途径,这可能导致强度失衡。总体而言,尽量保持数值相对较低。通常,法力恢复速度为每秒 5 点,如果你仅仅再增加 5 点,就已经使恢复速度翻倍了。
- 更多建议即将补充™️
计划中的功能
AT THIS POINT IN TIME, THE LIBRARY REQUIRES AN ADDITIONAL RESOURCEPACK. FEEL FREE TO MERGE THE RP WITH YOUR OWN USING WELD, OR TELL USERS TO DOWNLOAD IT FROM HERE OR GITHUB
RP GITHUB LINK:
This datapack library aims to establish a standardised mana/magic system multiple packs can use without breaking each other or getting confusing for the user.
Basic functionality
Mana is the main resource used to cast any form of magic.
By default, a player can hold up to 1000 mana, once they reach that point, they simply stop regenerating. Without any modifiers, 5 mana points are regenerated per second.
Through armor pieces, potions or other sources it's possible to not only increase the amount of mana/second a player regenerates but also to unlock up to 1000 points of overflow mana.
Each point of overflow mana allows the player to store one mana above what would usually be the maximum of 1000, allowing for up to 2000 mana to be stored.
Setup
Please do not merge this pack with your own datapacks requiring the pack. Instead, link players to the Modrinth page/this GitHub repo where they can download this pack to use alongside yours. This way, you won't need to update your pack everytime the library gets updated. If you're uploading your pack to Modrinth, best practice is to list this pack as a dependency. You are, however, allowed to merge the resource pack for ease of use, as well as change textures to your liking. Note that when the player uses different resourcepacks modifying these textures, the resource pack highest in the list will override the lower ones.
DO NOT use the textures provided by the resource pack for packs not also using the library and without giving credit.
Making sure the player installs the library
As proven by plenty of evidence, some players simply don't read the pack descriptions before downloading a new pack.
To inform those that they need to install the library, please include execute unless score %installed hexenkraft.util matches 777 run tellraw @a ["",{color:"yellow",text:"["},{color:"#CB81FF",text:"Hexenkraft Library"},{color:"yellow",text:"] "},{color:"red",text:"One of the datapacks you're using requires the "},{color:"#CB81FF",text:"Hexenkraft Mana Library "},{color:"red",text:"to function"},". ",{color:"gray",text:"["},{color:"#AFFFAC",text:"Download",click_event:{action:"open_url",url:"https://modrinth.com/datapack/hexenkraft"},hover_event:{action:"show_text",value:["",{text:"Click to download on Modrinth!"}]}},{color:"gray",text:"]"}] in your load function. Feel free to modify the text to your liking but make sure to include a direct download link in the message.
Interacting with the library
Abilities/Items that use mana:
To use a set amount of mana run:
function hexenkraft:_public/mana/use {amount:<AMOUNT>} (e.g. with execute store result)
This will only use mana if the player has enough, in which case the function will return 1, if the player does not have enough mana, the function will return -1 and give audible feedback to the player. Additionally, the amount of mana needed, will be highlighted in red on the players mana bar.
Items that grant additional mana regen / overflow
To allow for any item to increase mana regen or overflow, simply add the following to the item's "minecraft:custom_data" component:
{hexenkraft:{attributes:{<SLOT TYPE>:true,<MODIFIER TYPE>:true,<MODIFIER TYPE>_amount:<AMOUNT>}}}
<SLOT TYPE>: The slots the item needs to be in for the modifier to activate. Can be any or all of: armor, offhand or mainhand
<MODIFIER TYPE>: The type of the modifier. Can be any or all of: overflow, regen
<AMOUNT>: The amount of additional mana to regenerate per second/of overflow mana to be freed. Can be any integer, though overflow mana can not be negative.
Grating additional mana regen / overflow without items
To increase any players mana regen / overflow stats, run function hexenkraft:_public/attribute/add_modifier {type:<MODIFIER TYPE>,duration:<DURATION>,amount:<AMOUNT>,id:<ID>,persistent:<PERSITENCE> as the player
<MODIFIER TYPE>: The type of the modifier. Can be either overflow, regen
<AMOUNT>: The amount of regen/overflow added to the player
<DURATION>: The duration of how long these modifiers last in ticks. Set to -1 if you don't want them to run out.
<ID>: Unique ID for the modifier. E.g. namespace:mana_potion, namespace:bossfight_modifier, etc.
<PERSISTENCE>: Boolean. True -> modifier automatically gets removed when the player dies. False -> Modifier stays even after a player dies
You can remove existing modifiers before they run out using function hexenkraft:_public/attribute/remove_modifier {id:<ID>}
Trying to add multiple modifiers with the same ID to a player will cause the old modifier to be overwritten by the new one
Reading mana values
All mana values are stored in scoreboards:
hexenkraft.mana.amount -> Current amount of stored mana
hexenkraft.mana.overflow -> Amount of theoretically acessible overflow mana
hexenkraft.mana.max -> Maximum mana of a player, including their current overflow mana
hexenkraft.mana.regen -> Amount of mana to be regenerated / second
hexenkraft.mana.amount_used -> Stores the last amount of mana the player used/tried to use.
PLEASE do NOT ever directly modify these scoreboards, as doing so can break core functions of the library or compatibility with other packs. If you feel the need to change any of these and find no native way to do so using the library, please request for such function either via github issues or in the linked discord server!
If you for some reason want to get the current mana percentage of a player simply run:
function hexenkraft:_public/get/mana_percentage
And then read from scoreboard hexenkraft.mana.percentage
"Event handlers" / Function tags
If you want your pack to respond to certain events, you can add functions to certain tags and they will be called when the event happens. All of these are run as the player, at the player.
hexenkraft:call_on_mana_use_attempt -> called whenever a player attempts to use mana, no matter the success
hexenkraft:call_on_mana_use_fail -> called whenever a player attempts to use mana and fails (e.g. because they do not have enough)
hexenkraft:call_on_mana_use_success -> called whenever a player attempts to use mana and succeeds
Utility functions
Other functions to interact with a player's mana.
/function hexenkraft:_public/mana/add {amount:<AMOUNT>} -> increases the players mana by a set amount
/function hexenkraft:_public/mana/deplete -> sets the players current mana to 0
/function hexenkraft:_public/mana/fill -> completely fills up the players mana, including overflow
/function hexenkraft:_public/mana/no_overflow -> completely fills up the players mana, excluding overflow
/function hexenkraft:_public/mana/set {amount:<AMOUNT>} -> sets the players mana to a specific amount
/function hexenkraft:_public/mana/remove {amount:<AMOUNT>} -> removes a specific amount of mana from the player. DO NOT use this for spells and things of the like which are only supposed to work if the player has a specific amount of mana. For that see Abilities/Items that use mana above.
Developer settings
These settings require op permissions and might help out when developing your pack.
/function hexenkraft:_public/z_debug/toggle_debug_bar - Toggles the debug bar, an alternate mana bar numerically displaying current mana, max mana, overflow & regeneration. Shows up in all gamemodes and replaces all actionbar text.
/function hexenkraft:_public/z_debug/toggle_debug_messages - Toggles debug messages. Debug messages with extra information are for example sent whenever attribute modifiers are applied to/removed from a player. More debug messages might be added in the future.
Settings for users
- Any player can disable the sound that is played when they don't have enough mana to perform an action using:
/trigger hexenkraft.settings.toggle_sounds
Running the command again will re-enable sounds.
Recommendations for developers
- Though internally, the can hold up to 1000/2000 mana, it is recommended to communicate it as 100/200 to the player. E.g. 5 mana points -> 0.5 mana, 500 -> 50 mana, etc.
- Don't run any functions not in the
_public folder :P
- When adding mana regeneration modifiers, always think about how fast it would take the player to reach the maximum of 2000 mana, which is the most a spell can cost. Also, consider that other packs might add additional ways to increase regeneration on top of yours, which can quickly become overpowered. In general, try to keep values relatively low. Normally, mana regenerates at 5/s, if you even just add another 5 to that, you have already doubled the speed.
- More recommendations to be added soon™️
Planned features
- Further optimisation of the pack
- Whatever the people long for :)
评论 0
登录后参与评分
还没有评论,来抢沙发吧