Fabric 1.21.11 mod. Depends only on Fabric API.
Do not depend on Carpet or HeroBot.
Add a custom item "Bot Spawn Egg" (with a simple egg texture), available in the Creative inventory (Spawn Eggs or Tools tab).
Right-clicking a block with it creates one server-side fake player (a real ServerPlayer with a dummy network connection, like Carpet's fake player) next to the clicked block.
Bot names are automatic and unique: Bot1, Bot2, Bot3, and so on.
The egg is consumed in survival mode but not in creative mode.
Sneaking and right-clicking an existing bot removes it, but only if the player who clicked is in creative mode.
In survival mode this does nothing.
Also add one command /pvpbot killall that removes all bots.
On spawn each bot gets: a netherite sword in the main hand, full netherite armor, 64 golden apples in the inventory, and 3 totems of undying (one in the offhand, two in the inventory).
When the offhand totem is used up, the bot immediately moves another totem from its inventory to its offhand.
Every server tick, each bot acts independently:
- Finds the nearest real player (never another bot) within 32 blocks.
- Looks at their eyes and runs toward them while sprinting and
jumping repeatedly (bunny hop), like a real player.
- When within 3 blocks, it jumps and attacks on the way down
to get a critical hit, only if the attack cooldown is full.
It stops sprinting just before the hit so the critical hit works.
- If its health is 8 or lower (4 hearts) and it has golden
apples, it stops attacking, switches to a golden apple, and eats it (about 1.6 seconds). It keeps eating one apple after another, with no waiting between them, until its health is 10 or higher (5 hearts). Then it goes back to fighting.
- If no real player is nearby, it stands still.
Bots must never attack each other.
Maximum 10 bots at the same time.
I couldn’t complete this reliably: the fake player needs a working server connection and lifecycle, and the available API findings don’t establish a safe implementation. No files were created.
No files in this session