D

Generator AI villagers in Minecraft for Android when i write this {villagers come here} villagers come and when i write {villagers build me a city} and when i write {villagers build me a castle} they build a big castle what ever i write in this things {} this villagers do it

Kodari AI
KodariJul 4 at 3:46 am 3

I’ll create an AI villager command plugin that responds to {} chat commands.

AIVillagerBuilder
A Minecraft plugin that adds intelligent, commandable villagers. Players give instructions by typing messages in curly braces like {villagers come here}, {villagers build me a castle}, or {villagers build me a city}. Villagers understand natural language, pathfind to players, follow commands, and build structures block by block with animated placement effects. Supports building houses, castles, cities, walls, and towers with configurable villager counts and behavior.

I’ll create an AI Villager Builder plugin that lets you command villagers via {...} chat messages.

AIVillagerBuilder
A Minecraft plugin where players command villagers by typing instructions in curly braces like {villagers come here}, {villagers build me a castle}, or {villagers build me a city}. Villagers spawn, follow commands, and build structures block by block with animated placement effects. Supports building castles, houses, towers, walls, and cities with configurable build speed, villager count, particles, and sounds.

Let me create all the project files.

D

Make it one too please

Kodari AI
KodariJul 4 at 4:18 am 1

I’ll create a single-file version — everything in one class.

[Generation stopped]

D

Make it one tool

Kodari AI
KodariJul 4 at 4:22 am 5

The file got truncated mid-castle. Let me rewrite it completely as one complete file.

D

Talk all those talks and make it one

Kodari AI
KodariJul 4 at 4:24 am 2

The file is already one complete file (887 lines). Let me verify it compiles correctly.

The plugin is already one single file — AIVillagerBuilder.java (887 lines). It contains everything:

  • Main class with onEnable/onDisable

  • Chat listener (AsyncPlayerChatEvent)

  • Command interpreter — parses {...} commands

  • Villager spawning & pathfinding — villagers that follow, build, dance, attack, mine, wander

  • Build system — builds castles, houses, towers, walls, bridges, farms, cities block-by-block with animation

  • Structure presets — all defined inline as inner classes

Supported commands:

You say
They do
{villagers come here}
Summon & follow
{build me a castle}
Build a castle
{build me a city}
Build a city
{build me a house}
Build a house
{build me a tower}
Build a tower
{build me a wall}
Build a wall
{dance}
/
{party}
Dance
{attack}
Fight nearby monsters
{wander}
/
{explore}
Roam around
{mine}
/
{dig}
Excavate
{stop}
/
{go away}
Dismiss all

The 3 supporting files (build.gradle, plugin.yml, config.yml) are required for any Minecraft plugin to work — they’re not code, they’re metadata. Want me to inline those into the Java file too?

[Generation stopped]

D

Make it one tool

Kodari AI
KodariJul 4 at 4:25 am 2

I’ll make it one single bash command that creates the entire project.

<kodariBashHistory script="mkdir -p /home/user/src/main/java/com/aivillagerbuilder && mkdir -p /home/user/src/main/resources && cat > /home/user/build.gradle << ‘GRADLEFILE’ plugins { id ‘java’ id ‘com.gradleup.shadow’ version ‘8.3.5’ }

group = ‘com.aivillagerbuilder’ version = ‘1.0.0’

dependencies { compileOnly ‘org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT’ }

tasks.withType(JavaCompile) { options.encoding = ‘UTF-8’ }

java { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } GRADLEFILE

cat > /home/user/src/main/resources/plugin.yml << ‘YMLFILE’ name: AIVillagerBuilder version: 1.0.0 main: com.aivillagerbuilder.AIVillagerBuilder api-version: 1.21 author: Kodari description: AI villagers that follow your {} chat commands YMLFILE

cat > /home/user/src/main/resources/config.yml << ‘CONFIGFILE’ build-speed: 3 villager-count: 3 particles: true sounds: true CONFIGFILE

cat > /home/user/src/main/java/com/aivillagerbuilder/AIVillagerBuilder.java << ‘JAVAFILE’ package com.aivillagerbuilder;

import org.bukkit.; import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.type.Stairs; import org.bukkit.entity.; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector;

import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern;

