Fixed animations being stuck. Animations should now properly continue where they left off when a player rejoins a server/ singleplayer world.

This commit is contained in:
Luis C.M committed 2024-03-29 16:37:31 -05:00
1 parent fd4a6d0a2c
commit 266a6515e5
7 files changed
+171 -65

No files matched your search

@@ -5,6 +5,8 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.CustomNpcs;
import noppes.npcs.DataDisplay;
import noppes.npcs.EventHooks;
import noppes.npcs.api.handler.data.IAnimation;
import noppes.npcs.api.handler.data.IAnimationData;
@@ -210,6 +212,9 @@ public class Animation implements IAnimation {
this.whileStanding = compound.getBoolean("WhileStanding");
this.whileMoving = compound.getBoolean("WhileWalking");
this.whileAttacking = compound.getBoolean("WhileAttacking");
this.currentFrame = compound.getInteger("CurrentFrame");
this.currentFrameTime = compound.getInteger("CurrentFrameTime");
}
public NBTTagCompound writeToNBT(){
@@ -231,6 +236,9 @@ public class Animation implements IAnimation {
compound.setBoolean("WhileStanding", whileStanding);
compound.setBoolean("WhileWalking", whileMoving);
compound.setBoolean("WhileAttacking", whileAttacking);
compound.setInteger("CurrentFrame", currentFrame);
compound.setInteger("CurrentFrameTime", currentFrameTime);
return compound;
}
@@ -277,16 +285,23 @@ public class Animation implements IAnimation {
@SideOnly(Side.CLIENT)
public void jumpToCurrentFrame() {
this.currentFrameTime = 0;
Frame frame = (Frame) this.currentFrame();
if(frame != null){
for (EnumAnimationPart part : EnumAnimationPart.values()) {
if(part != null){
if (frame.frameParts.containsKey(part)) {
frame.frameParts.get(part).jumpToCurrentFrame();
}
}
}
}
this.jumpToFrameAtTime(this.currentFrame, 0);
}
@SideOnly(Side.CLIENT)
public void jumpToFrameAtTime(int frameIndex, int time) {
this.currentFrame = frameIndex;
this.currentFrameTime = time;
Frame frame = (Frame) this.currentFrame();
if(frame != null){
for (EnumAnimationPart part : EnumAnimationPart.values()) {
if(part != null){
if (frame.frameParts.containsKey(part)) {
frame.frameParts.get(part).jumpToCurrentFrame();
}
}
}
}
}
}