Files
CustomNPC-Plus/src/main/java/noppes/npcs/controllers/data/FramePart.java
T

115 lines
2.3 KiB
Java
Raw Normal View History

package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.constants.EnumAnimationPart;
public class FramePart {
public EnumAnimationPart part;
public int[] rotation = {0, 0, 0};
public int[] pivot = {0, 0, 0};
boolean customized = false;
public float speed = 1.0F;
public boolean smooth = false;
2023-01-12 19:40:06 -05:00
public FramePart(){}
public FramePart(EnumAnimationPart part){
this.part = part;
}
public FramePart(EnumAnimationPart part, int[] rotation, int[] pivot){
this.part = part;
this.rotation = rotation;
this.pivot = pivot;
}
public FramePart(EnumAnimationPart part, int[] rotation, int[] pivot, float speed, boolean smooth){
this.part = part;
this.rotation = rotation;
this.pivot = pivot;
this.speed = speed;
this.smooth = smooth;
this.customized = true;
}
public EnumAnimationPart getPart() {
return part;
}
public void setPart(EnumAnimationPart part) {
this.part = part;
}
public int[] getRotation() {
return rotation;
}
public void setRotation(int[] rotation) {
this.rotation = rotation;
}
public int[] getPivot() {
return pivot;
}
public void setPivot(int[] pivot) {
this.pivot = pivot;
}
public boolean isCustomized() {
return customized;
}
public void setCustomized(boolean customized) {
this.customized = customized;
}
public float getSpeed() {
return speed;
}
public void setSpeed(float speed) {
this.speed = speed;
}
public boolean isSmooth() {
return smooth;
}
public void setSmooth(boolean smooth) {
this.smooth = smooth;
}
public void readFromNBT(NBTTagCompound compound){
part = EnumAnimationPart.valueOf(compound.getString("Part"));
rotation = compound.getIntArray("Rotation");
pivot = compound.getIntArray("Pivot");
// Customized = TRUE if Speed or Smooth Exist
if(compound.hasKey("Speed")){
customized = true;
speed = compound.getFloat("Speed");
}
if(compound.hasKey("Smooth")){
customized = true;
smooth = compound.getBoolean("Smooth");
}
}
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
compound.setString("Part", part.toString());
compound.setIntArray("Rotation", rotation);
compound.setIntArray("Pivot", pivot);
2023-01-12 21:33:06 -05:00
if(customized){
compound.setFloat("Speed", speed);
compound.setBoolean("Smooth", smooth);
}
return compound;
}
}