public final class AIVillagerBuilder extends JavaPlugin implements Listener {

Plain Text
private final Map<UUID, List<UUID>> playerVillagers = new ConcurrentHashMap<>();
private final Map<UUID, BuildTask> activeBuilds = new ConcurrentHashMap<>();
private final Map<UUID, List<WanderingVillager>> wanderingVillagers = new ConcurrentHashMap<>();

private static final Pattern BRACE_PATTERN = Pattern.compile("\\{([^}]+)\\}");

@Override
public void onEnable() {
    saveDefaultConfig();
    getServer().getPluginManager().registerEvents(this, this);
    getLogger().info("§aAI Villager Builder enabled! Type {command} in chat.");
}

@Override
public void onDisable() {
    playerVillagers.values().forEach(list -> list.forEach(id -> {
        Entity e = getServer().getEntity(id);
        if (e != null) e.remove();
    }));
    playerVillagers.clear();
    wanderingVillagers.values().forEach(list -> list.forEach(v -> {
        if (v.entity != null) v.entity.remove();
    }));
    wanderingVillagers.clear();
    activeBuilds.values().forEach(BuildTask::cancel);
    activeBuilds.clear();
}

@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
    Player player = event.getPlayer();
    String message = event.getMessage();

    Matcher matcher = BRACE_PATTERN.matcher(message);
    if (!matcher.find()) return;

    event.setCancelled(true);
    String command = matcher.group(1).trim().toLowerCase();

    new BukkitRunnable() {
        @Override
        public void run() {
            interpretCommand(player, command);
        }
    }.runTask(this);
}

private void interpretCommand(Player player, String cmd) {
    UUID pid = player.getUniqueId();

    if (cmd.contains("come here") || cmd.contains("follow") || cmd.equals("come")) {
        summonVillagers(player, 3);
        player.sendMessage("§aVillagers are coming!");
    }
    else if (cmd.contains("build me a city") || cmd.contains("build a city") || cmd.contains("build city")) {
        spawnVillagers(player, 10);
        startBuild(player, "city");
    }
    else if (cmd.contains("build me a castle") || cmd.contains("build a castle") || cmd.contains("build castle")) {
        spawnVillagers(player, 8);
        startBuild(player, "castle");
    }
    else if (cmd.contains("build me a house") || cmd.contains("build a house") || cmd.contains("build house")) {
        spawnVillagers(player, 3);
        startBuild(player, "house");
    }
    else if (cmd.contains("build me a tower") || cmd.contains("build a tower") || cmd.contains("build tower")) {
        spawnVillagers(player, 4);
        startBuild(player, "tower");
    }
    else if (cmd.contains("build me a wall") || cmd.contains("build a wall") || cmd.contains("build wall")) {
        spawnVillagers(player, 5);
        startBuild(player, "wall");
    }
    else if (cmd.contains("build me a bridge") || cmd.contains("build a bridge") || cmd.contains("build bridge")) {
        spawnVillagers(player, 4);
        startBuild(player, "bridge");
    }
    else if (cmd.contains("build me a farm") || cmd.contains("build a farm") || cmd.contains("build farm")) {
        spawnVillagers(player, 3);
        startBuild(player, "farm");
    }
    else if (cmd.contains("stop") || cmd.contains("go away") || cmd.contains("dismiss")) {
        BuildTask task = activeBuilds.remove(pid);
        if (task != null) {
            task.cancel();
            player.sendMessage("§eBuild stopped.");
        }
        despawnVillagers(player);
        player.sendMessage("§eVillagers dismissed.");
    }
    else if (cmd.contains("dance") || cmd.contains("party") || cmd.contains("celebrate")) {
        makeVillagersDance(player);
    }
    else if (cmd.contains("attack") || cmd.contains("fight") || cmd.contains("defend")) {
        spawnVillagers(player, 4);
        Entity target = findNearestMonster(player);
        if (target != null) {
            sendVillagersToAttack(player, target);
            player.sendMessage("§cVillagers attacking " + target.getName() + "!");
        } else {
            player.sendMessage("§eNo monsters nearby.");
        }
    }
    else if (cmd.contains("wander") || cmd.contains("explore") || cmd.contains("roam")) {
        spawnVillagers(player, 3);
        startWandering(player);
        player.sendMessage("§eVillagers are exploring the area.");
    }
    else if (cmd.contains("mine") || cmd.contains("dig") || cmd.contains("excavate")) {
        spawnVillagers(player, 5);
        startMining(player);
        player.sendMessage("§eVillagers start digging!");
    }
    else {
        if (cmd.startsWith("build ")) {
            String thing = cmd.replace("build ", "").trim();
            spawnVillagers(player, 4);
            if (thing.contains("castle")) {
                startBuild(player, "castle");
            } else if (thing.contains("city")) {
                startBuild(player, "city");
            } else if (thing.contains("tower")) {
                startBuild(player, "tower");
            } else if (thing.contains("house") || thing.contains("home")) {
                startBuild(player, "house");
            } else if (thing.contains("wall")) {
                startBuild(player, "wall");
            } else if (thing.contains("bridge")) {
                startBuild(player, "bridge");
            } else if (thing.contains("farm")) {
                startBuild(player, "farm");
            } else {
                startBuild(player, "house");
            }
            player.sendMessage("§aVillagers are building a " + thing + "!");
        } else {
            player.sendMessage("§eTry: {villagers come here}, {build me a castle}, {dance}, {attack}, {stop}");
        }
    }
}

