mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 13:25:10 +00:00
Animation overhaul, along with animation changes to the API.
This commit is contained in:
1 parent
bda76bafe6
commit
be18e756fc
23 files changed
+648
-1229
No files matched your search
@@ -2,71 +2,101 @@ package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.api.handler.data.IFrame;
|
||||
import noppes.npcs.api.handler.data.IFramePart;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class Frame {
|
||||
|
||||
public ArrayList<FramePart> frameParts = new ArrayList<FramePart>();
|
||||
public class Frame implements IFrame {
|
||||
public Animation parent;
|
||||
public HashMap<EnumAnimationPart,FramePart> frameParts = new HashMap<>();
|
||||
public int duration = 0;
|
||||
boolean customized = false;
|
||||
public float speed = 1.0F;
|
||||
public boolean smooth = false;
|
||||
public byte smooth = 0;
|
||||
|
||||
public Frame(){}
|
||||
|
||||
public Frame(ArrayList<FramePart> parts, int duration){
|
||||
this.frameParts = parts;
|
||||
public Frame(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public Frame(ArrayList<FramePart> parts, int duration, float speed, boolean smooth){
|
||||
this.frameParts = parts;
|
||||
public Frame(int duration, float speed, byte smooth) {
|
||||
this.duration = duration;
|
||||
this.speed = speed;
|
||||
this.smooth = smooth;
|
||||
this.customized = true;
|
||||
}
|
||||
|
||||
public ArrayList<FramePart> getFrameParts() {
|
||||
public HashMap<EnumAnimationPart,FramePart> getFrameMap() {
|
||||
return frameParts;
|
||||
}
|
||||
|
||||
public void setFrameParts(ArrayList<FramePart> frameParts) {
|
||||
this.frameParts = frameParts;
|
||||
public IFramePart[] getParts() {
|
||||
return frameParts.values().toArray(new IFramePart[0]);
|
||||
}
|
||||
|
||||
public IFrame addPart(IFramePart partConfig) {
|
||||
this.frameParts.put(((FramePart)partConfig).getPart(),(FramePart) partConfig);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IFrame removePart(String partName) {
|
||||
try {
|
||||
this.frameParts.remove(EnumAnimationPart.valueOf(partName));
|
||||
} catch (IllegalArgumentException ignored) {}
|
||||
return this;
|
||||
}
|
||||
|
||||
public IFrame removePart(int partId) {
|
||||
for (EnumAnimationPart part : EnumAnimationPart.values()) {
|
||||
this.frameParts.remove(part);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public IFrame clearParts() {
|
||||
frameParts.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
public IFrame setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isCustomized() {
|
||||
return customized;
|
||||
}
|
||||
|
||||
public void setCustomized(boolean customized) {
|
||||
public IFrame setCustomized(boolean customized) {
|
||||
this.customized = customized;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed(float speed) {
|
||||
public IFrame setSpeed(float speed) {
|
||||
this.speed = speed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isSmooth() {
|
||||
public byte smoothType() {
|
||||
return smooth;
|
||||
}
|
||||
|
||||
public void setSmooth(boolean smooth) {
|
||||
public IFrame setSmooth(byte smooth) {
|
||||
this.smooth = smooth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
@@ -79,16 +109,25 @@ public class Frame {
|
||||
}
|
||||
if(compound.hasKey("Smooth")){
|
||||
customized = true;
|
||||
smooth = compound.getBoolean("Smooth");
|
||||
smooth = compound.getByte("Smooth");
|
||||
}
|
||||
|
||||
ArrayList<FramePart> frameParts = new ArrayList<FramePart>();
|
||||
if (!customized) {
|
||||
this.speed = parent.speed;
|
||||
this.smooth = parent.smooth;
|
||||
}
|
||||
|
||||
HashMap<EnumAnimationPart,FramePart> frameParts = new HashMap<>();
|
||||
NBTTagList list = compound.getTagList("FrameParts", 10);
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
NBTTagCompound item = list.getCompoundTagAt(i);
|
||||
FramePart framePart = new FramePart();
|
||||
framePart.readFromNBT(item);
|
||||
frameParts.add(framePart);
|
||||
if (!framePart.customized) {
|
||||
framePart.smooth = this.smooth;
|
||||
framePart.speed = this.speed;
|
||||
}
|
||||
frameParts.put(framePart.part,framePart);
|
||||
}
|
||||
this.frameParts = frameParts;
|
||||
}
|
||||
@@ -98,11 +137,11 @@ public class Frame {
|
||||
compound.setInteger("Duration", duration);
|
||||
if(customized){
|
||||
compound.setFloat("Speed", speed);
|
||||
compound.setBoolean("Smooth", smooth);
|
||||
compound.setByte("Smooth", smooth);
|
||||
}
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(FramePart framePart : frameParts){
|
||||
for(FramePart framePart : frameParts.values()){
|
||||
NBTTagCompound item = framePart.writeToNBT();
|
||||
list.appendTag(item);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user