🔌 Mixin 字节码注入参考与挂钩点
📌 代码仓库源码免责声明:本维基文档反映了仓库当前的源代码状态,可能包含领先于 CurseForge 与 Modrinth 上公开发布版本的最新开发提交或未发布功能。
Better Bats uses Bytecode Mixins to modify vanilla entity and world spawning behavior while keeping world saves 100% vanilla-safe.
☕ 独立开发者寄语:如果你喜欢蝙蝠逼真的三维群飞和鸟粪为庄稼施肥的生态体验,欢迎在 Ko-fi 上支持我的独立开发!
📋 完整 Mixin 注入映射表
| Mixin Class | Target Vanilla Class | Target Method | @At Injection Point | Cancellation / Behavior |
|---|---|---|---|---|
BatMixin | net.minecraft.world.entity.ambient.Bat | <init> | @At("TAIL") | Registers custom AI goals (Panic, Sleep, HuntLight, DiveBomb) into goalSelector. |
BatMixin | net.minecraft.world.entity.ambient.Bat | customServerAiStep | @At("HEAD") | cancellable = true. Completely replaces vanilla flight calculation with BatFlightHelper forces and resting logic. |
BatMixin | net.minecraft.world.entity.ambient.Bat | checkBatSpawnRules | @At("HEAD") | cancellable = true. Validates surface nighttime spawning rules. |
BatMixin | net.minecraft.world.entity.ambient.Bat | addAdditionalSaveData | @At("TAIL") | Writes betterbats:guano_ticks integer tag to ValueOutput. |
BatMixin | net.minecraft.world.entity.ambient.Bat | readAdditionalSaveData | @At("TAIL") | Reads betterbats:guano_ticks integer tag from ValueInput. |
GameEventDispatcherMixin | net.minecraft.world.level.gameevent.vibrations.VibrationSystem$Listener | handleGameEvent | @At("HEAD") | Notifies nearby bats of sprint/explosion vibrations. |
NaturalSpawnerMixin | net.minecraft.world.level.NaturalSpawner | m_6419_ | @At("HEAD") | Replaces vanilla bat spawn weights with bat_spawn_weight GameRule. |
See also: 系统架构与包结构 | 行为配置与状态访问器