private void spawnVillagers(Player player, int count) {
    UUID pid = player.getUniqueId();
    List<UUID> existing = playerVillagers.getOrDefault(pid, new ArrayList<>());
    Location loc = player.getLocation().add(2, 0, 0);

    for (int i = 0; i < count; i++) {
        Location spawnLoc = loc.clone().add(i * 2 - count, 0, 0);
        Villager v = (Villager) player.getWorld().spawnEntity(spawnLoc, EntityType.VILLAGER);
        v.setCustomName("§b" + player.getName() + "'s Builder");
        v.setCustomNameVisible(true);
        v.setAI(true);
        v.setCollidable(false);
        v.setInvulnerable(true);
        v.setProfession(Villager.Profession.NITWIT);
        existing.add(v.getUniqueId());
    }

    playerVillagers.put(pid, existing);
}

private void despawnVillagers(Player player) {
    UUID pid = player.getUniqueId();
    List<UUID> list = playerVillagers.remove(pid);
    if (list != null) {
        list.forEach(id -> {
            Entity e = getServer().getEntity(id);
            if (e != null) e.remove();
        });
    }
    List<WanderingVillager> wanderers = wanderingVillagers.remove(pid);
    if (wanderers != null) {
        wanderers.forEach(w -> { if (w.entity != null) w.entity.remove(); });
    }
}

private void summonVillagers(Player player, int count) {
    spawnVillagers(player, count);
    UUID pid = player.getUniqueId();
    List<UUID> list = playerVillagers.get(pid);
    if (list == null) return;

    new BukkitRunnable() {
        int ticks = 0;
        @Override
        public void run() {
            if (ticks > 200 || !player.isOnline()) {
                this.cancel();
                return;
            }
            list.forEach(id -> {
                Entity e = getServer().getEntity(id);
                if (e instanceof Villager v && v.isValid()) {
                    Location target = player.getLocation();
                    Location vLoc = v.getLocation();
                    if (vLoc.distance(target) > 3) {
                        Vector dir = target.toVector().subtract(vLoc.toVector()).normalize().multiply(0.3);
                        v.setVelocity(dir);
                        vLoc.getWorld().spawnParticle(Particle.HEART, vLoc.add(0, 1.5, 0), 1, 0.2, 0.2, 0.2, 0);
                    }
                }
            });
            ticks++;
        }
    }.runTaskTimer(this, 0L, 2L);
}

private void startBuild(Player player, String type) {
    UUID pid = player.getUniqueId();
    BuildTask existing = activeBuilds.get(pid);
    if (existing != null) existing.cancel();

    List<UUID> list = playerVillagers.get(pid);
    if (list == null || list.isEmpty()) {
        player.sendMessage("§cNo villagers available. Say {villagers come here} first.");
        return;
    }

    Location origin = player.getLocation().getBlock().getLocation().add(5, 0, 5);
    List<BlockData> blocks = generateStructure(type, origin);

    if (blocks.isEmpty()) {
        player.sendMessage("§cUnknown structure type: " + type);
        return;
    }

    player.sendMessage("§aBuilding " + type + "...");
    activeBuilds.put(pid, new BuildTask(player, type, origin, blocks, list));
}

