Wraiths

Simple, yet powerful NPC API

The Wraith api allows you to create and control player npc's with simple concepts or even more complex Wraiths with handlers and ai controllers. It's all possible with the WRAITH api in phantom

Create a Basic Wraith

Let's play around with some simple functionality through wraiths to get started

//Create the Wraith and give it a name
Wraith wraith = new PhantomWraith("Wraith");

//Let's spawn the wraith into the world so we can use it
wraith.spawn(Bukkit.getWorld("world").getSpawnLocation());

//You can follow entities or locations
wraith.setTarget(Bukkit.getPlayer("cyberpwn"));

//You can "focus" on entities or locations
wraith.setFocus(Bukkit.getPlayer("SwiftSwamp"));

//You can equip wraiths with items
wraith.setEquipment(WraithEquipment.HAND, new ItemStack(Material.IRON_SWORD));
wraith.setEquipment(WraithEquipment.CHESTPLATE, new ItemStack(Material.GOLD_BOOTS));

//Or all of this
wraith.setAggressive(true);
wraith.setSneaking(true);
wraith.setSprinting(false);
wraith.setTarget(Bukkit.getPlayer("Herobrine"));
wraith.setFocus(Bukkit.getPlayer("Herobrine"));
wraith.setProtected(true);
wraith.say("I will kill you Herobrine", 32);

//When you are done
wraith.despawn();

Wraith Events

  • WraithCollideEvent - An entity collided with the wraith
  • WraithDamageEvent - The wraith was damaged by an entity or block
  • WraithInteractEvent - A Player right clicked the wraith
  • WraithMoveEvent - The wraith has moved

Wraith Handlers

Wraith handlers allow you to control a wraith and use it across multiple wraiths if need be.

package org.phantomapi;

import org.phantomapi.wraith.Wraith;
import org.phantomapi.wraith.WraithHandle;

public class ExampleHandler extends WraithHandle
{
    public ExampleHandler(Wraith wraith)
    {
        super(wraith);

        // Set up any data for the wraith
    }

    @Override
    public void onTick()
    {
        // Called 4 times a second
    }

    @Override
    public void onUnbind()
    {
        // Called before the handler is removed from the wraith
    }

    @Override
    public void onBind()
    {
        // Called when the handler is added to the wraith
    }
}

You can then add the handler like so

Wraith w = new PhantomWraith("Wraith");

//This automatically binds the handle
ExampleHandler handle = new ExampleHandler(w);

//You can remove it internally or from here
handle.unregister();

//Destroys handlers
w.despawn();

results matching ""

    No results matching ""