Sennen Fernando

make me a mode that let me someone bots like players and they will act like real players

Kodari AI
KodariNov 2 at 12:53 pm 8
FakePlayerSimulator
A Minecraft Fabric mod that spawns simulated bot players who mimic real player behavior. Bots navigate terrain, break and place blocks, interact with entities, chat with random phrases, and respond to environmental stimuli. Includes configurable bot count, spawn locations, and behavior profiles. Bots use pathfinding to explore, avoid hazards, and perform basic survival tasks like mining and crafting. Commands allow spawning, despawning, and managing bot groups. Designed for server testing, creating lively worlds, or populating multiplayer-like experiences.
  1. Add a summonable, player-shaped bot with basic follow, wandering, and combat behavior.

  2. Register its command, client rendering, and survival acquisition through a spawn egg.

Added the Fabric 1.21.11 mod. Run /bot spawn to summon a player-shaped bot; it follows the nearest player, wanders, watches players, and attacks hostile mobs. It has its own skin and player-style hurt/death sounds.

Sennen Fernando

by using command you can type how much bots you want to spawn and they should react like real players and they should have real usernames that being generated by the mod

Kodari AI
KodariNov 2 at 12:56 pm 1

Plan:

  1. Update /bot spawn <count> to create that many bots with unique generated usernames.

  2. Give each bot lightweight player-like reactions to nearby players and surroundings.

Added /bot spawn <count> (1–32; /bot spawn still creates one). Each bot gets a generated, visible username unique for the current server session. Near players, bots look at them and sometimes jump or sneak, alongside their existing follow, wander, and combat behaviors.

Sennen Fernando

all bots should be different

Kodari AI
KodariNov 2 at 1:03 pm 1

Each bot now gets a unique dyed leather armor color, so spawned bots look different as well as having unique usernames. Their armor renders on the player model.

Sennen Fernando

different textures different usernames

Kodari AI
KodariNov 2 at 1:11 pm 1

Each bot now gets a distinct generated skin texture: its clothing is tinted individually, and a unique pixel badge is added to the chest. Generated usernames remain unique and visible above the bots.

Sennen Fernando

and the mode should be server side

Kodari AI
KodariNov 2 at 1:27 pm 3
  1. Convert the bots to server-created fake players so they don’t need the mod’s client renderer or textures.

Converted the bots to server-side fake players: only the dedicated server needs the mod, and vanilla clients see them as players with generated usernames. They follow players, wander, and attack nearby hostile mobs.

To keep every bot’s look different without a client mod, each gets a different vanilla default skin. There are 18 available, so the server won’t create more than 18 uniquely skinned bots; custom-generated skin textures would require client-side support.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
8 353
src/main/java/dev/kodari/playerbots/PlayerBotsMod.java
package dev.kodari.playerbots;

import com.mojang.authlib.GameProfile;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.math.Vec3d;

public final class PlayerBotsMod implements ModInitializer {
    public static final String MOD_ID = "playerbots";
    private static final int DEFAULT_SKIN_VARIANTS = 18;
    private static final String[] NAME_PREFIXES = {"Swift", "Quiet", "Mossy", "Bright", "River", "Lucky", "Frost", "Copper", "Cloud", "Pixel", "Sunny", "Brave"};
    private static final String[] NAME_SUFFIXES = {"Fox", "Birch", "Otter", "Raven", "Maple", "Comet", "Finch", "Moth", "Cedar", "Panda", "Sparrow", "Wolf"};
    private static final Set<String> GENERATED_NAMES = new HashSet<>();
    private static final Set<Integer> GENERATED_SKIN_VARIANTS = new HashSet<>();
    private static final List<BotPlayerEntity> BOTS = new ArrayList<>();

    @Override
    public void onInitialize() {
        CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> registerCommands(dispatcher));
        ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
            for (BotPlayerEntity bot : BOTS) {
                handler.sendPacket(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, bot));
            }
        });
        ServerLifecycleEvents.SERVER_STOPPED.register(server -> {
            BOTS.clear();
            GENERATED_NAMES.clear();
            GENERATED_SKIN_VARIANTS.clear();
        });
    }

    private static void registerCommands(CommandDispatcher<ServerCommandSource> dispatcher) {
        dispatcher.register(CommandManager.literal("bot")
            .then(CommandManager.literal("spawn")
                .executes(context -> spawnBots(context.getSource(), 1))
                .then(CommandManager.argument("count", IntegerArgumentType.integer(1, 32))
                    .executes(context -> spawnBots(
                        context.getSource(),
                        IntegerArgumentType.getInteger(context, "count")
                    )))));
    }

    private static int spawnBots(ServerCommandSource source, int count) {
        MinecraftServer server = source.getServer();
        ServerWorld world = source.getWorld();
        Vec3d spawnPosition = source.getPosition();
        List<String> spawnedNames = new ArrayList<>();

        for (int i = 0; i < count; i++) {
            UUID profileId = generateUniqueSkinUuid();
            if (profileId == null) {
                break;
            }

            String username = generateUsername();
            BotPlayerEntity bot = new BotPlayerEntity(server, world, new GameProfile(profileId, username));
            double spawnAngle = ThreadLocalRandom.current().nextDouble(Math.PI * 2.0);
            bot.setPosition(
                spawnPosition.x + Math.cos(spawnAngle) * 1.5,
                spawnPosition.y,
                spawnPosition.z + Math.sin(spawnAngle) * 1.5
            );
            bot.setYaw((float) ThreadLocalRandom.current().nextDouble(360.0));

            server.getPlayerManager().sendToAll(
                new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, bot)
            );
            world.onPlayerConnected(bot);
            bot.onSpawn();

            GENERATED_NAMES.add(username);
            BOTS.add(bot);
            spawnedNames.add(username);
        }

        if (spawnedNames.isEmpty()) {
            source.sendFeedback(() -> Text.literal("All 18 different vanilla player skins are already in use."), false);
            return 0;
        }

        String result = "Spawned " + spawnedNames.size() + " player bot(s): " + String.join(", ", spawnedNames);
        if (spawnedNames.size() < count) {
            result += ". Vanilla clients provide 18 distinct default player skins, so no more uniquely skinned bots can be added.";
        }
        String feedback = result;
        source.sendFeedback(() -> Text.literal(feedback), false);
        return spawnedNames.size();
    }

    private static UUID generateUniqueSkinUuid() {
        if (GENERATED_SKIN_VARIANTS.size() >= DEFAULT_SKIN_VARIANTS) {
            return null;
        }

        while (true) {
            UUID uuid = UUID.randomUUID();
            int skinVariant = Math.floorMod(uuid.hashCode(), DEFAULT_SKIN_VARIANTS);
            if (GENERATED_SKIN_VARIANTS.add(skinVariant)) {
                return uuid;
            }
        }
    }

    private static String generateUsername() {
        ThreadLocalRandom random = ThreadLocalRandom.current();
        String username;
        do {
            username = NAME_PREFIXES[random.nextInt(NAME_PREFIXES.length)]
                + NAME_SUFFIXES[random.nextInt(NAME_SUFFIXES.length)]
                + random.nextInt(100, 1000);
        } while (GENERATED_NAMES.contains(username));
        return username;
    }
}