Puppet Players
一款用于 Minecraft 的 Fabric 模组,可在游戏中添加虚假的“傀儡”玩家
关于本项目
这是对 Carpet Mod 中最初实现的虚假玩家功能的一种现代化、简洁的实现方式。
与 Carpet Mod 中的原始实现相比,这些虚假玩家的实现方式存在一些根本性的差异。
本模组可以与 Carpet Mod 一起使用,Carpet 的虚假玩家操作同样适用于这些傀儡玩家;但推荐使用本模组提供的操作指令。
本模组的目标是尽可能使傀儡玩家的行为与真实玩家保持一致:
- 所有玩家逻辑都在正确的 tick 阶段执行。
- 玩家操作的客户端代码在服务器端进行模拟。
- 傀儡玩家通过发送数据包与服务器交互,就像真实玩家一样。
- 保持与所有模组的兼容性。
使用方法
本文档涵盖的是该模组的最新版本。对于 2.0.0 之前的版本,请参阅旧版文档。
安装模组后,操作员(operators)即可使用 /puppet 命令。
也可以通过修改配置,将该命令对所有玩家开放。
详情请参阅配置部分。
我们可以使用以下命令之一让傀儡玩家加入世界:
/puppet <username> join
/puppet <username> spawn
/puppet <username> spawn at <position> facing <rotation> in <dimension> in <gamemode>
/puppet <username> shadow
join 子命令会在指定傀儡上次登出的位置生成它,这实质上模拟了玩家自己加入服务器的情况。
spawn 子命令会在指定位置生成指定的傀儡;如果未指定位置,则会在命令执行者的位置生成。
shadow 子命令会让一个傀儡玩家取代当前在线的一名玩家加入游戏。
一旦玩家加入了世界,我们可以通过运行以下命令让玩家离开:
/puppet <player> leave
操控傀儡
玩家可以接管一个傀儡并以其身份进行游戏,而将自己的本体留在世界中:
/puppet <player>
你只能指定傀儡进行操控;如果你当前正在操控傀儡,则可以指定自己以回到原始身体。此功能默认禁用,必须通过设置 enable_puppeteering 来启用,详见 配置部分。
在操控傀儡期间,其他玩家会看到你是那个傀儡,并且你会恢复傀儡之前的位置和背包物品。在你停止操控后,对傀儡所做的任何更改都会保留。然而,统计数据和进度仍然与 你的 账户绑定。聊天也是如此,消息仍通过你的账户发送。
操控期间,你的原始身体会变成一个傀儡,因此你可以像对待其他傀儡一样对他们执行 /puppet 命令(但 leave 命令除外)。因为在服务器上,当你运行指定你名称的命令时,你仍然是在 你自己的 账户上游玩,此时目标将是你正在操控的玩家。例如,如果玩家 senseiwells 正在操控 SuperSanta,有人运行 /tp senseiwells,他们将会传送到玩家 SuperSanta 所在的位置。唯一的例外是 /puppet 命令,它将指向以该名称进行操控的人。
如果你在操控期间死亡,或者傀儡断开连接,你将停止操控。如果你在操控期间登出,你的原始身体将被登出,而傀儡将继续保持在线状态。
动作
傀儡玩家可以执行模仿真实玩家行为的各种动作。某些动作也可以对真实玩家执行。
以下是所有可用动作的列表:
| 操作 |
描述 |
参数 |
独立运行 |
仅傀儡 |
"minecraft:attack" |
使玩家进行攻击(左键点击)。 |
<once|hold|release> |
是 |
否 |
"minecraft:delay" |
在链式操作之间添加延迟。 |
<delay> |
否 |
否 |
"minecraft:drop" |
使玩家丢弃当前选中的物品。 |
<entire_stack> |
是 |
否 |
"minecraft:interrupt_look_at" |
中断当前的注视目标。 |
无 |
是 |
是 |
"minecraft:interrupt_move_to" |
中断玩家当前的寻路行为。 |
无 |
是 |
是 |
"minecraft:jump" |
使玩家跳跃。 |
<once|hold|release> |
是 |
是 |
"minecraft:look" |
使玩家看向某个方向。 |
<rotation> |
是 |
否 |
"minecraft:look_at" |
使玩家看向指定的目标。 |
position <pos> <lock?> 或 entity <entity> <lock?> |
是 |
是 |
"minecraft:move_to" |
使玩家寻路至某个位置或实体。 |
position <pos> <sprint?> <jump?> 或 entity <entity> <sprint?> <jump?> |
是 |
是 |
"minecraft:offhand" |
使玩家将物品与副手栏交换。 |
无 |
是 |
否 |
"minecraft:sneak" |
使玩家潜行。 |
<sneaking> |
是 |
是 |
"minecraft:sprint" |
使玩家疾跑。 |
<sprinting> |
是 |
是 |
"minecraft:swap_slot" |
使玩家切换到某个槽位。 |
<slot> |
是 |
否 |
"minecraft:use" |
使玩家使用物品(右键点击)。 |
<once|hold|release> |
是 |
否 |
要执行一个操作,我们可以使用以下命令使其独立运行:
/puppet <player> actions run <action> ...
这会使玩家立即执行该操作。
例如,要使玩家按住攻击键,你可以运行:
/puppet <player> actions run minecraft:attack hold
我们还可以通过运行以下命令将多个操作链接在一起:
/puppet <player> actions chain add <action> ...
一旦你向链中添加了操作,我们还可以运行以下命令来控制链式行为:
/puppet <player> actions chain loop <true|false> # 是否无限循环链式操作
/puppet <player> actions chain pause # 暂停执行链式操作
/puppet <player> actions chain resume # 恢复执行链式操作
/puppet <player> actions chain restart # 重新开始执行链式操作(从第一个操作开始)
/puppet <player> actions chain stop # 停止执行链式操作(并清除所有操作)
例如,要使玩家按住攻击键 5 秒,然后松开 2 秒,然后重复此过程,我们会运行:
/puppet <player> actions chain add minecraft:attack hold
/puppet <player> actions chain add minecraft:delay 5s
/puppet <player> actions chain add minecraft:attack release
/puppet <player> actions chain add minecraft:delay 2s
/puppet <player> actions chain loop true
配置
配置文件位于 ./config/puppet-player-config.json,默认情况下应如下所示:
{
"reload_puppet_players": true,
"respawn_puppet_players": true,
"puppet_player_death_delay": 0,
"operator_required_for_puppets": true,
"can_players_puppet_themselves": true,
"can_spawn_puppets_anywhere": true,
"can_spawn_whitelisted_players_as_puppets": true,
"enable_puppeteering": false,
"enabled_actions": "*"
}
"reload_puppet_players" - 当服务器关闭时,傀儡是否会在它们上次在线时重新加入
"respawn_puppet_players" - 傀儡死亡后是否重生;如果禁用,它们将离开游戏
"puppet_player_death_delay" - 傀儡死亡后重生的延迟时间(具体是重生还是离开由 respawn_puppet_players 决定)
"operator_required_for_puppets" - 玩家是否需要拥有操作员权限才能执行 /puppet 命令
"can_players_puppet_themselves" - 非操作员玩家是否可以对自身执行 /puppet 命令
"can_spawn_puppets_anywhere" - 是否可以运行 /puppet <username> spawn <position?> 在世界中的任何位置生成傀儡(与 join 不同,后者在它们上次登出的位置生成)
"can_spawn_whitelisted_players_as_puppets" - 是否可以将白名单中的玩家生成为傀儡
"enable_puppeteering" - 玩家是否能够接管一个傀儡并以其身份进行游玩
"enabled_actions" - 你可以让傀儡执行的已启用动作列表,使用 "*" 表示所有动作,或者列出已启用的动作,例如 ["attack", "use"]
对于生存服务器,可以使用以下推荐配置来启用该模组的较少“作弊”版本:
{
"reload_puppet_players": true,
"respawn_puppet_players": false,
"puppet_player_death_delay": 20,
"operator_required_for_puppets": true,
"can_players_puppet_themselves": true,
"can_spawn_puppets_anywhere": false,
"can_spawn_whitelisted_players_as_puppets": false,
"enable_puppeteering": false,
"enabled_actions": ["use", "attack", "drop", "swap_slot"]
}
Puppet Players
A fabric mod for fake 'puppet' players in Minecraft
About The Project
Modern, simple implementation of the fake players implemented originally in Carpet Mod.
There are some fundamental differences to how these fake players are implemented in comparison to the original implementation in Carpet Mod.
This mod can be used alongside Carpet Mod, carpet's fake player actions will work on these puppet players; however, it's recommended to use the provided actions instead.
The aim of this mod is to keep the behaviour of the puppet players as accurate as possible to a real player:
- All the player ticking is done in the correct tick phase.
- The client code for player actions is simulated on the server.
- Puppet players send packets to interact with the server, like a real player.
- Maintaining compatibility with all mods.
Usage
This documentation covers the latest version of the mod, for versions prior to 2.0.0
please see the old documentation
After installing the mod the /puppet command should become available to operators.
The /puppet command can also be made available to all players by changing the config,
see the config section for more details.
We can make a puppet player join the world using one of the following commands:
/puppet <username> join
/puppet <username> spawn
/puppet <username> spawn at <position> facing <rotation> in <dimension> in <gamemode>
/puppet <username> shadow
- The
join subcommand spawns the specified puppet at its previous log-off position, this essentially simulates
as if the player were joining the server themselves.
- The
spawn subcommand spawns the specified puppet at either a specified position or the position of the
command executor if the position is not specified.
- The
shadow subcommand makes a puppet player join in the place of a currently online player.
Once a player has joined the world, we can make the player leave by running the following command:
/puppet <player> leave
Puppeteering
Players can take over a puppet and play as it, leaving their own body behind in the world:
/puppet <player>
You can only specify puppets to puppeteer, or yourself if you are currently puppeteering
which puts you back in your original body. This feature is disabled by default and must be
enabled by setting enable_puppeteering, see the config section.
While puppeteering you will appear to other players as the puppet, and you resume the position
that the puppet was in with their inventory. Anything done to the puppet will persist after you
stop puppeting them. Stats and advancements however are still tied to your account. The same
is true for chat, messages are still sent through your account.
Your original body while puppeteering will become a puppet, so you can run /puppet on them
like you could with any other puppet, except for the leave command. Because on the server
you are still playing on your account when someone runs a command specifying your name it
will target the player you are puppeteering. For example, if the player senseiwells is
puppeteering SuperSanta and someone runs /tp senseiwells they will teleport to the player
SuperSanta. The exception to this is the /puppet command which will refer to whoever is going
by that name.
If you die while puppeteering or if the puppet disconnects then you will stop puppeteering. If
you log off while puppeteering then your original body will be logged off and the puppet will remain online.
Actions
Puppet players are able to run actions mimicking real player behaviour.
Certain actions can also be run on real players.
Here is a list of all available actions:
| Action |
Description |
Arguments |
Works stand-alone |
Puppet only |
"minecraft:attack" |
Makes the player attack (left click). |
<once|hold|release> |
Yes |
No |
"minecraft:delay" |
Adds a delay between chained actions. |
<delay> |
No |
No |
"minecraft:drop" |
Makes the player drop their selected item. |
<entire_stack> |
Yes |
No |
"minecraft:interrupt_look_at" |
Interrupts the current look at target. |
None |
Yes |
Yes |
"minecraft:interrupt_move_to" |
Interrupts the players current pathfinding. |
None |
Yes |
Yes |
"minecraft:jump" |
Makes the player jump. |
<once|hold|release> |
Yes |
Yes |
"minecraft:look" |
Makes the player look in a direction. |
<rotation> |
Yes |
No |
"minecraft:look_at" |
Makes the player look towards the specified target. |
position <pos> <lock?> or entity <entity> <lock?> |
Yes |
Yes |
"minecraft:move_to" |
Makes the player pathfind to a position or entity. |
position <pos> <sprint?> <jump?> or entity <entity> <sprint?> <jump?> |
Yes |
Yes |
"minecraft:offhand" |
Makes the player swap their item with their offhand. |
None |
Yes |
No |
"minecraft:sneak" |
Makes the player sneak. |
<sneaking> |
Yes |
Yes |
"minecraft:sprint" |
Makes the player sprint. |
<sprinting> |
Yes |
Yes |
"minecraft:swap_slot" |
Makes the player swap to a slot. |
<slot> |
Yes |
No |
"minecraft:use" |
Makes the player use (right click). |
<once|hold|release> |
Yes |
No |
To run an action, we can run it stand-alone with the following command:
/puppet <player> actions run <action> ...
This makes the player run the action immediately.
For example, to make a player hold attack, you would run:
/puppet <player> actions run minecraft:attack hold
We can also chain multiple actions together by running the following command:
/puppet <player> actions chain add <action> ...
Once you've added actions to the chain, we can also run the following commands to
control the chained behaviour:
/puppet <player> actions chain loop <true|false> # Whether to infinitely loop the chained actions
/puppet <player> actions chain pause # Pause execution of the chained actions
/puppet <player> actions chain resume # Resume execution of the chained actions
/puppet <player> actions chain restart # Restart execution of the chained actions (from the first action)
/puppet <player> actions chain stop # Stops execution of the chained actions (and clears all actions)
For example, to make a player hold attack for 5 seconds, then let go for 2 seconds, then repeat we would run:
/puppet <player> actions chain add minecraft:attack hold
/puppet <player> actions chain add minecraft:delay 5s
/puppet <player> actions chain add minecraft:attack release
/puppet <player> actions chain add minecraft:delay 2s
/puppet <player> actions chain loop true
Config
The config is located in ./config/puppet-player-config.json and by default should look like this:
{
"reload_puppet_players": true,
"respawn_puppet_players": true,
"puppet_player_death_delay": 0,
"operator_required_for_puppets": true,
"can_players_puppet_themselves": true,
"can_spawn_puppets_anywhere": true,
"can_spawn_whitelisted_players_as_puppets": true,
"enable_puppeteering": false,
"enabled_actions": "*"
}
"reload_puppet_players" - Whether puppets will rejoin if the server stopped with them last online
"respawn_puppet_players" - Whether to respawn puppets after they die, if disabled they will leave the game instead
"puppet_player_death_delay" - The delay after the puppet dies to either respawn/leave (determined by respawn_puppet_players)
"operator_required_for_puppets" - Whether players need operator permissions to run the /puppet command
"can_players_puppet_themselves" - Whether non-op players are able to run the /puppet command on themselves
"can_spawn_puppets_anywhere" - Whether you can run the /puppet <username> spawn <position?> to spawn puppets anywhere in the world (as opposed to join which spawns then where they last logged off)
"can_spawn_whitelisted_players_as_puppets" - Whether you can spawn whitelisted players as puppets
"enable_puppeteering" - Whether players are able to take over a puppet and play as it
"enabled_actions" - The list of enabled actions that you can make puppets do, "*" for all actions, or list the enabled actions, e.g. ["attack", "use"]
For a survival server, a less "cheaty" version of the mod can be used with the following recommended config:
{
"reload_puppet_players": true,
"respawn_puppet_players": false,
"puppet_player_death_delay": 20,
"operator_required_for_puppets": true,
"can_players_puppet_themselves": true,
"can_spawn_puppets_anywhere": false,
"can_spawn_whitelisted_players_as_puppets": false,
"enable_puppeteering": false,
"enabled_actions": ["use", "attack", "drop", "swap_slot"]
}
评论 0
登录后参与评分
还没有评论,来抢沙发吧