MCBE 一些基于网络数据包的作弊功能实现(飞行/速度/传送/自动疾跑/转头)

  • 示例 Minecraft 版本: Bedrock 1.20.80

  • C -> S 表示客户端发往服务器的数据包

  • S -> C 表示服务器发往客户端的数据包

飞行/Fly

  1. 修改 S -> C update_abilities 数据包
  • 如果数据包的 entity_unique_id 与当前玩家的 entity_unique_id 一致,则遍历 abilities 字段获得 ability 实例
  • 把每个 ability 中 allowed 字段的 may_fly 设为 true
  • 把每个 ability 中 enabled 字段的 may_fly 设为 true
  1. 构造 S -> C update_abilities 数据包
  • entity_unique_id 设为当前玩家的 entity_unique_id
  • abilities 修改项与上一步一致
  • 发送数据包给客户端

此方法会受到摔落伤害

速度/Speed

  • 修改 S -> C update_abilities 数据包
    • 如果数据包的 entity_unique_id 与当前玩家的 entity_unique_id 一致,则遍历 abilities 字段获得 ability 实例
    • 修改每个 ability 的 walk_speed 字段(默认是 0.1)
  • 修改 S -> C update_attributes 数据包
    • 如果数据包的 runtime_entity_id 与当前玩家的 runtime_entity_id 一致,则遍历 attributes 字段获得 attribute 实例
    • 如果 attribute 的 nameminecraft:movement,则修改 attribute 的 currentdefault 字段(默认是 0.1)

传送/Teleport

构造 S -> C move_player 数据包

  • runtime_id 设为当前玩家的 runtime_entity_id
  • position 设为目标位置的 Vec3{x, y, z}
  • teleport 可填
1
2
3
4
{
cause: 'command',
source_entity_type: 1
}
  • 发送数据包给客户端

自动疾跑/AutoSprint

修改 C -> S player_input 数据包

  • 设置 input_data 中的 start_sprintingtrue

转头/SpinBot

修改 C -> S player_input 数据包

  • 设置 head_yaw 为目标头部偏航角
  • 设置 yaw 为目标偏航角
  • 设置 pitch 为目标俯仰角

设置角度为随机值即可实现乱转
此方法不影响当前客户端视角和移动

后记

  • 通过 S -> C start_game 数据包的 runtime_entity_id 字段获得当前玩家的 runtime_entity_id
  • 通过第一个 S -> C update_abilities 数据包的 entity_unique_id 字段获得当前玩家的 entity_unique_id

参考文献