Use cases

PvP

Have your Minecraft bots guard you or your base: when a player you haven't listed comes close, each bot turns to the nearest one and fights.

PvP with bots is an army of your accounts standing guard, at your base, at a door or around you, ready for any player you haven't listed who comes close. Each bot turns to the nearest player who isn't one of your accounts, hits them with its sword for as long as you set, and then lets go. For mobs rather than players, see Mob grinding.

What you need

  • Tier 3. The Player appears event, the held click and the loops all need it.
  • Java or Bedrock accounts.
  • Physics on. The held click runs on the bot's physics, so with physics off it does nothing. See What are bot physics?
  • Each bot where it should stand guard. The bots turn but never walk, and a hit reaches 3 blocks, a survival player's reach, so put them where an intruder has to pass close, such as a doorway.
  • A sword in one of the nine hotbar slots, armour on, and food in the inventory for auto eat.
  • A server that allows PvP where they stand.

Build the macro

  1. Visit minecraftafk.com/dashboard/servers/, open the server profile, and open its Macros page.
  2. Click Create macro, click the event card, and pick Player appears under Runs when.
  3. Leave Players empty, for anyone, and set Only within (blocks) to 4. Put your friends under Never fire for these players, and leave Ignore my own accounts ticked so your bots don't set each other off. Untick Smart trigger: while it's ticked, the event doesn't fire with 5 or more other players in sight, so a group that big coming at once would not set it off.
  4. Click Add step and pick Hold item. Under Item source pick Specific item, then the sword under Item name.
  5. Add Hold left click and untick Break blocks, so the bot hits and never digs. Under Step name you can call it Fight.
  6. Add Repeat, leave it on A set number of times, and set How many times to 60, about a minute of fighting once the waits below are set.
  7. With the plus button inside the Repeat, add For each and pick Entity nearby. Under Match pick Any player, set Within (blocks) to 4, and leave Skip my own accounts ticked. Switch on Stop after at most and leave it at 1, so it only ever picks the nearest player.
  8. Inside the For each, add Look at variable. It comes filled in with target, the For each's variable. Set its Wait before this step to 0, and the For each's Delay between loops to 0 too, so each lap takes about a second, the Repeat's own delay.
  9. After the End repeat, add Release left click, then click Create macro at the top right.

A player who comes within 4 blocks starts it. The held button hits whoever is under the crosshair, and every lap turns the bot back onto the nearest player, so it keeps up as they move. Every bot the macro runs on does this for itself, so each one fights whoever comes close to it.

Keep it safe

  • Release when the macro stops is ticked on Hold left click to begin with, so anything that stops the macro lets go of the button, even in the middle of a fight.
  • Add a Death stop condition, with Add stop condition on the dashed frame round the flow. A bot that dies comes back still holding the button, with the loop turning it to whoever is nearest where it respawned. The stop condition stands it down instead.
  • To leave before it dies, add an If inside the Repeat, ahead of the For each, and pick Health is low under Checks whether. Below starts at 10, half the bar. Put a Panic logout on its Yes branch: it stops the macro on that account and keeps the account off until you press Reconnect on the Macros page.
  • Add Enable auto eat to the macro too, so the bot eats from the food it carries when it gets hungry.

Good to know

  • On Java 1.9 and newer, a bot waits for its sword to recharge before each hit, the way a player landing full-strength hits does, so it hits about every 0.6 seconds. On older versions, which have no recharge, and on Bedrock accounts, it hits about once a second.
  • Skip my own accounts leaves out every account on your Accounts page, not your friends, and not an account of yours you haven't added. Any of them within 4 blocks during a fight can be the nearest player, and gets hit.
  • The held button hits whatever is under the crosshair, so one of your bots that steps into the way takes the hit.
  • The macro aims with a For each rather than Look at entity because Look at entity can't skip your own accounts. In a group, the nearest player is usually one of your bots.
  • The button pauses while a chest or menu is open on the bot, and while it eats.

For each and Holding a button in the macros guide, and Stop conditions, are worth reading next.