Package noppes.npcs.api.handler.data
Interface IAction
-
- All Known Subinterfaces:
IConditionalAction
public interface IAction
Represents a single "task" that can be executed over multiple ticks, supports delayed start, limited duration, repeating intervals, data storage, and chaining to neighboring tasks.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IAction
addData(java.lang.String key, java.lang.Object value)
Store arbitrary per-action data.IAction
after(int delay, java.util.function.Consumer<IAction> t)
IAction
after(java.lang.String name, int maxDuration, int delay, java.util.function.Consumer<IAction> t)
IAction
after(java.lang.String name, int delay, java.util.function.Consumer<IAction> t)
IAction
after(java.lang.String name, java.util.function.Consumer<IAction> t)
IAction
after(java.util.function.Consumer<IAction> t)
IAction
after(IAction after)
Enqueue another action immediately after this one.IAction
before(int delay, java.util.function.Consumer<IAction> t)
IAction
before(java.lang.String name, int maxDuration, int delay, java.util.function.Consumer<IAction> t)
IAction
before(java.lang.String name, int delay, java.util.function.Consumer<IAction> t)
IAction
before(java.lang.String name, java.util.function.Consumer<IAction> t)
IAction
before(java.util.function.Consumer<IAction> t)
IAction
before(IAction before)
Enqueue another action immediately before this one (pausing this one until done).int
getCount()
java.lang.Object
getData(java.lang.String key)
Retrieve arbitrary per-action data.int
getDuration()
IActionManager
getManager()
int
getMaxDuration()
java.lang.String
getName()
IAction
getNext()
IAction
getPrevious()
int
getStartAfterTicks()
int
getUpdateEveryXTick()
boolean
isDone()
void
markDone()
Mark this action as complete.IAction
pauseFor(int ticks)
IAction
removeData(java.lang.String key)
IAction
setMaxDuration(int x)
IAction
setTask(java.util.function.Consumer<IAction> task)
IAction
setUpdateEveryXTick(int X)
Set how many ticks between each invocation of the action callback.
-
-
-
Method Detail
-
setTask
IAction setTask(java.util.function.Consumer<IAction> task)
- Parameters:
task
- code to execute each time the action fires- Returns:
-
getManager
IActionManager getManager()
- Returns:
- action manager the action is scheduled on
-
getCount
int getCount()
- Returns:
- how many times this action’s
action.accept(this)
callback has run (or how many times task ran)
-
getDuration
int getDuration()
- Returns:
- how many ticks have elapsed since this action actually began (excluding start delay)
-
getName
java.lang.String getName()
- Returns:
- the name given at creation/scheduling time
-
getMaxDuration
int getMaxDuration()
- Returns:
- the maximum number of ticks this action is allowed to run before auto-terminating
-
setMaxDuration
IAction setMaxDuration(int x)
-
markDone
void markDone()
Mark this action as complete. Once done, it will be removed on the next tick.
-
isDone
boolean isDone()
- Returns:
- true if
markDone()
was called (or maxDuration reached)
-
getData
java.lang.Object getData(java.lang.String key)
Retrieve arbitrary per-action data.- Parameters:
key
- a string key- Returns:
- the stored value, or null if not set
-
addData
IAction addData(java.lang.String key, java.lang.Object value)
Store arbitrary per-action data.- Parameters:
key
- a string keyvalue
- any object to associate with this action
-
removeData
IAction removeData(java.lang.String key)
-
getUpdateEveryXTick
int getUpdateEveryXTick()
- Returns:
- how many ticks between each invocation of the action callback
-
setUpdateEveryXTick
IAction setUpdateEveryXTick(int X)
Set how many ticks between each invocation of the action callback.- Parameters:
X
- tick interval (e.g. 1 = every tick, 20 = once per second)
-
getStartAfterTicks
int getStartAfterTicks()
- Returns:
- how many ticks remain before the action begins (initial delay)
-
pauseFor
IAction pauseFor(int ticks)
- Parameters:
ticks
- pauses action for this number of ticks (any subsequent action is paused too)- Returns:
-
getNext
IAction getNext()
- Returns:
- the next action in the queue (or null if none or at end)
-
getPrevious
IAction getPrevious()
- Returns:
- the previous action in the queue (or null if none or at front)
-
after
IAction after(IAction after)
Enqueue another action immediately after this one.- Parameters:
after
- the action to run next
-
after
IAction after(java.lang.String name, int maxDuration, int delay, java.util.function.Consumer<IAction> t)
-
before
IAction before(IAction before)
Enqueue another action immediately before this one (pausing this one until done).- Parameters:
before
- the action to run prior
-
before
IAction before(java.lang.String name, int maxDuration, int delay, java.util.function.Consumer<IAction> t)
-
-