Kay Nad

Make a mob called daniella she will spawn randomly around the map and attacks the player

Kodari AI
KodariSep 25 at 6:40 pm 1
DaniellaMobBoss
A Minecraft plugin that introduces a formidable mob named Daniella, who spawns randomly across the map and aggressively targets players. Daniella possesses unique AI behavior, including tracking, chasing, and attacking nearby players with custom damage and abilities. The plugin includes configurable spawn rates, spawn radius, health, damage values, and attack cooldowns. It also features custom death messages, loot drops, and visual effects like particle bursts and sound cues when Daniella appears or attacks. The plugin ensures balanced gameplay by limiting spawn frequency and providing admin commands to manually spawn or remove Daniella, along with toggleable features for server customization.
  1. Create a Paper plugin scaffold and spawn settings.

  2. Add a scheduled spawner that places persistent husks named Daniella near players.

  3. Set Daniella’s target to a nearby player so she attacks.

Created the Daniella plugin. It periodically spawns persistent husks named Daniella at safe random spots near online players, and sets the selected player as her target. Spawn interval, distance, and per-world limit are configurable in config.yml.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
4 118
src/main/java/com/kodari/daniella/DaniellaPlugin.java
package com.kodari.daniella;

import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Husk;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public final class DaniellaPlugin extends JavaPlugin {
    private static final String DANIella_TAG = "kodari_daniella";

    @Override
    public void onEnable() {
        saveDefaultConfig();
        long intervalTicks = Math.max(1L, getConfig().getLong("spawn-interval-seconds", 45L)) * 20L;
        Bukkit.getScheduler().runTaskTimer(this, this::trySpawnDaniella, intervalTicks, intervalTicks);
    }

    private void trySpawnDaniella() {
        Player[] players = Bukkit.getOnlinePlayers().toArray(new Player[0]);
        if (players.length == 0) {
            return;
        }

        Player target = players[ThreadLocalRandom.current().nextInt(players.length)];
        World world = target.getWorld();
        int maxPerWorld = getConfig().getInt("max-per-world", 3);
        if (maxPerWorld <= 0 || countDaniellas(world) >= maxPerWorld) {
            return;
        }

        int minimumDistance = Math.max(1, getConfig().getInt("minimum-distance", 24));
        int maximumDistance = Math.max(minimumDistance, getConfig().getInt("maximum-distance", 64));
        int attempts = Math.max(1, getConfig().getInt("spawn-attempts", 12));
        ThreadLocalRandom random = ThreadLocalRandom.current();

        for (int attempt = 0; attempt < attempts; attempt++) {
            double angle = random.nextDouble(0.0, Math.PI * 2.0);
            double distance = random.nextDouble(minimumDistance, (double) maximumDistance + 1.0);
            int x = (int) Math.floor(target.getLocation().getX() + Math.cos(angle) * distance);
            int z = (int) Math.floor(target.getLocation().getZ() + Math.sin(angle) * distance);
            int y = world.getHighestBlockYAt(x, z);
            Location spawnLocation = new Location(world, x + 0.5, y + 1.0, z + 0.5);

            if (!world.getWorldBorder().isInside(spawnLocation) || !isSafeSpawnLocation(world, x, y, z)) {
                continue;
            }

            Husk daniella = (Husk) world.spawnEntity(spawnLocation, EntityType.HUSK);
            daniella.setCustomName("Daniella");
            daniella.setCustomNameVisible(true);
            daniella.setPersistent(true);
            daniella.setCanPickupItems(false);
            daniella.addScoreboardTag(DANIella_TAG);
            ((Monster) daniella).setTarget(target);
            return;
        }
    }

    private boolean isSafeSpawnLocation(World world, int x, int y, int z) {
        Block ground = world.getBlockAt(x, y, z);
        Block feet = world.getBlockAt(x, y + 1, z);
        Block head = world.getBlockAt(x, y + 2, z);
        return ground.getType().isSolid() && !ground.isLiquid() && feet.isPassable() && head.isPassable();
    }

    private long countDaniellas(World world) {
        return world.getEntities().stream()
                .filter(entity -> entity.getType() == EntityType.HUSK)
                .filter(Entity::isPersistent)
                .filter(entity -> entity.getScoreboardTags().contains(DANIella_TAG))
                .count();
    }
}