HungerTweaker 将 AppleCore API 暴露给 CraftTweaker 脚本,可用于修改多种与食物和饥饿相关的属性。
HungerTweaker 由两部分组成。首先,它包含一个对 AppleCore API 的简化封装。该封装可用于设置多种默认值,并修改食物物品的属性。其次,它提供了对 AppleCore 大部分事件的访问权限。这可用于动态修改并对玩家饥饿度、疲劳值、饥饿伤害和治疗能力的变化做出反应。
该简化封装旨在易于使用,主要由静态 ZenMethod 构成,例如 mods.hungertweaker.Hunger.setMaxHunger(20)。它仅能获取该属性的先前值作为上下文,此值可在表达式中使用,例如 mods.hungertweaker.Hunger.setMaxHunger("x/2")。
事件系统的功能在很大程度上类似于 CraftTweaker 自身的事件系统。脚本可以注册事件处理函数,当事件触发时这些函数会被调用,并且能够访问上下文信息(例如相关的 IPlayer)。因此,事件系统能够实现比简化封装更为复杂的效果。
HungerTweaker 会尝试在所有其他模组之后应用其更改。简化选项的处理发生在事件之前,且事件处理器可以覆盖由简化选项设置的默认值。
如需更全面的概览,请访问 HungerTweaker wiki。
HungerTweaker exposes the AppleCore API to CraftTweaker scripts, and can be used to modify a variety of food and hunger-related properties.
HungerTweaker consists of two parts. Firstly, it includes a simplified wrapper around the AppleCore API. This can be used to set a variety of default values, as well as modify the properties of food items. Secondly, it provides access to most of AppleCore's events. This can be used to dynamically modify and react to changes in a player's hunger, exhaustion, starvation, and regen.
The simplified wrapper is designed to be easy to use, and largely consists of static ZenMethods such as mods.hungertweaker.Hunger.setMaxHunger(20). It has access to no other context than the previous value of the property, which can be used in expressions, such as mods.hungertweaker.Hunger.setMaxHunger("x/2").
The event system functions largely like CraftTweaker's own event system. Scripts can register event handler functions, which are invoked whenever the event occurs and have access to context, such as the IPlayer in question. As such, the event system can be used to produce far more advanced results than the simplified wrapper.
HungerTweaker attempts to apply its changes after all other mods. The simplified options are handled before the events, and event handlers may override the default values set by the simplified options.
For a more complete overview, visit the HungerTweaker wiki.
评论 0
登录后参与评分
还没有评论,来抢沙发吧