mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 21:09:40 +00:00
Frames can now be copy/pasted in the animation editor, even working across animations. Copy with CTRL + C and paste with CTRL + V.
This commit is contained in:
1 parent
947c908667
commit
206755a343
3 files changed
+48
-13
No files matched your search
@@ -18,7 +18,6 @@ import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.blocks.tiles.TileNpcContainer;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.containers.*;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.Frame;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
@@ -26,6 +25,7 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.util.MillisTimer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class CommonProxy implements IGuiHandler {
|
||||
@@ -68,7 +68,9 @@ public class CommonProxy implements IGuiHandler {
|
||||
serverPlayingAnimations.removeIf(CommonProxy.this::removeAnimation);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (!(e instanceof ConcurrentModificationException)) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
|
||||
@@ -3,7 +3,6 @@ package noppes.npcs.client.gui.global;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.gui.SubGuiAnimationFrame;
|
||||
import noppes.npcs.client.gui.SubGuiAnimationOptions;
|
||||
import noppes.npcs.client.gui.SubGuiColorSelector;
|
||||
@@ -24,14 +23,16 @@ import java.util.Map;
|
||||
public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfieldListener, ISliderListener, ISubGuiListener {
|
||||
private final Animation animation;
|
||||
|
||||
private static int partEditMode;
|
||||
private static int sliderSelection = 0;
|
||||
private static Frame copiedFrame;
|
||||
|
||||
private EnumAnimationPart editingPart = EnumAnimationPart.HEAD;
|
||||
private int frameIndex = 0;
|
||||
public boolean playingAnimation = false;
|
||||
private Frame prevFrame;
|
||||
private final GuiScreen parent;
|
||||
private long prevTick;
|
||||
private static int partEditMode;
|
||||
private static int sliderSelection = 0;
|
||||
|
||||
private final GuiNpcSlider[] rotationSliders = new GuiNpcSlider[3];
|
||||
private final GuiNpcSlider[] pivotSliders = new GuiNpcSlider[3];
|
||||
@@ -402,13 +403,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield
|
||||
AnimationData data = npc.display.animationData;
|
||||
|
||||
if (guibutton.id == 11) {
|
||||
if (frameIndex < animation.frames.size() - 1) {
|
||||
animation.frames.add(frameIndex + 1, new Frame(10));
|
||||
} else {
|
||||
animation.frames.add(new Frame(10));
|
||||
}
|
||||
this.frameIndex = frameIndex + 1;
|
||||
updateFrameSlider();
|
||||
this.addFrame();
|
||||
} else if (guibutton.id == 12) {
|
||||
animation.frames.remove(frameIndex);
|
||||
updateFrameSlider();
|
||||
@@ -502,6 +497,20 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield
|
||||
initGui();
|
||||
}
|
||||
|
||||
private void addFrame() {
|
||||
this.addFrame(new Frame(10));
|
||||
}
|
||||
|
||||
private void addFrame(Frame frame) {
|
||||
if (frameIndex < animation.frames.size() - 1) {
|
||||
animation.frames.add(frameIndex + 1, frame);
|
||||
} else {
|
||||
animation.frames.add(frame);
|
||||
}
|
||||
this.frameIndex = frameIndex + 1;
|
||||
updateFrameSlider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int par1, int par2, float par3)
|
||||
{
|
||||
@@ -640,4 +649,28 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield
|
||||
editingFrame.setColorMarker(((SubGuiColorSelector) subgui).color);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char par1, int par2) {
|
||||
super.keyTyped(par1, par2);
|
||||
|
||||
if (GuiScreen.isCtrlKeyDown() && par2 != 29 && !GuiNpcTextField.isFieldActive()) {
|
||||
switch (par2) {
|
||||
case 46:
|
||||
if (this.editingFrame() != null) {
|
||||
copiedFrame = this.editingFrame();
|
||||
}
|
||||
break;
|
||||
case 47:
|
||||
if (copiedFrame != null) {
|
||||
Frame frame = new Frame(10);
|
||||
frame.parent = this.animation;
|
||||
frame.readFromNBT(copiedFrame.writeToNBT());
|
||||
this.addFrame(frame);
|
||||
this.initGui();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,7 @@ public class Frame implements IFrame {
|
||||
this.tickDuration = compound.getBoolean("RenderTicks") ? 20 : 50;
|
||||
}
|
||||
|
||||
if (!customized) {
|
||||
if (!customized && parent != null) {
|
||||
this.speed = parent.speed;
|
||||
this.smooth = parent.smooth;
|
||||
this.tickDuration = parent.tickDuration;
|
||||
|
||||
Reference in new issue
Block a user