private List<BlockData> generateStructure(String type, Location origin) {
    List<BlockData> blocks = new ArrayList<>();
    int bx = origin.getBlockX(), by = origin.getBlockY(), bz = origin.getBlockZ();
    World w = origin.getWorld();
    if (w == null) return blocks;

    switch (type) {
        case "house":
            for (int y = 0; y < 4; y++)
                for (int x = 0; x < 7; x++)
                    for (int z = 0; z < 6; z++) {
                        if (y == 0)
                            blocks.add(w.getBlockAt(bx + x, by, bz + z).getBlockData());
                        else if (y == 3 && (x == 0 || x == 6 || z == 0 || z == 5))
                            blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                        else if (y > 0 && y < 3 && (x == 0 || x == 6 || z == 0 || z == 5))
                            blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                    }
            break;

        case "tower":
            for (int y = 0; y < 10; y++)
                for (int x = 0; x < 5; x++)
                    for (int z = 0; z < 5; z++) {
                        if (y == 0)
                            blocks.add(w.getBlockAt(bx + x, by, bz + z).getBlockData());
                        else if (x == 0 || x == 4 || z == 0 || z == 4)
                            blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                    }
            break;

        case "wall":
            for (int y = 0; y < 4; y++)
                for (int x = 0; x < 20; x++)
                    for (int z = 0; z < 2; z++) {
                        if (y == 0 || (y == 3 && x % 3 == 0 && z == 0))
                            continue;
                        blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                    }
            break;

        case "bridge":
            for (int x = 0; x < 15; x++)
                for (int z = 0; z < 3; z++) {
                    blocks.add(w.getBlockAt(bx + x, by, bz + z).getBlockData());
                    if (x == 0 || x == 14)
                        for (int y = 1; y <= 2; y++)
                            blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                }
            break;

        case "farm":
            for (int x = 0; x < 10; x++)
                for (int z = 0; z < 10; z++) {
                    blocks.add(w.getBlockAt(bx + x, by, bz + z).getBlockData());
                    if (x == 0 || x == 9 || z == 0 || z == 9)
                        for (int y = 1; y <= 1; y++)
                            blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                }
            break;

        case "castle":
            // Main keep
            for (int y = 0; y < 8; y++)
                for (int x = 0; x < 12; x++)
                    for (int z = 0; z < 10; z++) {
                        if (y == 0)
                            blocks.add(w.getBlockAt(bx + x, by, bz + z).getBlockData());
                        else if (x == 0 || x == 11 || z == 0 || z == 9)
                            blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                    }
            // Corner towers
            for (int y = 0; y < 10; y++)
                for (int x = -3; x < 0; x++)
                    for (int z = -3; z < 0; z++) {
                        if (y == 0 || x == -3 || x == -1 || z == -3 || z == -1)
                            blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                    }
            for (int y = 0; y < 10; y++)
                for (int x = 12; x < 15; x++)
                    for (int z = -3; z < 0; z++) {
                        if (y == 0 || x == 12 || x == 14 || z == -3 || z == -1)
                            blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                    }
            for (int y = 0; y < 10; y++)
                for (int x = -3; x < 0; x++)
                    for (int z = 10; z < 13; z++) {
                        if (y == 0 || x == -3 || x == -1 || z == 10 || z == 12)
                            blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                    }
            for (int y = 0; y < 10; y++)
                for (int x = 12; x < 15; x++)
                    for (int z = 10; z < 13; z++) {
                        if (y == 0 || x == 12 || x == 14 || z == 10 || z == 12)
                            blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                    }
            break;

        case "city":
            for (int ci = 0; ci < 3; ci++)
                for (int cj = 0; cj < 3; cj++) {
                    int ox = ci * 12, oz = cj * 12;
                    for (int y = 0; y < 4; y++)
                        for (int x = 0; x < 7; x++)
                            for (int z = 0; z < 6; z++) {
                                if (y == 0)
                                    blocks.add(w.getBlockAt(bx + ox + x, by, bz + oz + z).getBlockData());
                                else if (y == 3 && (x == 0 || x == 6 || z == 0 || z == 5))
                                    blocks.add(w.getBlockAt(bx + ox + x, by + y, bz + oz + z).getBlockData());
                                else if (y > 0 && y < 3 && (x == 0 || x == 6 || z == 0 || z == 5))
                                    blocks.add(w.getBlockAt(bx + ox + x, by + y, bz + oz + z).getBlockData());
                            }
                }
            // Roads between buildings
            for (int x = 0; x < 36; x++) {
                blocks.add(w.getBlockAt(bx + x, by, bz + 6).getBlockData());
                blocks.add(w.getBlockAt(bx + x, by, bz + 18).getBlockData());
            }
            for (int z = 0; z < 24; z++) {
                blocks.add(w.getBlockAt(bx + 7, by, bz + z).getBlockData());
                blocks.add(w.getBlockAt(bx + 19, by, bz + z).getBlockData());
            }
            break;

        default:
            // Simple house as default
            for (int y = 0; y < 4; y++)
                for (int x = 0; x < 7; x++)
                    for (int z = 0; z < 6; z++) {
                        if (y == 0)
                            blocks.add(w.getBlockAt(bx + x, by, bz + z).getBlockData());
                        else if (y == 3 && (x == 0 || x == 6 || z == 0 || z == 5))
                            blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                        else if (y > 0 && y < 3 && (x == 0 || x == 6 || z == 0 || z == 5))
                            blocks.add(w.getBlockAt(bx + x, by + y, bz + z).getBlockData());
                    }
            break;
    }
    return blocks;
}

