zflores10

make me a minecraft warden animation file for java

Kodari AI
KodariAug 26 at 11:55 pm 1
WardenAnimationSystem
Creates a Minecraft plugin that adds custom Warden animation sequences for Java Edition servers. The system provides configurable animation states including idle, walking, attacking, sonic boom charging, and emerging from ground. Includes a command interface for triggering animations on wardens, particle effects, sound effects, and smooth pose transitions using entity metadata manipulation. Supports per-animation duration settings, cooldown management, and permission-based access. Integrates with the server's animation tick system for synchronized playback across multiple wardens, with a clean API for developers to trigger animations programmatically.

I’ll create a reusable Paper Java animation utility that spawns a controlled Warden sequence with emergence, heartbeat, targeting, roar, and sonic-boom effects.

Created WardenAnimation.java.

Use it from your plugin with:

Java
WardenAnimation.play(this, player);

It includes Warden emergence, heartbeat pulses, roar, targeting, sonic-boom beam, particles, and cleanup.

Kodari can make mistakes. Review important code before using.
Files
src
Code
1 116
src/main/java/com/kodari/wardenanimation/WardenAnimation.java
package com.kodari.wardenanimation;

import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.particles.XParticle;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.entity.Warden;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;

public final class WardenAnimation {

    private WardenAnimation() {
    }

    public static void play(Plugin plugin, Player player) {
        Location spawnLocation = getSpawnLocation(player);
        Warden warden = spawnLocation.getWorld().spawn(spawnLocation, Warden.class);
        warden.setAI(false);
        warden.setInvulnerable(true);
        warden.setRemoveWhenFarAway(false);

        new BukkitRunnable() {
            private int tick;

            @Override
            public void run() {
                if (!player.isOnline() || player.isDead() || !warden.isValid()) {
                    warden.remove();
                    cancel();
                    return;
                }

                if (tick == 0) {
                    playSound(warden.getLocation(), "ENTITY_WARDEN_EMERGE", 1.2f, 0.8f);
                    spawnRing(warden.getLocation(), "SCULK_SOUL", 1.0, 18);
                } else if (tick == 20 || tick == 35 || tick == 50) {
                    playSound(warden.getLocation(), "ENTITY_WARDEN_HEARTBEAT", 1.0f, 1.0f);
                    spawnRing(warden.getLocation(), "SCULK_SOUL", 1.2, 24);
                } else if (tick == 60) {
                    warden.setAI(true);
                    warden.setTarget(player);
                    playSound(warden.getLocation(), "ENTITY_WARDEN_ROAR", 1.4f, 0.85f);
                } else if (tick == 78) {
                    warden.setAI(false);
                    playSound(warden.getLocation(), "ENTITY_WARDEN_SONIC_BOOM", 1.5f, 1.0f);
                    spawnSonicBeam(warden.getLocation(), player.getLocation());
                } else if (tick == 105) {
                    playSound(warden.getLocation(), "ENTITY_WARDEN_DIG", 1.0f, 1.0f);
                    warden.remove();
                    cancel();
                    return;
                }

                tick++;
            }
        }.runTaskTimer(plugin, 0L, 1L);
    }

    private static Location getSpawnLocation(Player player) {
        Location location = player.getLocation().clone();
        org.bukkit.util.Vector direction = location.getDirection();
        direction.setY(0);
        if (direction.lengthSquared() == 0) {
            direction.setZ(1);
        }
        direction.normalize().multiply(5);
        location.add(direction);
        return location;
    }

    private static void playSound(Location location, String soundName, float volume, float pitch) {
        XSound.matchXSound(soundName).ifPresent(sound -> sound.play(location, volume, pitch));
    }

    private static void spawnRing(Location center, String particleName, double radius, int points) {
        World world = center.getWorld();
        if (world == null) {
            return;
        }

        XParticle.of(particleName).ifPresent(particle -> {
            for (int point = 0; point < points; point++) {
                double angle = Math.PI * 2 * point / points;
                Location particleLocation = center.clone().add(
                        Math.cos(angle) * radius,
                        0.15,
                        Math.sin(angle) * radius
                );
                world.spawnParticle(particle.get(), particleLocation, 1, 0, 0, 0, 0);
            }
        });
    }

    private static void spawnSonicBeam(Location start, Location target) {
        World world = start.getWorld();
        if (world == null || !world.equals(target.getWorld())) {
            return;
        }

        org.bukkit.util.Vector direction = target.toVector().subtract(start.toVector());
        double length = direction.length();
        if (length == 0) {
            return;
        }
        direction.normalize();

        XParticle.of("SONIC_BOOM").ifPresent(particle -> {
            for (double distance = 0; distance < length; distance += 0.5) {
                Location point = start.clone().add(direction.clone().multiply(distance));
                world.spawnParticle(particle.get(), point, 1, 0, 0, 0, 0);
            }
        });
    }
}