No Starving
食物默认影响两个系统:生命值(通过营养值,即红心)和饱和度(鸡腿图标)。本模组完全移除了饱和度机制,使食物直接回复生命值。
为什么
我认为这种分裂式的回血机制很繁琐,并希望在我的服务器上移除它。我没有找到任何能简单高效地仅针对此机制进行修改的现有模组,因此我自行学习了如何实现这一功能,现在将其上传,以防万一有人有同样的需求。
如何运作
本模组使用 Fabric/SpongePowered Mixin API 直接向 FoodData、Hud 和 Player 类注入代码。
服务端
核心逻辑位于公共/服务端的重写部分。FoodData 被修改为:任何进食 API(注入覆盖内部的共享添加方法)都只会增加每刻跟踪的食物等级。然后,该刻的逻辑被重写,以重新设定最大饱和度(旨在尽可能与其他模组兼容)并移除疲惫值。随后,玩家在本刻内通过食用食物直接获得生命值回复。
客户端
客户端代码仅通过注入覆盖执行精灵绘制的私有方法来隐藏饱和度栏(鸡腿指示器)。跳过此步骤后,Boss 状态指示器等元素应得以保留。
No Starving
Food items by default effect two systems: Health (via nutrition, your hearts) and Saturation (your drumsticks). This removes the saturation feature entirely, making food heal hearts directly.
Why
I find the split healing system tedius and wanted to remove it from my server. I couldn't find any existing mods that simply and efficiently addressed this mechanic, and only this mechanic, so I learned how to do it myself and am now uploading it on the off-chance someone feels similarly.
How
This uses the fabric/spongepowered Mixin API to inject directly into the FoodData class, Hud class, and Player class.
Server side
The actual core logic lives in the common/server side overrides. FoodData is modified such that any eat API (injecting over the internal shared add method) results in just increasing the foodLevel tracked each tick. Then, the tick is overwriten such that it re-asserts maximum saturation (for hopefully yielding maximum compatibility with other mods) and removing exhaustion. The player is then healed directly by any food eaten this tick.
Client side
The client side code simply hides the saturation bar (drumstick indicator) by injecting over the private method that does the sprite blit. By skipping this step, boss indicators and the like should be preserved.
评论 0
登录后参与评分
还没有评论,来抢沙发吧