2023-01-12 19:32:40 -05:00
|
|
|
package noppes.npcs.controllers.data;
|
|
|
|
|
|
2023-01-12 20:34:07 -05:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import net.minecraft.nbt.NBTTagList;
|
|
|
|
|
|
2023-01-12 19:32:40 -05:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class Animation {
|
|
|
|
|
|
|
|
|
|
public ArrayList<Frame> frames = new ArrayList<Frame>();
|
|
|
|
|
public int id = 0;
|
|
|
|
|
public String name;
|
|
|
|
|
public float speed = 1.0F;
|
|
|
|
|
public boolean smooth = false;
|
|
|
|
|
|
2023-01-12 19:40:06 -05:00
|
|
|
public Animation(){}
|
|
|
|
|
|
2023-01-12 19:32:40 -05:00
|
|
|
public Animation(ArrayList<Frame> parts, String name){
|
|
|
|
|
this.frames = parts;
|
|
|
|
|
this.name = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Animation(ArrayList<Frame> parts, String name, float speed, boolean smooth){
|
|
|
|
|
this.frames = parts;
|
|
|
|
|
this.name = name;
|
|
|
|
|
this.speed = speed;
|
|
|
|
|
this.smooth = smooth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ArrayList<Frame> getFrames() {
|
|
|
|
|
return frames;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getId() {
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float getSpeed() {
|
|
|
|
|
return speed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isSmooth() {
|
|
|
|
|
return smooth;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-12 20:34:07 -05:00
|
|
|
public void readFromNBT(NBTTagCompound compound){
|
|
|
|
|
name = compound.getString("Name");
|
|
|
|
|
id = compound.getInteger("ID");
|
|
|
|
|
speed = compound.getFloat("Speed");
|
|
|
|
|
smooth = compound.getBoolean("Smooth");
|
|
|
|
|
|
|
|
|
|
ArrayList<Frame> frames = new ArrayList<Frame>();
|
|
|
|
|
NBTTagList list = compound.getTagList("Frames", 10);
|
|
|
|
|
for (int i = 0; i < list.tagCount(); i++) {
|
|
|
|
|
NBTTagCompound item = list.getCompoundTagAt(i);
|
|
|
|
|
Frame frame = new Frame();
|
|
|
|
|
frame.readFromNBT(item);
|
|
|
|
|
frames.add(frame);
|
|
|
|
|
}
|
|
|
|
|
this.frames = frames;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NBTTagCompound writeToNBT(){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
compound.setString("Name", name);
|
|
|
|
|
compound.setInteger("ID", id);
|
|
|
|
|
compound.setFloat("Speed", speed);
|
|
|
|
|
compound.setBoolean("Smooth", smooth);
|
|
|
|
|
|
|
|
|
|
NBTTagList list = new NBTTagList();
|
|
|
|
|
for(Frame frame : frames){
|
|
|
|
|
NBTTagCompound item = frame.writeToNBT();
|
|
|
|
|
list.appendTag(item);
|
|
|
|
|
}
|
|
|
|
|
compound.setTag("Frames", list);
|
|
|
|
|
return compound;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-12 19:32:40 -05:00
|
|
|
}
|