public abstract class AbstractProvider extends java.lang.Object implements BehaviorProvider
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
id
Unique identifier used to tell if a behavior is ours when asked to load it.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractProvider(java.lang.String id)
For the ID passed in here, it is suggested to use a one-time generated
UUID that is hard-coded into your provider implementation.
|
Modifier and Type | Method and Description |
---|---|
protected abstract Behavior |
readBehaviorFromNBT(net.minecraft.entity.player.EntityPlayer player,
net.minecraft.nbt.NBTTagCompound nbt)
Called when loading a behavior from NBT.
|
Behavior |
readFromNBT(net.minecraft.entity.player.EntityPlayer player,
net.minecraft.nbt.NBTTagCompound nbt)
Restore a behavior from NBT.
|
protected void |
writeBehaviorToNBT(Behavior behavior,
net.minecraft.nbt.NBTTagCompound nbt)
Called when saving a behavior created using this behavior to NBT.
|
net.minecraft.nbt.NBTTagCompound |
writeToNBT(Behavior behavior)
Write a behavior to NBT.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createBehaviors
protected final java.lang.String id
protected AbstractProvider(java.lang.String id)
id
- the unique identifier for this provider.protected void writeBehaviorToNBT(Behavior behavior, net.minecraft.nbt.NBTTagCompound nbt)
behavior
- the behavior to persist.nbt
- the NBT tag to persist it to.protected abstract Behavior readBehaviorFromNBT(net.minecraft.entity.player.EntityPlayer player, net.minecraft.nbt.NBTTagCompound nbt)
writeBehaviorToNBT(li.cil.oc.api.nanomachines.Behavior, net.minecraft.nbt.NBTTagCompound)
to restore the behavior
to its previous state, then return it.player
- the player to restore the behavior for.nbt
- the NBT tag to load restore the behavior from.public net.minecraft.nbt.NBTTagCompound writeToNBT(Behavior behavior)
BehaviorProvider
BehaviorProvider.createBehaviors(net.minecraft.entity.player.EntityPlayer)
, so make sure to save all your behaviors.writeToNBT
in interface BehaviorProvider
behavior
- the behavior to serialize.public Behavior readFromNBT(net.minecraft.entity.player.EntityPlayer player, net.minecraft.nbt.NBTTagCompound nbt)
BehaviorProvider
readFromNBT
in interface BehaviorProvider
player
- the player the behaviors should be created for.nbt
- the tag to restore the behavior from.