IAppleCoreMutator
基本信息
| 属性 | 值 |
|---|---|
| 类名 | squeek.applecore.api.IAppleCoreMutator |
| 类型 | interface,5 个方法 |
| 实现 | AppleCoreAccessorMutatorImpl(枚举单例,与 accessor 共用) |
| 启用版本 | Minecraft 1.7.10 |
功能
写入接口,直接改写玩家的饱食度、饱和度、消耗值以及两个内部计时器。 实现在 AppleCoreAccessorMutatorImpl。
| 方法 | 写入目标 |
|---|---|
setExhaustion(EntityPlayer, float) |
消耗值 foodExhaustionLevel |
setHunger(EntityPlayer, int) |
饱食度 foodLevel |
setSaturation(EntityPlayer, float) |
饱和度 foodSaturationLevel |
setHealthRegenTickCounter(EntityPlayer, int) |
回血计时器 |
setStarveDamageTickCounter(EntityPlayer, int) |
掉血计时器 |
实现要点
- 两个计时器 setter 是
FoodStats没有 setter 的私有字段, 靠 FoodStatsExt duck 接口 + Mixin 注入实现。 - 写入消耗值后客户端显示不会立即更新;服务端侧需依赖 SyncHandler 的阈值同步才会下发新值。
相关条目
- IAppleCoreAccessor - 同一枚举单例实现的只读侧
- AppleCoreAccessorMutatorImpl - 实际实现
- FoodStatsExt - 提供两个计时器 setter 的 duck 接口
- CommandHunger - 唯一内置调用方,通过
setHunger/setSaturation改数值 - SyncHandler - 改值后的同步机制