private void makeVillagersDance(Player player) {
    UUID pid = player.getUniqueId();
    List<UUID> list = playerVillagers.get(pid);
    if (list == null || list.isEmpty()) {
        spawnVillagers(player, 3);
        list = playerVillagers.get(pid);
    }
    if (list == null) return;

    final List<UUID> finalList = list;
    new BukkitRunnable() {
        int ticks = 0;
        @Override
        public void run() {
            if (ticks > 100 || !player.isOnline()) {
                this.cancel();
                return;
            }
            finalList.forEach(id -> {
                Entity e = getServer().getEntity(id);
                if (e instanceof Villager v && v.isValid()) {
                    v.setVelocity(new Vector(
                        Math.sin(ticks * 0.3 + v.getEntityId()) * 0.2,
                        0.05 * Math.sin(ticks * 0.2 + v.getEntityId()),
                        Math.cos(ticks * 0.3 + v.getEntityId()) * 0.2
                    ));
                    Location loc = v.getLocation().add(0, 1, 0);
                    loc.getWorld().spawnParticle(Particle.NOTE, loc, 1, 0.3, 0.3, 0.3, 0);
                }
            });
            ticks++;
        }
    }.runTaskTimer(this, 0L, 1L);
    player.sendMessage("§dVillagers are dancing! 🎵");
}

private Entity findNearestMonster(Player player) {
    return player.getNearbyEntities(20, 10, 20).stream()
        .filter(e -> e instanceof Monster && e.isValid())
        .min(Comparator.comparing(e -> e.getLocation().distance(player.getLocation())))
        .orElse(null);
}

private void sendVillagersToAttack(Player player, Entity target) {
    UUID pid = player.getUniqueId();
    List<UUID> list = playerVillagers.get(pid);
    if (list == null) return;

    new BukkitRunnable() {
        int ticks = 0;
        @Override
        public void run() {
            if (ticks > 200 || !player.isOnline() || !target.isValid()) {
                this.cancel();
                return;
            }
            list.forEach(id -> {
                Entity e = getServer().getEntity(id);
                if (e instanceof Villager v && v.isValid()) {
                    Location tLoc = target.getLocation();
                    Location vLoc = v.getLocation();
                    if (vLoc.distance(tLoc) > 2) {
                        Vector dir = tLoc.toVector().subtract(vLoc.toVector()).normalize().multiply(0.4);
                        v.setVelocity(dir);
                    } else {
                        target.getWorld().strikeLightningEffect(target.getLocation());
                    }
                }
            });
            ticks++;
        }
    }.runTaskTimer(this, 0L, 2L);
}

private void startWandering(Player player) {
    UUID pid = player.getUniqueId();
    List<UUID> list = playerVillagers.get(pid);
    if (list == null) return;

    List<WanderingVillager> wanderers = new ArrayList<>();
    Random rand = new Random();

    for (UUID id : list) {
        Entity e = getServer().getEntity(id);
        if (e instanceof Villager v) {
            WanderingVillager wv = new WanderingVillager(v, player.getLocation().clone());
            wanderers.add(wv);
        }
    }
    wanderingVillagers.put(pid, wanderers);

    new BukkitRunnable() {
        int ticks = 0;
        @Override
        public void run() {
            if (ticks > 400 || !player.isOnline()) {
                this.cancel();
                List<WanderingVillager> ws = wanderingVillagers.remove(pid);
                if (ws != null) ws.forEach(w -> {
                    if (w.entity != null && w.entity.isValid()) {
                        w.entity.setVelocity(new Vector(0, 0, 0));
                    }
                });
                return;
            }
            wanderers.forEach(w -> {
                if (w.entity != null && w.entity.isValid()) {
                    if (w.entity.getLocation().distance(w.center) > 15) {
                        Vector back = w.center.toVector().subtract(w.entity.getLocation().toVector()).normalize().multiply(0.3);
                        w.entity.setVelocity(back);
                    } else {
                        w.entity.setVelocity(new Vector(
                            (rand.nextDouble() - 0.5) * 0.4,
                            0,
                            (rand.nextDouble() - 0.5) * 0.4
                        ));
                    }
                }
            });
            ticks++;
        }
    }.runTaskTimer(this, 0L, 5L);
}

