Better Enchanted
Fabric Mod | Minecraft 1.20.4 | Java 17
将附魔效果应用于食物和药水——让它们也拥有附魔能力。
简介
Better Enchanted 是一款 Minecraft Fabric 模组,其核心玩法围绕创造性地将原版剑、弓、弩和三叉戟的附魔效果应用于食物和投掷型药水。食物附魔在被食用时触发,而药水附魔则在命中目标时触发。为了保持平衡性和一致性,所有伤害公式尽可能贴近 MC 1.20.4 的原版附魔机制。
0. 附魔获取机制
默认情况下,原版附魔台和铁砧会拒绝为食物和药水进行附魔。本模组通过 Mixins 接入整个附魔管线,使食物/药水能够像武器一样被附魔:
- 附魔台:
FoodPotionEnchantableMixin 使 Item.isEnchantable() 对食物/药水返回 true,并提供合理的附魔能力值(普通食物 10,药水 15,超级/终极金苹果 22)。
EnchantingTableMixin 注入 EnchantmentHelper.getPossibleEntries(),以返回模组为食物/药水提供的自定义可用附魔列表。
- 铁砧(附魔书):
EnchantmentAcceptItemMixin 注入 Enchantment.isAcceptableItem(),使得匹配的附魔书可以应用于食物/药水。
- 可附魔范围:
- 食物:锋利、击退、火焰附加、效率、冰霜行者、耐久
- 药水:锋利、力量、冲击、火矢、无限、耐久、多重射击、快速装填、穿透、引雷、忠诚、迅捷投掷
- 超级/终极附魔金苹果:支持全套食物 + 药水附魔
I. 食物附魔
食物附魔适用于所有可食用物品,同时也兼容蛋糕方块(蛋糕使用专用的方块附魔存储系统)。
1.1 锋利
- 效果:食用时对食用者造成伤害
- 公式:
damage = 0.5 × level + 0.5
- 锋利 I = 1.0 伤害,II = 1.5,III = 2.0,IV = 2.5,V = 3.0
- 自定义伤害来源:具有独特的死亡讯息(“XXX 被锋利的食物割断了喉咙”)
- 蛋糕支持:从蛋糕位置读取
CakeEnchantmentStorage 中的锋利等级
1.2 击退
- 效果:食用时对食用者施加击退效果
- 方向:随机方向(360° 随机角度),模拟被食物“弹飞”
- 强度公式:
- 水平方向:
strength = 0.5 × level
- 垂直方向:若在地面上,给予小幅向上提升(最高 0.4)
- 参考:改编自 MC 1.20.4
PlayerEntity.attack() 中的击退逻辑
1.3 火焰附加
- 效果:食用时点燃食用者
- 持续时间:
level × 4 秒
- 参考:与 MC 1.20.4 原版火焰附加逻辑相同(
target.setOnFireFor(level * 4))
1.4 效率
- 效果:加快进食速度
- 公式:每级减少 10% 的进食时间
- 效率 I = 快 10%,效率 V = 快 50%
- 实现方式:Mixin 到
Item.getMaxUseTime() 以减少进食 tick 数
1.5 冰霜行者
- 效果:食用后获得冰霜行者效果
- 持续时间:基础 20 秒 + 每级增加 10 秒
- 冰霜行者 I = 30秒,II = 40秒,III = 50秒
- 结冰机制:在效果持续期间,玩家下方的水会冻结成霜冰
- 持续伤害:每 4 秒受到 1 点冰霜伤害,间隔随等级每级减少 0.5 秒
- 冰霜行者 I = 每 3.5秒,II = 每 3秒
- 视觉效果:血条显示为蓝色冰冻风格
- 可配置:可通过调试菜单切换冰霜行者的日志记录
1.6 耐久
- 效果:食用后有几率不消耗食物
- 概率公式:参考 MC 1.20.4 原版耐久公式
- 消耗概率 =
1 / (level + 1)
- 不消耗概率 =
level / (level + 1)
- 耐久 I = 50% 不消耗,II = 66.7%,III = 75%
- 蛋糕特殊处理:触发时恢复一块蛋糕(BITES - 1);若蛋糕刚被完全吃完,则将其恢复到最后一口的状态
II. 药水附魔 — 武器/弓类
药水附魔在投掷型药水(喷溅型/滞留型)被投出并击中物体时触发。所有伤害/效果对直接命中的实体全额生效,并对溅射范围内(4格内)的实体按距离衰减生效。
2.1 锋利 [药水]
- 效果:投掷的药水对命中的实体造成伤害
- 公式:
damage = 0.5 × level + 0.5(与食物锋利相同)
- 溅射:4格范围内的伤害衰减(
damage × (1 - distance/4))
- 叠加:与力量附魔的伤害相加
- 自定义伤害来源:独特的死亡讯息(“XXX 被锋利的药水震碎”)
2.2 力量 [药水]
- 效果:投掷的药水对命中的实体造成伤害
- 公式:参考 MC 1.20.4 弓的力量附魔
damage = level + 1(模拟箭矢基础=2 的力量加成)
- 力量 I = 2.0,II = 3.0,III = 4.0,IV = 5.0,V = 6.0
- 叠加:直接加到锋利伤害上
- 伤害来源:当力量伤害 ≥ 锋利伤害时,使用力量专属的死亡讯息(“XXX 被强大的药水彻底摧毁”)
2.3 冲击 [药水]
-
效果:投掷的药水对命中的实体施加击退效果
-
公式:参考 MC 1.20.4 弓的冲击附魔(AbstractArrowEntity.onHit)
knockbackStrength = punchLevel × 0.6
-
方向:
- 直接命中:沿药水飞行方向(归一化的水平分量)
- 溅射范围:从撞击点指向实体,强度随距离衰减
-
效果:投掷药水命中时点燃目标
-
直接命中:5 秒火焰伤害(100 tick),与 MC 1.20.4 弓箭火焰附魔规则一致
-
溅射范围:火焰持续时间随距离衰减(ceil(5 × (1 - distance/4)) 秒)
-
等级:仅 I 级(与原版一致)
2.5 引雷 [Potion]
- 效果:将 MC 1.20.4 三叉戟引雷规则适配为 AOE 版本
- 条件:
- 必须处于雷雨天气(
world.isThundering())
- 目标实体位置必须可见天空(
isSkyVisible)
- 范围:药水撞击点周围 4 格内的所有活体实体
- 结果:每个符合条件的实体将在其位置召唤一道闪电
- 闪电归属:闪电施法者设置为投掷者(影响掉落物和经验值)
- 等级:仅 I 级(与原版一致)
III. 药水附魔 — 弩类别
3.1 多重射击 [Potion]
- 效果:单次投掷产生多个呈锥形扩散的药水
- 数量公式:总投射物数 =
2 + level
- 多重射击 I = 3,II = 4,III = 5
- 分布规则:
- 第一瓶药水(主弹)沿瞄准方向直线飞行(锥形中心)
- 前 8 个额外投射物均匀分布在 10° 的锥形圆周上
- 超过 8 个额外投射物:在锥形内随机分布(0°–10°,使用 sqrt 实现面积均匀分布)
- 消耗:仅消耗 1 瓶药水
- 兼容性:完全兼容所有 Swift Throw 模式(物理/射线检测)
3.2 快速装填 [Potion]
- 效果:减少无限附魔的冷却时间
- 公式:每级减少 20% 冷却时间(基础 30 秒)
- Lv I = 24s,Lv II = 18s,Lv III = 12s,Lv IV = 6s,Lv V = 0s(无冷却)
- 前置条件:必须与无限附魔一起使用;单独存在时无效
3.3 穿透 [Potion]
- 效果:参考 MC 1.20.4 弩穿透规则
- 机制:
- 药水可穿透
level 个实体(总共击中 level + 1 个)
- 对每个被穿透的实体应用附魔效果(锋利/力量/击退/火焰)
- 已被穿透的实体不会再次被击中
- 击中方块或达到穿透上限时正常销毁并触发溅射效果
IV. 药水附魔 — 三叉戟类别
4.1 忠诚 [Potion]
- 效果:改编自 MC 1.20.4 三叉戟忠诚规则
- 机制:
- 药水投出后 2 秒自动返回投掷者
- 返回速度 =
0.5 × level 格/tick
- Lv I = 10 格/s,Lv II = 20 格/s,Lv III = 30 格/s
- 如果在飞行或返回途中击中实体或方块,则正常消耗(不会返回)
- 成功返回后将药水物品归还给玩家
- 消耗逻辑:药水在投出时立即消耗(实体本身携带返回逻辑)
V. 通用药水附魔
5.1 无限 [Potion]
- 效果:投掷药水不消耗它
- 冷却系统:
- 基于 NBT 标签(
InfinityMarked)的自定义冷却系统
- 仅影响带有无限附魔的物品,不影响其他相同物品
- 基础冷却时间:30 秒(可被快速装填减少)
- 与耐久度的交互:
- 拥有耐久度:执行耐久检查 — 通过 → 无冷却,失败 → 进入冷却
- 无耐久度:始终进入冷却
- 客户端显示:灰色半透明冷却叠加层,通过网络同步
- 冷却阻断:冷却期间无法再次使用该物品
5.2 耐久 [Potion]
- 效果:投掷后不消耗药水的几率
- 公式:同食物耐久规则(消耗概率 =
1/(level+1))
- 与无限的交互:检查结果决定是否触发冷却(见上文)
VI. 自定义附魔
6.1 迅捷投掷
- 效果:增加药水投掷速度和轨迹平坦度
- 附魔台最高等级:10(仅限书籍;不能直接应用于药水/物品)
- 铁砧最高合法等级:19(无法达到 >20 的射线检测模式,保留超级金苹果迅捷投掷 25 的稀有性)
- 速度公式:
实际速度 = 基础速度 (0.5) × (1 + 0.5 × level)
- 角度公式:向上偏移角度
y = 80 / (4 + level) 度
- 等级越高 = 轨迹越平
- 当偏移角度 < 1° 时,设为 0(完美平抛)
- 两种模式:
- Level 1–20(物理模式):正常的物理投掷,速度和方向由公式计算,受重力影响
- Level >20(射线检测模式):通过逐 tick 射线检测传送实现即时命中;药水实体不可见且无重力;沿发射方向每 0.5 格生成暴击粒子(最多 64 格)
- 兼容性:完全兼容多重射击 — 额外投射物也使用相同的迅捷投掷模式
VII. 超级附魔金苹果
7.1 物品概览
| 属性 |
描述 |
| 物品 ID |
hello-mod:super_enchanted_golden_apple |
| 文本颜色 |
淡紫色 (LIGHT_PURPLE) |
| 内置附魔 |
迅捷投掷 25 |
| 获取方式 |
3×3 工作台合成(金块 ×4 + 喷溅药水 ×2 + 滞留药水 ×2 + 金苹果 ×1) |
7.2 模式切换
- 手持左键点击可在食用/投掷模式间切换,5 游戏刻冷却
- 动态名称:食用模式下为“超级附魔金苹果”,投掷模式下为“可投掷超级附魔金苹果”
7.3 食用模式
- 食用时间 32 tick(1.6s),效率附魔加速
- 食用效果 = 基础效果 + 喷溅药水效果 + 滞留药水效果(持续 100%)
- 基础效果:再生 V(30s)+ 吸收 IV(2min)+ 抗性 I(5min)+ 防火 I(5min)
7.4 投掷模式
- 内置 Swift Throw 25(射线检测即击)
- 命中时:先触发溅射效果(基础增益 + 喷溅药水效果,随距离衰减),随后生成区域效果云(基础增益 + 滞留药水效果)
- 附魔额外效果(锋利/力量/击退/火焰弹/导灵/多重射击)均生效
7.5 药水效果存储
- 合成时,从配方中的喷溅/滞留药水中读取药水效果,按规则合并并存储至 NBT
- 工具提示显示完整的溅射效果和云效果信息
7.6 铁砧兼容性
- 绕过“代价过高”的 39 级上限:超级附魔金苹果在铁砧操作中无视原版 39 级经验值消耗限制,因此始终可以附魔
- RepairCost 锁定为 10,以防止惩罚呈指数级增长
- 可通过铁砧施加额外附魔(锋利/力量/击退/火焰弹/无限/耐久/快速装填/导灵/多重射击/穿透/忠诚)
VIII. 终极附魔金苹果
8.1 物品概览
| 属性 |
描述 |
| 物品 ID |
hello-mod:ultimate_enchanted_golden_apple |
| 文本颜色 |
亮金色 (GOLD) |
| 内置附魔 |
Efficiency 9, Unbreaking 10, Swift Throw 25, Infinity 1 |
| 获取方式 |
自定义进度奖励(拥有全部 14 种有效附魔且均为最大等级的超级附魔金苹果) |
8.2 模式切换
- 手持时左键点击可在食用/投掷模式间切换,冷却时间为 2 个游戏刻(比超级版本更快)
- 名称动态变化:食用模式下为 "Ultimate Enchanted Golden Apple",投掷模式下为 "Throwable Ultimate Enchanted Golden Apple"
8.3 食用模式
- Efficiency 9 将食用时间缩短至约 3 个游戏刻(近乎即时)
- 固定效果(无药水 NBT):
| 效果 |
等级 |
持续时间 |
| Regeneration |
V |
60s |
| Resistance |
III |
60s |
| Strength |
V |
60s |
- 消耗判定:Unbreaking 10 检定通过(91% 概率)→ 不消耗 + 3 秒使用冷却;失败(9%)→ 消耗,无冷却
8.4 投掷模式
- Swift Throw 25 (>20) → 射线检测即击模式
- 命中时 4 格半径检测:
- 敌对生物:10 点真实伤害(无视护甲)+ 无条件闪电打击
- 友好生物/玩家:Regeneration V(60s)
- 范围内的所有实体均适用附魔额外效果(锋利/力量/击退/火焰弹/导灵)
- 消耗判定:内置 Infinity + Unbreaking 10;投掷时不消耗,进入 30 秒冷却(受 Quick Charge 减少);Unbreaking 检定通过则无冷却
8.5 铁砧兼容性
- 与超级版本共享铁砧机制:绕过“代价过高”的 39 级上限,RepairCost 锁定为 10
- 可通过铁砧施加额外附魔(附魔列表与超级版本相同)
8.6 进度要求
- 超级附魔金苹果上需拥有全部 14 种有效附魔,且处于合法最高等级:
- Swift Throw 25, Sharpness V, Power V, Punch II, Flame I, Channeling I, Multishot 10, Infinity I, Unbreaking III, Quick Charge III, Knockback II, Fire Aspect II, Efficiency V, Frost Walker II
- 触发时机:当玩家将符合条件的超级附魔金苹果从铁砧取出时,
SuperAppleAnvilMixin 检测到该情况并给予进度奖励
- 完成后,
AdvancementRewardMixin 发放奖励:1 个终极附魔金苹果(含 4 种内置附魔)+ 1000 经验等级
- 若玩家背包已满,奖励物品将掉落至地面
IX. 实用功能
9.1 实体生命 HUD
- 准星瞄准实体时,在屏幕上显示目标当前 HP / 最大 HP
- 检测距离可配置(默认 128 格)
- 可通过调试菜单独立开关
9.2 手持物品 HUD
- 在主手物品左上角显示物品名称和数量
- 高级模式:额外显示物品耐久度和完整 NBT 标签数据
- 可通过调试菜单独立开关
9.3 调试菜单
- 通过自定义按键绑定打开(默认未绑定,可在按键设置中配置)
- 提供子菜单:
- 实体生命显示设置(开关 + 检测距离滑块)
- 手持物品显示设置(开关 + 高级模式开关)
- 调试日志开关(独立控制 10 个日志模块:cake/place/food/potion/damage/swift throw/client/frost walker/infinity cooldown/player behavior)
9.4 持久化配置
- 配置文件位于
config/hello-mod.json
- 所有设置更改自动保存;启动时自动加载
- 人类可读的 JSON 格式,支持手动编辑
X. 技术架构
10.1 核心技术栈
| 组件 |
技术 |
| Mod 框架 |
Fabric Loader 0.15.3 + Fabric API 0.97.1 |
| 游戏版本 |
Minecraft 1.20.4 |
| Java 版本 |
Java 17 |
| 构建工具 |
Gradle + Fabric Loom 1.7 |
| 代码修改 |
Mixin Injection |
| 映射表 |
Yarn 1.20.4+build.3:v2 |
10.2 Mixin 注入点
| Mixin 类 |
目标 |
用途 |
| FoodPotionEnchantableMixin |
Item.isEnchantable() / Item.getEnchantability() |
使食物/药水可在附魔台附魔,并提供附魔能力值 |
| EnchantingTableMixin |
EnchantmentHelper.getPossibleEntries() |
在附魔台中为食物/药水返回自定义附魔列表 |
| EnchantmentAcceptItemMixin |
Enchantment.isAcceptableItem() |
允许通过铁砧上的附魔书对食物/药水进行附魔 |
| PlayerEatFoodMixin |
PlayerEntity.eatFood() |
食物附魔触发效果(锋利/击退/火焰/冰霜) |
| CakeBlockMixin |
CakeBlock.tryEat() |
蛋糕附魔触发效果 |
| CakePlaceMixin |
CakeBlock.onPlaced() |
放置蛋糕时存储附魔数据 |
| EfficientEatingMixin |
Item.getMaxUseTime() |
提升进食速度效率 |
| UnbreakingFoodMixin |
PlayerEntity.eatFood() RETURN |
检查食物的耐久修复 |
| PotionItemMixin |
ThrowablePotionItem.use() |
药水投掷逻辑(无限/耐久修复/多重射击/消耗) |
| PotionEntityMixin |
PotionEntity.onCollision() |
药水命中效果(锋利/力量/击退/火焰/引雷) |
| SwiftThrowTickMixin |
PotionEntity.tick() |
迅捷投掷射线检测模式 |
| MultishotEnchantmentMixin |
— |
多重射击辅助功能 |
| PiercingPotionMixin |
PotionEntity collision |
穿透逻辑 |
| LoyaltyPotionMixin |
PotionEntity.tick() |
忠诚返回逻辑 |
| LoyaltyCollisionMixin |
PotionEntity collision |
忠诚返回碰撞处理 |
| LivingEntityDamageCooldownMixin |
LivingEntity.damage() |
清除药水/闪电伤害的无敌帧 |
| SuperAppleCraftingMixin |
CraftingScreenHandler.updateResult |
合成超级金苹果时添加迅捷投掷 + 药水数据 |
| SuperAppleAnvilMixin |
AnvilScreenHandler.updateResult |
绕过 39 级上限 + 锁定修理成本 + 触发进度奖励 |
| AdvancementRewardMixin |
PlayerAdvancementTracker.grantCriterion() |
终极金苹果进度奖励 |
| PlayerBehaviorLogMixin |
PlayerEntity behavior |
玩家行为日志记录(攻击/交互/受伤/死亡/掉落/跳跃等) |
| PlayerBlockInteractLogMixin |
Block interaction |
方块放置/破坏/交互日志记录 |
| client/DrawContextCooldownMixin |
DrawContext.drawItemInSlot() |
无限冷却覆盖层渲染 |
| client/SwiftThrowRenderMixin |
Client |
在射线检测模式下隐藏药水实体 |
| client/SuperAppleAttackMixin |
MinecraftClient.doAttack() |
金苹果左键点击模式切换 |
| client/BehaviorLogClientMixin |
Client tick |
客户端行为日志记录(刻事件) |
| client/BehaviorLogKeyboardMixin |
Client keyboard |
客户端行为日志记录(键盘输入) |
| client/BehaviorLogMouseMixin |
Client mouse |
客户端行为日志记录(鼠标点击) |
10.3 包结构
com.example.hellomod
├── HelloMod.java # 主入口点,注册事件和系统
├── advancement/ # 进度检查
│ └── UltimateAppleChecker.java # 终极金苹果附魔检查器
├── block/ # 蛋糕附魔存储、方块实体
│ ├── CakeEnchantmentStorage.java # 内存中蛋糕附魔数据管理
│ ├── EnchantedCakeBlockEntity.java
│ └── HelloModBlockEntities.java
├── client/ # 客户端功能
│ ├── HelloModClient.java # 客户端入口点
│ ├── EmptyEntityRenderer.java # 空渲染器(投掷实体不可见,避免高速视觉错误)
│ ├── EntityHealthHud.java # 实体生命 HUD
│ ├── InfinityCooldownClientState.java # 无限冷却客户端同步
│ ├── DebugMenuScreen.java # 调试菜单 UI
│ ├── DebugLogSettingScreen.java # 日志开关 UI
│ ├── HealthHudSettingScreen.java # 生命 HUD 设置 UI
│ └── ItemHudSettingScreen.java # 物品 HUD 设置 UI
├── config/ # 配置持久化
│ └── ModConfig.java
├── damage/ # 自定义伤害来源
│ ├── ModDamageTypes.java
│ ├── SharpFoodDamageSource.java
│ ├── SharpPotionDamageSource.java
│ ├── PowerPotionDamageSource.java
│ └── UltimateAppleDamageSource.java
├── debug/ # 调试日志控制
│ └── DebugLogConfig.java
├── effect/ # 自定义效果
│ └── FrostWalkerFoodEffect.java # 冰霜行者食物效果(刻事件)
├── enchantment/ # 附魔系统
│ ├── ModEnchantments.java # 自定义附魔注册
│ ├── SwiftThrowEnchantment.java # 迅捷投掷附魔定义
│ ├── InfinityCooldownManager.java # 无限冷却服务端管理
│ └── InfinityCooldownSync.java # 冷却状态网络同步
├── entity/ # 自定义实体
│ ├── ModEntities.java # 实体注册
│ ├── SuperGoldenAppleEntity.java # 超级金苹果投掷实体
│ └── UltimateGoldenAppleEntity.java # 终极金苹果投掷实体
├── item/ # 自定义物品
│ ├── ModItems.java # 物品注册
│ ├── SuperEnchantedGoldenAppleItem.java # 超级附魔金苹果
│ ├── UltimateEnchantedGoldenAppleItem.java # 终极附魔金苹果
│ ├── SuperAppleCraftingHandler.java # 合成辅助(遗留,兼容)
│ └── SuperApplePotionMerger.java # 药水效果合并辅助
├── network/ # 网络通信
│ ├── SuperAppleModeSwitchC2SPacket.java # 金苹果模式切换同步
│ ├── EntityNbtRequestC2SPacket.java # 实体 NBT 请求(C2S)
│ ├── EntityNbtResponseS2CPacket.java # 实体 NBT 响应(S2C)
│ └── EntityNbtCache.java # 客户端 NBT 缓存(500ms 过期)
└── mixin/ # 所有 Mixin 注入类
├── client/ # 客户端 Mixins
└── ... # 见上表
10.4 关键设计决策
-
蛋糕特殊处理:蛋糕是方块而非物品,因此无法直接读取 ItemStack NBT。使用 CakeEnchantmentStorage 将附魔数据绑定到方块坐标——在放置时写入,完全被吃掉时清除。
-
药水附魔数据传递:附魔存储在药水 ItemStack 的 NBT 中。投掷时,完整的 ItemStack 通过 potionEntity.setItem(stack) 传递给投射物实体。命中时,EnchantmentHelper.getLevel() 从实体的堆栈中读取数据。
-
无限冷却系统:不使用原版的 ItemCooldownManager(它会影响所有同类物品)。而是使用一个自定义冷却管理器,键为玩家 UUID + NBT 标签(InfinityMarked),仅影响被特别标记的物品。
-
快速投掷射线检测:在较高的快速投掷等级(>20)下,基于物理的投掷速度过快,导致穿墙和碰撞检测失败。切换为逐刻射线追踪传送,以确保正确的碰撞检测。
-
铁砧绕过“过于昂贵”上限:当经验成本超过 39 级时,原版铁砧会拒绝操作。SuperAppleAnvilMixin 通过在 updateResult 开始时临时将玩家标记为创造模式,随后恢复原始状态来绕过此检查,确保超级/终极金苹果始终可以在铁砧上加工。
-
投射物实体空渲染:超级/终极金苹果的投射物实体使用 EmptyEntityRenderer(shouldRender() 返回 false),因为在快速投掷 25 级射线模式下实体移动极快,渲染纹理会产生视觉伪影。玩家看到的是暴击粒子轨迹,而非飞行的物品实体。
-
移除药水/闪电伤害的无敌帧:LivingEntityDamageCooldownMixin 检查 damage() 头部的伤害来源。如果是 sharp_potion、power_potion 或 lightning_bolt,它将 timeUntilRegen 和 hurtTime 重置为 0,确保多个药水附魔伤害和引雷伤害在同一刻内正确叠加。
-
多重射击等级上限修改:MultishotEnchantmentMixin 注入 Enchantment.getMaxLevel() 将多重射击附魔的原版最大等级从 1 提升至 10,支持更大范围的投射物散布。
-
实体 NBT 网络同步:实体详情 HUD 需要显示服务器的完整 NBT 数据(包括药水效果)。这通过 EntityNbtRequestC2SPacket(客户端请求)→ EntityNbtResponseS2CPacket(服务器响应)→ EntityNbtCache(客户端缓存,500ms 后过期)的合作实现跨端数据同步。
XI. 附魔概览表
| 附魔 |
食物 |
药水 |
最高等级 |
备注 |
| Sharpness |
✅ |
✅ |
V |
食物伤害食用者,药水伤害目标 |
| Knockback |
✅ |
— |
II |
随机方向 |
| Fire Aspect |
✅ |
— |
II |
每级持续 4s |
| Efficiency |
✅ |
— |
V |
每级减少 10% 进食时间 |
| Frost Walker |
✅ |
— |
III |
冰霜 + 持续伤害 |
| Unbreaking |
✅ |
✅ |
III |
不消耗的概率 |
| Power |
— |
✅ |
V |
与 Sharpness 叠加 |
| Punch |
— |
✅ |
II |
沿飞行方向击退 |
| Flame |
— |
✅ |
I |
5s 火焰 |
| Infinity |
— |
✅ |
I |
无消耗 + 冷却 |
| Channeling |
— |
✅ |
I |
雷雨 AOE 闪电 |
| Multishot |
— |
✅ |
10 |
锥形散布(原版上限为 1,通过 Mixin 提升至 10) |
| Quick Charge |
— |
✅ |
V |
减少 Infinity 冷却 |
| Piercing |
— |
✅ |
IV |
穿透多个实体 |
| Loyalty |
— |
✅ |
III |
2s 后返回 |
| Swift Throw |
— |
✅ |
∞ (合法上限 19) |
自定义附魔;合成表上限 10(仅限书),铁砧合法上限 19 |
XII. 运行环境与依赖项
- Minecraft: 1.20.4
- Fabric Loader: ≥ 0.15.0
- Fabric API: 任意兼容版本
- Java: ≥ 17
- 许可证: MIT
Better Enchanted
Fabric Mod | Minecraft 1.20.4 | Java 17
Bring vanilla enchantment effects to food and potions — let them have enchantment abilities too.
Introduction
Better Enchanted is a Minecraft Fabric mod whose core gameplay revolves around creatively applying vanilla weapon, bow, crossbow, and trident enchantment effects to food and thrown potions. Food enchantments trigger on the eater when consumed, while potion enchantments trigger on targets upon impact. All damage formulas reference MC 1.20.4 vanilla enchantment mechanics as closely as possible for balance and consistency.
0. Enchantment Acquisition Mechanism
By default, the vanilla enchanting table and anvil reject food and potions. This mod wires up the entire enchantment pipeline via Mixins so food/potions can be enchanted like weapons:
- Enchanting table:
FoodPotionEnchantableMixin makes Item.isEnchantable() return true for food/potions and provides reasonable enchantability values (plain food 10, potions 15, super/ultimate golden apple 22).
EnchantingTableMixin injects EnchantmentHelper.getPossibleEntries() to return the mod's custom list of available enchantments for food/potions.
- Anvil (enchanted books):
EnchantmentAcceptItemMixin injects Enchantment.isAcceptableItem() so matching enchanted books can be applied to food/potions.
- Enchantable scope:
- Food: Sharpness, Knockback, Fire Aspect, Efficiency, Frost Walker, Unbreaking
- Potions: Sharpness, Power, Punch, Flame, Infinity, Unbreaking, Multishot, Quick Charge, Piercing, Channeling, Loyalty, Swift Throw
- Super/Ultimate Enchanted Golden Apple: supports the full food + potion enchantment set
I. Food Enchantments
Food enchantments apply to all edible items and are also compatible with cake blocks (cakes use a dedicated block enchantment storage system).
1.1 Sharpness
- Effect: Deals damage to the eater upon consumption
- Formula:
damage = 0.5 × level + 0.5
- Sharpness I = 1.0 damage, II = 1.5, III = 2.0, IV = 2.5, V = 3.0
- Custom damage source: Has a unique death message ("XXX had their throat cut by sharp food")
- Cake support: Reads sharpness level from CakeEnchantmentStorage at the cake's position
1.2 Knockback
- Effect: Applies knockback to the eater upon consumption
- Direction: Random direction (360° random angle), simulating being "flung" by the food
- Strength formula:
- Horizontal:
strength = 0.5 × level
- Vertical: If on ground, gives a small upward boost (max 0.4)
- Reference: Adapted from MC 1.20.4
PlayerEntity.attack() knockback logic
1.3 Fire Aspect
- Effect: Ignites the eater upon consumption
- Duration:
level × 4 seconds
- Fire Aspect I = 4s, Fire Aspect II = 8s
- Reference: Identical to MC 1.20.4 vanilla Fire Aspect logic (
target.setOnFireFor(level * 4))
1.4 Efficiency
- Effect: Speeds up eating
- Formula: Each level reduces eating time by 10%
- Efficiency I = 10% faster, Efficiency V = 50% faster
- Implementation: Mixin into
Item.getMaxUseTime() to reduce eating tick count
1.5 Frost Walker
- Effect: Grants Frost Walker effect after eating
- Duration: Base 20 seconds + 10 seconds per level
- Frost Walker I = 30s, II = 40s, III = 50s
- Ice formation: Water beneath the player freezes into frosted ice during the effect
- Continuous damage: Takes 1 frost damage every 4 seconds, with interval reduced by 0.5s per level
- Frost Walker I = every 3.5s, II = every 3s
- Visual effect: Health bar displays in blue frozen style
- Configurable: Frost Walker logging can be toggled via debug menu
1.6 Unbreaking
- Effect: Chance to not consume food after eating
- Probability formula: References MC 1.20.4 vanilla Unbreaking formula
- Consumption probability =
1 / (level + 1)
- Non-consumption probability =
level / (level + 1)
- Unbreaking I = 50% no consumption, II = 66.7%, III = 75%
- Cake special handling: When triggered, restores one cake bite (BITES - 1); if the cake was just fully eaten, restores it to the last-bite state
II. Potion Enchantments — Weapon/Bow Category
Potion enchantments trigger when throwable potions (splash/lingering) are thrown and hit something. All damage/effects apply at full strength to directly hit entities, and with distance-based falloff to entities within splash range (4 blocks).
2.1 Sharpness [Potion]
- Effect: Thrown potion deals damage to hit entities
- Formula:
damage = 0.5 × level + 0.5 (same as food Sharpness)
- Splash: Distance-attenuated damage within 4 blocks (
damage × (1 - distance/4))
- Stacking: Stacks additively with Power enchantment damage
- Custom damage source: Unique death message ("XXX was shattered by a sharp potion")
2.2 Power [Potion]
- Effect: Thrown potion deals damage to hit entities
- Formula: References MC 1.20.4 bow Power enchantment
damage = level + 1 (simulating arrow base=2 Power bonus)
- Power I = 2.0, II = 3.0, III = 4.0, IV = 5.0, V = 6.0
- Stacking: Adds directly to Sharpness damage
- Damage source: When Power damage ≥ Sharpness damage, uses Power-specific death message ("XXX was obliterated by a powerful potion")
2.3 Punch [Potion]
- Effect: Thrown potion applies knockback to hit entities
- Formula: References MC 1.20.4 bow Punch enchantment (
AbstractArrowEntity.onHit)
knockbackStrength = punchLevel × 0.6
- Direction:
- Direct hit: Along potion flight direction (normalized horizontal components)
- Splash range: From impact point toward entity, strength attenuated by distance
2.4 Flame [Potion]
- Effect: Thrown potion ignites targets on hit
- Direct hit: 5 seconds of fire (100 ticks), matching MC 1.20.4 bow Flame rules
- Splash range: Fire duration attenuated by distance (
ceil(5 × (1 - distance/4)) seconds)
- Level: Only level I (matching vanilla)
2.5 Channeling [Potion]
- Effect: MC 1.20.4 trident Channeling rules adapted as AOE version
- Conditions:
- Must be thunderstorm weather (
world.isThundering())
- Target entity position must have sky visibility (
isSkyVisible)
- Range: All living entities within 4 blocks of potion impact point
- Result: Each qualifying entity gets a lightning bolt summoned at its position
- Lightning attribution: Lightning channeler set to the thrower (affects drops and XP)
- Level: Only level I (matching vanilla)
III. Potion Enchantments — Crossbow Category
3.1 Multishot [Potion]
- Effect: Single throw produces multiple potions in a cone spread
- Count formula: Total projectiles =
2 + level
- Multishot I = 3, II = 4, III = 5
- Distribution rules:
- First potion (primary) flies straight along aim direction (cone center)
- First 8 extra projectiles distribute evenly on a 10° cone circumference
- Beyond 8 extras: randomly distributed within the cone (0°–10°, using sqrt for area-uniform distribution)
- Consumption: Only consumes 1 potion
- Compatibility: Fully compatible with all Swift Throw modes (physics/raycast)
3.2 Quick Charge [Potion]
- Effect: Reduces Infinity enchantment cooldown time
- Formula: Each level reduces cooldown by 20% (base 30 seconds)
- Lv I = 24s, Lv II = 18s, Lv III = 12s, Lv IV = 6s, Lv V = 0s (no cooldown)
- Prerequisite: Must be used with Infinity enchantment; has no effect alone
3.3 Piercing [Potion]
- Effect: References MC 1.20.4 crossbow Piercing rules
- Mechanics:
- Potion can pass through
level entities (hitting level + 1 total)
- Applies enchantment effects (Sharpness/Power/Punch/Flame) to each pierced entity
- Already-pierced entities won't be hit again
- Destroys normally and triggers splash effects when hitting a block or reaching pierce limit
IV. Potion Enchantments — Trident Category
4.1 Loyalty [Potion]
- Effect: Adapted from MC 1.20.4 trident Loyalty rules
- Mechanics:
- Potion automatically returns to thrower 2 seconds after being thrown
- Return speed =
0.5 × level blocks/tick
- Lv I = 10 blocks/s, Lv II = 20 blocks/s, Lv III = 30 blocks/s
- If it hits an entity or block during flight/return, it's consumed normally (won't return)
- Successful return gives the potion item back to the player
- Consumption logic: Potion is consumed immediately on throw (entity itself carries return logic)
V. Universal Potion Enchantments
5.1 Infinity [Potion]
- Effect: Throwing potion doesn't consume it
- Cooldown system:
- Custom cooldown system based on NBT tag (
InfinityMarked)
- Only affects items with the Infinity enchantment, not other identical items
- Base cooldown: 30 seconds (reduced by Quick Charge)
- Interaction with Unbreaking:
- With Unbreaking: perform durability check — pass → no cooldown, fail → enter cooldown
- Without Unbreaking: always enters cooldown
- Client display: Gray semi-transparent cooldown overlay synced via networking
- Cooldown blocking: Cannot use the item again while on cooldown
5.2 Unbreaking [Potion]
- Effect: Chance to not consume potion after throwing
- Formula: Same as food Unbreaking (consumption probability =
1/(level+1))
- Interaction with Infinity: Check result determines whether cooldown triggers (see above)
VI. Custom Enchantments
6.1 Swift Throw
- Effect: Increases potion throw speed and trajectory flatness
- Max level at enchanting table: 10 (books only; cannot be applied directly to potions/items)
- Max legal level at anvil: 19 (cannot reach the >20 raycast mode, preserving the rarity of the super golden apple's Swift Throw 25)
- Speed formula:
actual speed = base speed (0.5) × (1 + 0.5 × level)
- Angle formula: Upward offset angle
y = 80 / (4 + level) degrees
- Higher levels = flatter trajectory
- When offset angle < 1°, set to 0 (perfectly flat throw)
- Two modes:
- Level 1–20 (Physics mode): Normal physics throw with speed and direction calculated by formula, affected by gravity
- Level >20 (Raycast mode): Instant hit via per-tick raytrace teleportation; potion entity is invisible and gravity-free; crit particles spawn every 0.5 blocks along the firing direction (up to 64 blocks)
- Compatibility: Fully compatible with Multishot — extra projectiles also use the same Swift Throw mode
VII. Super Enchanted Golden Apple
7.1 Item Overview
| Property |
Description |
| Item ID |
hello-mod:super_enchanted_golden_apple |
| Text Color |
Light purple (LIGHT_PURPLE) |
| Built-in Enchantment |
Swift Throw 25 |
| Acquisition |
3×3 crafting table (Gold Blocks ×4 + Splash Potions ×2 + Lingering Potions ×2 + Golden Apple ×1) |
7.2 Mode Switching
- Left-click while held to switch between eat/throw mode, 5 game tick cooldown
- Dynamic name: "Super Enchanted Golden Apple" in eat mode, "Throwable Super Enchanted Golden Apple" in throw mode
7.3 Eat Mode
- Eating time 32 ticks (1.6s), accelerated by Efficiency enchantment
- Eat effects = Base effects + Splash potion effects + Lingering potion effects (100% duration)
- Base effects: Regeneration V (30s) + Absorption IV (2min) + Resistance I (5min) + Fire Resistance I (5min)
7.4 Throw Mode
- Built-in Swift Throw 25 (raycast instant-hit)
- On impact: first triggers splash effects (base buffs + splash potion effects, distance-attenuated), then spawns area effect cloud (base buffs + lingering potion effects)
- Enchantment extra effects (Sharpness/Power/Punch/Flame/Channeling/Multishot) all work
7.5 Potion Effect Storage
- On crafting, reads potion effects from splash/lingering potions in recipe, merges by rules and stores in NBT
- Tooltip displays full splash effects and cloud effects info
7.6 Anvil Compatibility
- Bypasses the "Too Expensive" 39-level cap: The super enchanted golden apple ignores the vanilla 39-level experience cost limit during anvil operations, so it can always be enchanted
- RepairCost locked at 10 to prevent exponential penalty growth
- Additional enchantments can be applied via anvil (Sharpness/Power/Punch/Flame/Infinity/Unbreaking/Quick Charge/Channeling/Multishot/Piercing/Loyalty)
VIII. Ultimate Enchanted Golden Apple
8.1 Item Overview
| Property |
Description |
| Item ID |
hello-mod:ultimate_enchanted_golden_apple |
| Text Color |
Bright gold (GOLD) |
| Built-in Enchantments |
Efficiency 9, Unbreaking 10, Swift Throw 25, Infinity 1 |
| Acquisition |
Custom advancement reward (Super Enchanted Golden Apple with all 14 valid enchantments at max level) |
8.2 Mode Switching
- Left-click while held to switch between eat/throw mode, 2 game tick cooldown (faster than Super version)
- Dynamic name change: "Ultimate Enchanted Golden Apple" in eat mode, "Throwable Ultimate Enchanted Golden Apple" in throw mode
8.3 Eat Mode
- Efficiency 9 reduces eating time to ~3 ticks (nearly instant)
- Fixed effects (no potion NBT):
| Effect |
Level |
Duration |
| Regeneration |
V |
60s |
| Resistance |
III |
60s |
| Strength |
V |
60s |
- Consumption: Unbreaking 10 check passes (91% chance) → not consumed + 3s use cooldown; fails (9%) → consumed, no cooldown
8.4 Throw Mode
- Swift Throw 25 (>20) → raycast instant-hit mode
- 4-block radius detection on impact:
- Hostile mobs: 100 true damage (ignores armor) + unconditional lightning strike
- Friendly mobs/Players: Regeneration V (60s)
- Enchantment extra effects (Sharpness/Power/Punch/Flame/Channeling) apply to all entities in range
- Consumption: Built-in Infinity + Unbreaking 10; no consumption on throw, enters 30s cooldown (reduced by Quick Charge); Unbreaking check pass = no cooldown
8.5 Anvil Compatibility
- Shares the anvil mechanism with the super version: bypasses the "Too Expensive" 39-level cap, RepairCost locked at 10
- Additional enchantments can be applied via anvil (same enchantment list as the super version)
8.6 Advancement Requirements
- All 14 valid enchantments on a Super Enchanted Golden Apple at their legal max level:
- Swift Throw 25, Sharpness V, Power V, Punch II, Flame I, Channeling I, Multishot 10, Infinity I, Unbreaking III, Quick Charge III, Knockback II, Fire Aspect II, Efficiency V, Frost Walker II
- Trigger timing: When the player takes out a qualifying Super Enchanted Golden Apple from the anvil,
SuperAppleAnvilMixin detects it and grants the advancement
- Once completed,
AdvancementRewardMixin issues the reward: 1 Ultimate Enchanted Golden Apple (with 4 built-in enchantments) + 1000 experience levels
- If the player's inventory is full, the reward item drops on the ground
IX. Utility Features
9.1 Entity Health HUD
- Displays target's current HP / max HP on screen when crosshair is aimed at an entity
- Detection distance is configurable (default 128 blocks)
- Can be independently toggled via debug menu
9.2 Held Item HUD
- Displays main hand item name and count in the top-left corner
- Advanced mode: Additionally shows item durability and full NBT tag data
- Can be independently toggled via debug menu
9.3 Debug Menu
- Opened via custom keybind (unbound by default, configurable in key settings)
- Provides sub-menus:
- Entity health display settings (toggle + detection distance slider)
- Held item display settings (toggle + advanced mode toggle)
- Debug log toggles (independent control of 10 log modules: cake/place/food/potion/damage/swift throw/client/frost walker/infinity cooldown/player behavior)
9.4 Persistent Configuration
- Config file located at
config/hello-mod.json
- All setting changes auto-save; auto-loads on startup
- Human-readable JSON format, supports manual editing
X. Technical Architecture
10.1 Core Tech Stack
| Component |
Technology |
| Mod Framework |
Fabric Loader 0.15.3 + Fabric API 0.97.1 |
| Game Version |
Minecraft 1.20.4 |
| Java Version |
Java 17 |
| Build Tool |
Gradle + Fabric Loom 1.7 |
| Code Modification |
Mixin Injection |
| Mappings |
Yarn 1.20.4+build.3:v2 |
10.2 Mixin Injection Points
| Mixin Class |
Target |
Purpose |
| FoodPotionEnchantableMixin |
Item.isEnchantable() / Item.getEnchantability() |
Make food/potions enchantable in the table and provide enchantability values |
| EnchantingTableMixin |
EnchantmentHelper.getPossibleEntries() |
Return custom enchantment list for food/potions in the enchanting table |
| EnchantmentAcceptItemMixin |
Enchantment.isAcceptableItem() |
Allow food/potions to be enchanted via enchanted books on the anvil |
| PlayerEatFoodMixin |
PlayerEntity.eatFood() |
Food enchantment triggers (Sharpness/Knockback/Fire/Frost) |
| CakeBlockMixin |
CakeBlock.tryEat() |
Cake enchantment triggers |
| CakePlaceMixin |
CakeBlock.onPlaced() |
Store enchantment data when placing cake |
| EfficientEatingMixin |
Item.getMaxUseTime() |
Efficiency eating speed boost |
| UnbreakingFoodMixin |
PlayerEntity.eatFood() RETURN |
Food Unbreaking check |
| PotionItemMixin |
ThrowablePotionItem.use() |
Potion throw logic (Infinity/Unbreaking/Multishot/consumption) |
| PotionEntityMixin |
PotionEntity.onCollision() |
Potion hit effects (Sharpness/Power/Punch/Flame/Channeling) |
| SwiftThrowTickMixin |
PotionEntity.tick() |
Swift Throw raycast mode |
| MultishotEnchantmentMixin |
— |
Multishot helper |
| PiercingPotionMixin |
PotionEntity collision |
Piercing logic |
| LoyaltyPotionMixin |
PotionEntity.tick() |
Loyalty return logic |
| LoyaltyCollisionMixin |
PotionEntity collision |
Loyalty return collision handling |
| LivingEntityDamageCooldownMixin |
LivingEntity.damage() |
Clears invincibility frames for potion/lightning damage |
| SuperAppleCraftingMixin |
CraftingScreenHandler.updateResult |
Add Swift Throw + potion data when crafting super golden apple |
| SuperAppleAnvilMixin |
AnvilScreenHandler.updateResult |
Bypass 39-level cap + lock RepairCost + advancement trigger |
| AdvancementRewardMixin |
PlayerAdvancementTracker.grantCriterion() |
Ultimate golden apple advancement reward |
| PlayerBehaviorLogMixin |
PlayerEntity behavior |
Player behavior logging (attack/interact/hurt/death/drop/jump, etc.) |
| PlayerBlockInteractLogMixin |
Block interaction |
Block place/break/interact logging |
| client/DrawContextCooldownMixin |
DrawContext.drawItemInSlot() |
Infinity cooldown overlay rendering |
| client/SwiftThrowRenderMixin |
Client |
Hide potion entity in raycast mode |
| client/SuperAppleAttackMixin |
MinecraftClient.doAttack() |
Golden apple left-click mode switch |
| client/BehaviorLogClientMixin |
Client tick |
Client behavior logging (tick events) |
| client/BehaviorLogKeyboardMixin |
Client keyboard |
Client behavior logging (keyboard input) |
| client/BehaviorLogMouseMixin |
Client mouse |
Client behavior logging (mouse clicks) |
10.3 Package Structure
com.example.hellomod
├── HelloMod.java # Main entrypoint, registers events and systems
├── advancement/ # Advancement checks
│ └── UltimateAppleChecker.java # Ultimate golden apple enchantment checker
├── block/ # Cake enchantment storage, block entities
│ ├── CakeEnchantmentStorage.java # In-memory cake enchantment data management
│ ├── EnchantedCakeBlockEntity.java
│ └── HelloModBlockEntities.java
├── client/ # Client-side features
│ ├── HelloModClient.java # Client entrypoint
│ ├── EmptyEntityRenderer.java # Empty renderer (thrown entity invisible, avoids high-speed visual bug)
│ ├── EntityHealthHud.java # Entity health HUD
│ ├── InfinityCooldownClientState.java # Infinity cooldown client sync
│ ├── DebugMenuScreen.java # Debug menu UI
│ ├── DebugLogSettingScreen.java # Log toggle UI
│ ├── HealthHudSettingScreen.java # Health HUD settings UI
│ └── ItemHudSettingScreen.java # Item HUD settings UI
├── config/ # Configuration persistence
│ └── ModConfig.java
├── damage/ # Custom damage sources
│ ├── ModDamageTypes.java
│ ├── SharpFoodDamageSource.java
│ ├── SharpPotionDamageSource.java
│ ├── PowerPotionDamageSource.java
│ └── UltimateAppleDamageSource.java
├── debug/ # Debug log control
│ └── DebugLogConfig.java
├── effect/ # Custom effects
│ └── FrostWalkerFoodEffect.java # Frost Walker food effect (tick event)
├── enchantment/ # Enchantment system
│ ├── ModEnchantments.java # Custom enchantment registration
│ ├── SwiftThrowEnchantment.java # Swift Throw enchantment definition
│ ├── InfinityCooldownManager.java # Infinity cooldown server-side management
│ └── InfinityCooldownSync.java # Cooldown state network sync
├── entity/ # Custom entities
│ ├── ModEntities.java # Entity registration
│ ├── SuperGoldenAppleEntity.java # Super golden apple thrown entity
│ └── UltimateGoldenAppleEntity.java # Ultimate golden apple thrown entity
├── item/ # Custom items
│ ├── ModItems.java # Item registration
│ ├── SuperEnchantedGoldenAppleItem.java # Super enchanted golden apple
│ ├── UltimateEnchantedGoldenAppleItem.java # Ultimate enchanted golden apple
│ ├── SuperAppleCraftingHandler.java # Crafting helper (legacy, compat)
│ └── SuperApplePotionMerger.java # Potion effect merge helper
├── network/ # Networking
│ ├── SuperAppleModeSwitchC2SPacket.java # Golden apple mode switch sync
│ ├── EntityNbtRequestC2SPacket.java # Entity NBT request (C2S)
│ ├── EntityNbtResponseS2CPacket.java # Entity NBT response (S2C)
│ └── EntityNbtCache.java # Client NBT cache (500ms expiry)
└── mixin/ # All Mixin injection classes
├── client/ # Client-side Mixins
└── ... # See table above
10.4 Key Design Decisions
-
Cake special handling: Cakes are blocks, not items, so ItemStack NBT can't be read directly. Uses CakeEnchantmentStorage to bind enchantment data to block coordinates — written on placement, cleared when fully eaten.
-
Potion enchantment data transfer: Enchantments are stored in the potion ItemStack's NBT. On throw, the complete ItemStack is passed to the projectile entity via potionEntity.setItem(stack). On impact, EnchantmentHelper.getLevel() reads from the entity's stack.
-
Infinity cooldown system: Doesn't use vanilla ItemCooldownManager (which affects all items of the same type). Instead uses a custom cooldown manager keyed by player UUID + NBT tag (InfinityMarked), only affecting specifically marked items.
-
Swift Throw raycast: At high Swift Throw levels (>20), physics-based throw speed is too fast causing wall-clipping and collision detection failures. Switches to per-tick raytrace teleportation to ensure correct collision detection.
-
Anvil bypasses "Too Expensive" cap: The vanilla anvil refuses operations when the experience cost exceeds 39 levels. SuperAppleAnvilMixin bypasses this check by temporarily flagging the player as creative mode at the start of updateResult, then restoring the original state afterward, ensuring super/ultimate golden apples can always be worked on the anvil.
-
Empty rendering for thrown entities: The super/ultimate golden apple thrown entities use EmptyEntityRenderer (shouldRender() returns false), because at Swift Throw 25 raycast mode the entity moves extremely fast and rendering the texture produces visual artifacts. Players see a crit-particle trajectory instead of the flying item entity.
-
Removing invincibility frames for potion/lightning damage: LivingEntityDamageCooldownMixin inspects the damage source at the head of damage(). If it's sharp_potion, power_potion, or lightning_bolt, it resets timeUntilRegen and hurtTime to 0, ensuring multiple potion enchantment damages and Channeling damage stack correctly within the same tick.
-
Multishot level cap modification: MultishotEnchantmentMixin injects Enchantment.getMaxLevel() to raise the Multishot enchantment's vanilla max level from 1 to 10, supporting a larger spread of thrown projectiles.
-
Entity NBT network sync: The entity detail HUD needs to display the server's full NBT data (including potion effects). This is achieved through the cooperation of EntityNbtRequestC2SPacket (client request) → EntityNbtResponseS2CPacket (server response) → EntityNbtCache (client cache, expires after 500ms) for cross-side data sync.
XI. Enchantment Overview Table
| Enchantment |
Food |
Potion |
Max Level |
Notes |
| Sharpness |
✅ |
✅ |
V |
Food damages eater, potion damages target |
| Knockback |
✅ |
— |
II |
Random direction |
| Fire Aspect |
✅ |
— |
II |
4s per level |
| Efficiency |
✅ |
— |
V |
-10% eating time per level |
| Frost Walker |
✅ |
— |
III |
Ice + continuous damage |
| Unbreaking |
✅ |
✅ |
III |
Chance to not consume |
| Power |
— |
✅ |
V |
Stacks with Sharpness |
| Punch |
— |
✅ |
II |
Knockback along flight direction |
| Flame |
— |
✅ |
I |
5s fire |
| Infinity |
— |
✅ |
I |
No consumption + cooldown |
| Channeling |
— |
✅ |
I |
Thunderstorm AOE lightning |
| Multishot |
— |
✅ |
10 |
Cone spread (vanilla cap is 1, raised to 10 via Mixin) |
| Quick Charge |
— |
✅ |
V |
Reduces Infinity cooldown |
| Piercing |
— |
✅ |
IV |
Passes through multiple entities |
| Loyalty |
— |
✅ |
III |
Returns after 2s |
| Swift Throw |
— |
✅ |
∞ (legal max 19) |
Custom enchantment; table max 10 (books only), anvil legal max 19 |
XII. Runtime Environment & Dependencies
- Minecraft: 1.20.4
- Fabric Loader: ≥ 0.15.0
- Fabric API: Any compatible version
- Java: ≥ 17
- License: MIT
评论 0
登录后参与评分
还没有评论,来抢沙发吧