mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 02:37:27 +00:00
Changes to the animation GUI and part/frame saving.
This commit is contained in:
1 parent
b8dc090db8
commit
79e13dfade
5 files changed
+48
-10
No files matched your search
@@ -25,7 +25,7 @@ public class AnimationData implements IAnimationData {
|
||||
public void updateClient() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound = this.writeToNBT(compound);
|
||||
compound.setTag("Animation",this.animation.writeToNBT());
|
||||
compound.setTag("Animation",this.animation == null ? new NBTTagCompound() : this.animation.writeToNBT());
|
||||
if (parent instanceof PlayerData) {
|
||||
Server.sendToAll(EnumPacketClient.UPDATE_ANIMATIONS, compound, ((PlayerData) parent).player.getCommandSenderName());
|
||||
} else if (parent instanceof DataDisplay) {
|
||||
|
||||
@@ -113,12 +113,15 @@ public class GuiNPCManageAnimations extends GuiModelInterface implements IScroll
|
||||
|
||||
|
||||
this.addLabel(new GuiNpcLabel(10, "animation.frames", guiLeft + 9 + 145, guiTop + 180, 0xFFFFFF));
|
||||
this.addButton(new GuiNpcButton(11, guiLeft - 20 + 145, guiTop + 191, 45, 20, "gui.add"));
|
||||
this.addButton(new GuiNpcButton(11, guiLeft - 45 + 150, guiTop + 189, 45, 20, "gui.add"));
|
||||
if (animation.frames.size() > 0) {
|
||||
this.addButton(new GuiNpcButton(12, guiLeft + 30 + 145, guiTop + 191, 45, 20, "gui.remove"));
|
||||
this.addButton(new GuiNpcButton(13, guiLeft - 3 + 145, guiTop + 210, 20, 20, "<"));
|
||||
this.addButton(new GuiNpcButton(14, guiLeft + 17 + 145, guiTop + 210, 20, 20, "" + frameIndex));
|
||||
this.addButton(new GuiNpcButton(15, guiLeft + 37 + 145, guiTop + 210, 20, 20, ">"));
|
||||
this.addButton(new GuiNpcButton(12, guiLeft + 150, guiTop + 189, 45, 20, "gui.remove"));
|
||||
this.addButton(new GuiNpcButton(13, guiLeft + 45 + 150, guiTop + 189, 45, 20, "gui.copy"));
|
||||
this.addButton(new GuiNpcButton(14, guiLeft - 8 + 145, guiTop + 210, 20, 20, "<"));
|
||||
this.addTextField(new GuiNpcTextField(15, this, guiLeft + 17 + 145, guiTop + 212, 20, 17, frameIndex + ""));
|
||||
this.getTextField(15).integersOnly = true;
|
||||
this.getTextField(15).setMinMaxDefault(0, animation.frames.size() - 1, frameIndex);
|
||||
this.addButton(new GuiNpcButton(16, guiLeft + 42 + 145, guiTop + 210, 20, 20, ">"));
|
||||
}
|
||||
|
||||
this.addButton(new GuiNpcButton(20, guiLeft + 290, guiTop - 5, 75, 20, new String[]{"animation.animation", "animation.frame", "animation.framePart"}, editingMode));
|
||||
@@ -331,12 +334,18 @@ public class GuiNPCManageAnimations extends GuiModelInterface implements IScroll
|
||||
}
|
||||
} else if (guibutton.id == 12) {
|
||||
animation.frames.remove(frameIndex);
|
||||
} else if (guibutton.id == 13) {
|
||||
} else if (guibutton.id == 13 && editingFrame != null) {
|
||||
if (frameIndex < animation.frames.size() - 1) {
|
||||
animation.frames.add(frameIndex + 1, editingFrame.copy());
|
||||
} else {
|
||||
animation.frames.add(editingFrame.copy());
|
||||
}
|
||||
} else if (guibutton.id == 14) {
|
||||
frameIndex--;
|
||||
if (frameIndex == -1) {
|
||||
frameIndex = animation.frames.size() - 1;
|
||||
}
|
||||
} else if (guibutton.id == 14 || guibutton.id == 15) {
|
||||
} else if (guibutton.id == 16) {
|
||||
frameIndex++;
|
||||
} else if (guibutton.id == 20) {
|
||||
editingMode++;
|
||||
@@ -457,6 +466,10 @@ public class GuiNPCManageAnimations extends GuiModelInterface implements IScroll
|
||||
} else {
|
||||
textfield.setText(animation.name);
|
||||
}
|
||||
} else if (textfield.id == 15 && animation != null && animation.frames.size() > 0) {
|
||||
animation.frames.remove(frameIndex);
|
||||
animation.frames.add(textfield.getInteger(),frame);
|
||||
frameIndex = textfield.getInteger();
|
||||
} else if (textfield.id == 32) {
|
||||
if (editingMode == 0) {
|
||||
animation.speed = textfield.getFloat();
|
||||
|
||||
@@ -165,4 +165,19 @@ public class Frame implements IFrame {
|
||||
compound.setTag("FrameParts", list);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public Frame copy() {
|
||||
Frame frame = new Frame(this.duration);
|
||||
HashMap<EnumAnimationPart,FramePart> frameParts = this.frameParts;
|
||||
for (Map.Entry<EnumAnimationPart,FramePart> entry : frameParts.entrySet()) {
|
||||
frame.frameParts.put(entry.getKey(),entry.getValue().copy());
|
||||
}
|
||||
frame.parent = this.parent;
|
||||
frame.duration = this.duration;
|
||||
frame.customized = this.customized;
|
||||
frame.speed = this.speed;
|
||||
frame.smooth = this.smooth;
|
||||
frame.renderTicks = this.renderTicks;
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class FramePart implements IFramePart {
|
||||
public byte smooth = 0;
|
||||
|
||||
//Client-sided fields (unsaved)
|
||||
public float[] prevRotations = {(float) Math.PI,(float) Math.PI,(float) Math.PI};
|
||||
public float[] prevRotations = {0,0,0};
|
||||
public float[] prevPivots = {0,0,0};
|
||||
public float partialRotationTick;
|
||||
public float partialPivotTick;
|
||||
@@ -147,6 +147,16 @@ public class FramePart implements IFramePart {
|
||||
return compound;
|
||||
}
|
||||
|
||||
public FramePart copy() {
|
||||
FramePart part = new FramePart(this.part);
|
||||
part.rotation = new float[]{this.rotation[0],this.rotation[1],this.rotation[2]};
|
||||
part.pivot = new float[]{this.pivot[0],this.pivot[1],this.pivot[2]};
|
||||
part.customized = this.customized;
|
||||
part.speed = this.speed;
|
||||
part.smooth = this.smooth;
|
||||
return part;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void interpolateAngles() {
|
||||
if (parent != null && parent.paused)
|
||||
|
||||
Reference in new issue
Block a user