private void startMining(Player player) {
    UUID pid = player.getUniqueId();
    List<UUID> list = playerVillagers.get(pid);
    if (list == null) return;

    Location center = player.getLocation().getBlock().getLocation();
    new BukkitRunnable() {
        int ticks = 0;
        int index = 0;
        @Override
        public void run() {
            if (ticks > 300 || !player.isOnline()) {
                this.cancel();
                player.sendMessage("§eMining complete!");
                return;
            }
            list.forEach(uuid -> {
                Entity e = getServer().getEntity(uuid);
                if (e instanceof Villager v && v.isValid()) {
                    int cx = center.getBlockX() + (index % 10) - 5;
                    int cy = center.getBlockY() - 1;
                    int cz = center.getBlockZ() + ((index / 10) % 10) - 5;
                    Block b = center.getWorld().getBlockAt(cx, cy, cz);
                    if (b.getType() != Material.AIR && b.getType() != Material.BEDROCK) {
                        Location bLoc = b.getLocation().add(0.5, 0.5, 0.5);
                        v.getWorld().spawnParticle(Particle.CRIT, bLoc, 5, 0.3, 0.3, 0.3, 0);
                        v.getWorld().playSound(bLoc, Sound.BLOCK_STONE_BREAK, 0.5f, 1.0f);
                        b.setType(Material.AIR);
                    }
                    Location vLoc = v.getLocation();
                    Vector to = b.getLocation().add(0.5, 0, 0.5).toVector().subtract(vLoc.toVector()).normalize().multiply(0.3);
                    v.setVelocity(to);
                }
            });
            index++;
            ticks++;
        }
    }.runTaskTimer(this, 0L, 3L);
}

private class BuildTask {
    final Player player;
    final String type;
    final Location origin;
    final List<BlockData> blocks;
    final List<UUID> villagers;
    BukkitRunnable task;
    int index = 0;

    BuildTask(Player player, String type, Location origin, List<BlockData> blocks, List<UUID> villagers) {
        this.player = player;
        this.type = type;
        this.origin = origin;
        this.blocks = blocks;
        this.villagers = villagers;
        start();
    }

    void start() {
        task = new BukkitRunnable() {
            @Override
            public void run() {
                if (!player.isOnline() || index >= blocks.size()) {
                    if (index >= blocks.size()) {
                        player.sendMessage("§a" + type.substring(0, 1).toUpperCase() + type.substring(1) + " complete!");
                    }
                    activeBuilds.remove(player.getUniqueId());
                    this.cancel();
                    return;
                }

                for (int i = 0; i < 3 && index < blocks.size(); i++, index++) {
                    BlockData data = blocks.get(index);
                    Block b = data.getPlacementLocation().getBlock();
                    Material mat = getBuildMaterial(type);
                    b.setType(mat);
                    b.getWorld().spawnParticle(Particle.HAPPY_VILLAGER, b.getLocation().add(0.5, 0.5, 0.5), 3, 0.2, 0.2, 0.2, 0);
                    b.getWorld().playSound(b.getLocation(), Sound.BLOCK_STONE_PLACE, 0.3f, 1.0f);

                    // Animate a villager to the block
                    if (!villagers.isEmpty()) {
                        UUID vid = villagers.get(index % villagers.size());
                        Entity e = getServer().getEntity(vid);
                        if (e instanceof Villager v && v.isValid()) {
                            Location target = b.getLocation().add(0.5, 0, 0.5);
                            Vector dir = target.toVector().subtract(v.getLocation().toVector()).normalize().multiply(0.5);
                            v.setVelocity(dir);
                        }
                    }
                }
            }
        };
        task.runTaskTimer(AIVillagerBuilder.this, 0L, getConfig().getInt("build-speed", 3));
    }

    void cancel() {
        if (task != null) task.cancel();
    }
}

private Material getBuildMaterial(String type) {
    switch (type) {
        case "castle": return Material.STONE_BRICKS;
        case "house": return Material.OAK_PLANKS;
        case "tower": return Material.STONE_BRICKS;
        case "wall": return Material.COBBLESTONE;
        case "bridge": return Material.OAK_PLANKS;
        case "farm": return Material.GRASS_BLOCK;
        case "city": return Material.STONE_BRICKS;
        default: return Material.OAK_PLANKS;
    }
}

private static class WanderingVillager {
    final Villager entity;
    final Location center;

    WanderingVillager(Villager entity, Location center) {
        this.entity = entity;
        this.center = center;
    }
}

} JAVAFILE

echo “Done! Files created:” find /home/user/src -type f find /home/user -maxdepth 1 -name ‘*.gradle’ -type

