Changed animations to flow into each other more smoothly.

This commit is contained in:
Luis C.M committed 2023-12-23 18:33:16 -06:00
1 parent bc089a4e14
commit 782f21f1fe
1 file changed
+19 -3
@@ -28,18 +28,18 @@ import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.player.GuiBook;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.config.ConfigClient;
import noppes.npcs.constants.EnumAnimationPart;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.controllers.data.RecipeCarpentry;
import noppes.npcs.controllers.data.*;
import noppes.npcs.entity.EntityDialogNpc;
import noppes.npcs.entity.EntityNPCInterface;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class PacketHandlerClient extends PacketHandlerServer{
@@ -331,6 +331,22 @@ public class PacketHandlerClient extends PacketHandlerServer{
if (animationData.allowAnimation) {
Animation animation = new Animation();
animation.readFromNBT(ClientCacheHandler.animationCache.get(animationId).writeToNBT());
if (animationData.animation != null && animation.frames.size() > 0) {
Frame frame = (Frame) animationData.animation.currentFrame();
if (frame != null) {
Frame firstFrame = animation.frames.get(0);
for (Map.Entry<EnumAnimationPart, FramePart> entry : frame.frameParts.entrySet()) {
if (firstFrame.frameParts.containsKey(entry.getKey())) {
FramePart prevFramePart = entry.getValue();
FramePart newFramePart = firstFrame.frameParts.get(entry.getKey());
for (int i = 0; i < 3; i++) {
newFramePart.prevPivots[i] = prevFramePart.prevPivots[i];
newFramePart.prevRotations[i] = prevFramePart.prevRotations[i];
}
}
}
}
}
animationData.animation = animation;
animation.parent = animationData;
Client.sendData(EnumPacketServer.CacheAnimation, animationId);