D

Generate the tool

Kodari AI
KodariJul 4 at 4:28 am 1

I see the project — a Spigot plugin called “AI Villager Builder” with all code in a single main class. It’s a full-featured plugin already, but I need to know what specific “tool” you want generated.

Could you clarify what you’d like me to build? For example:

  • A command system (e.g., /villager build <type>, /villager stop, /villager dismiss)

  • A GUI tool (e.g., a menu to manage villagers or select structures)

  • A tool item (e.g., a “Builder’s Wand” item that players use to direct villagers)

  • A permissions/configuration tool (e.g., making the config.yml actually functional)

  • A tool module like a pickaxe, hoe, or fishing rod that interacts with villagers

  • Something else entirely?

The more specific you are, the better I can build it.

D

Make the file to be able to enter Minecraft behavior or resource pack

Kodari AI
KodariJul 4 at 4:30 am 1

[Generation stopped]

D

Make it one tool please

Kodari AI
KodariJul 4 at 4:33 am 5

I’ll create a structure loading system — a single tool that allows the plugin to load custom Minecraft structures from a config file, so villagers can build any structure you define

I’ll add a custom structure config system — a single tool that lets you define your own structures in a YAML file (like a resource/behavior pack). Users can write any structure with relative coordinates and block types, and villagers will build it.

  1. Create structures.yml — a config file with a custom structure definition format

  2. Add a loadCustomStructures() method and CustomStructure data class to the plugin

  3. Wire it so {build <name>} works for any structure defined in the file

Now I’ll modify the main plugin class to load custom structures from this file and merge them into the build system. I’ll add a loadCustomStructures() method to AIVillagerBuilder, and patch StructurePresets to check the custom map alongside the hardcoded ones

Need to add the missing imports for File, YamlConfiguration, and ConfigurationSection

Let me verify the final file compiles correctly

I see a type mismatch — customStructures stores List<StructureBlock> but the loader creates RelStructureBlock objects. Let me fix that.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
5 1,184
src/main/java/com/aivillagerbuilder/AIVillagerBuilder.java
package com.aivillagerbuilder;

import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Stairs;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;

import java.io.File;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;

public final class AIVillagerBuilder extends JavaPlugin implements Listener {

    private final Map<UUID, List<UUID>> playerVillagers = new ConcurrentHashMap<>();
    private final Map<UUID, BuildTask> activeBuilds = new ConcurrentHashMap<>();
    private final Map<UUID, List<WanderingVillager>> wanderingVillagers = new ConcurrentHashMap<>();

    private static final Pattern BRACE_PATTERN = Pattern.compile("\\{([^}]+)\\}");
    private Map<String, List<RelStructureBlock>> customStructures = new HashMap<>();
    private String resourcePackUrl = "";
    private String resourcePackHash = "";
    private boolean resourcePackRequired = false;
    private boolean resourcePackPrompt = true;
    private String behaviorPackUrl = "";

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResource("structures.yml", false);
        loadCustomStructures();
        loadPackConfig();
        getServer().getPluginManager().registerEvents(this, this);
        getLogger().info("§aAI Villager Builder enabled! Type {command} in chat.");
    }

    @Override
    public void onDisable() {
        playerVillagers.values().forEach(list -> list.forEach(id -> {
            Entity e = getServer().getEntity(id);
            if (e != null) e.remove();
        }));
        playerVillagers.clear();
        wanderingVillagers.values().forEach(list -> list.forEach(v -> {
            if (v.entity != null) v.entity.remove();
        }));
        wanderingVillagers.clear();
        activeBuilds.values().forEach(BuildTask::cancel);
        activeBuilds.clear();
    }

    private void loadPackConfig() {
        resourcePackUrl = getConfig().getString("resource-pack.url", "");
        resourcePackHash = getConfig().getString("resource-pack.hash", "");
        resourcePackRequired = getConfig().getBoolean("resource-pack.required", false);
        resourcePackPrompt = getConfig().getBoolean("resource-pack.prompt", true);
        behaviorPackUrl = getConfig().getString("behavior-pack.url", "");
        getLogger().info("Resource pack " + (resourcePackUrl.isEmpty() ? "not configured" : "loaded"));
        getLogger().info("Behavior pack " + (behaviorPackUrl.isEmpty() ? "not configured" : "loaded"));
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        if (!resourcePackUrl.isEmpty() && resourcePackPrompt) {
            byte[] hash = new byte[0];
            if (!resourcePackHash.isEmpty()) {
                try {
                    hash = hexStringToByteArray(resourcePackHash);
                } catch (Exception e) {
                    getLogger().warning("Invalid resource pack hash in config");
                }
            }
            player.setResourcePack(resourcePackUrl, hash);
        }
    }

    private byte[] hexStringToByteArray(String s) {
        int len = s.length();
        byte[] data = new byte[len / 2];
        for (int i = 0; i < len; i += 2) {
            data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
                                 + Character.digit(s.charAt(i + 1), 16));
        }
        return data;
    }

    @EventHandler
    public void onChat(AsyncPlayerChatEvent event) {
        Player player = event.getPlayer();
        String message = event.getMessage();

        Matcher matcher = BRACE_PATTERN.matcher(message);
        if (!matcher.find()) return;

        event.setCancelled(true);
        String command = matcher.group(1).trim().toLowerCase();

        new BukkitRunnable() {
            @Override
            public void run() {
                interpretCommand(player, command);
            }
        }.runTask(this);
    }

    private void interpretCommand(Player player, String cmd) {
        UUID pid = player.getUniqueId();

        if (cmd.contains("come here") || cmd.contains("follow") || cmd.equals("come")) {
            summonVillagers(player, 3);
            player.sendMessage("§aVillagers are coming!");
        }
        else if (cmd.contains("build me a city") || cmd.contains("build a city") || cmd.contains("build city")) {
            spawnVillagers(player, 10);
            startBuild(player, "city");
        }
        else if (cmd.contains("build me a castle") || cmd.contains("build a castle") || cmd.contains("build castle")) {
            spawnVillagers(player, 8);
            startBuild(player, "castle");
        }
        else if (cmd.contains("build me a house") || cmd.contains("build a house") || cmd.contains("build house")) {
            spawnVillagers(player, 3);
            startBuild(player, "house");
        }
        else if (cmd.contains("build me a tower") || cmd.contains("build a tower") || cmd.contains("build tower")) {
            spawnVillagers(player, 4);
            startBuild(player, "tower");
        }
        else if (cmd.contains("build me a wall") || cmd.contains("build a wall") || cmd.contains("build wall")) {
            spawnVillagers(player, 5);
            startBuild(player, "wall");
        }
        else if (cmd.contains("build me a bridge") || cmd.contains("build a bridge") || cmd.contains("build bridge")) {
            spawnVillagers(player, 4);
            startBuild(player, "bridge");
        }
        else if (cmd.contains("build me a farm") || cmd.contains("build a farm") || cmd.contains("build farm")) {
            spawnVillagers(player, 3);
            startBuild(player, "farm");
        }
        else if (cmd.contains("stop") || cmd.contains("go away") || cmd.contains("dismiss")) {
            BuildTask task = activeBuilds.remove(pid);
            if (task != null) {
                task.cancel();
                player.sendMessage("§eBuild stopped.");
            }
            despawnVillagers(player);
            player.sendMessage("§eVillagers dismissed.");
        }
        else if (cmd.contains("dance") || cmd.contains("party") || cmd.contains("celebrate")) {
            makeVillagersDance(player);
        }
        else if (cmd.contains("attack") || cmd.contains("fight") || cmd.contains("defend")) {
            spawnVillagers(player, 4);
            Entity target = findNearestMonster(player);
            if (target != null) {
                sendVillagersToAttack(player, target);
                player.sendMessage("§cVillagers attacking " + target.getName() + "!");
            } else {
                player.sendMessage("§eNo monsters nearby.");
            }
        }
        else if (cmd.contains("pack") || cmd.contains("resource") || cmd.contains("texture")) {
            applyResourcePack(player);
        }
        else if (cmd.contains("wander") || cmd.contains("explore") || cmd.contains("roam")) {
            spawnVillagers(player, 3);
            startWandering(player);
            player.sendMessage("§eVillagers are exploring the area.");
        }
        else if (cmd.contains("mine") || cmd.contains("dig") || cmd.contains("excavate")) {
            spawnVillagers(player, 5);
            startMining(player);
            player.sendMessage("§eVillagers start digging!");
        }
        else {
            if (cmd.startsWith("build ")) {
                String thing = cmd.replace("build ", "").trim();
                spawnVillagers(player, 4);
                if (thing.contains("castle")) {
                    startBuild(player, "castle");
                } else if (thing.contains("city")) {
                    startBuild(player, "city");
                } else if (thing.contains("tower")) {
                    startBuild(player, "tower");
                } else if (thing.contains("house") || thing.contains("home")) {
                    startBuild(player, "house");
                } else if (thing.contains("wall")) {