mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 13:10:04 +00:00
Fixed null pointer exception when updating animation data.
This commit is contained in:
1 parent
3486686abe
commit
947c908667
1 file changed
+17
-16
@@ -20,10 +20,12 @@ 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;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.util.MillisTimer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class CommonProxy implements IGuiHandler {
|
||||
@@ -49,24 +51,10 @@ public class CommonProxy implements IGuiHandler {
|
||||
}
|
||||
|
||||
for (int i = 0; i < animationTimer.elapsedTicks; ++i) {
|
||||
for (AnimationData data : clientPlayingAnimations) {
|
||||
if (data.animation != null) {
|
||||
int tickDuration = data.animation.currentFrame().tickDuration();
|
||||
if (totalClientTicks % tickDuration == 0) {
|
||||
data.increaseTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
updateData(totalClientTicks, clientPlayingAnimations);
|
||||
totalClientTicks++;
|
||||
|
||||
for (AnimationData data : serverPlayingAnimations) {
|
||||
if (data.animation != null) {
|
||||
int tickDuration = data.animation.currentFrame().tickDuration();
|
||||
if (totalServerTicks % tickDuration == 0) {
|
||||
data.increaseTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
updateData(totalServerTicks, serverPlayingAnimations);
|
||||
totalServerTicks++;
|
||||
}
|
||||
|
||||
@@ -88,6 +76,19 @@ public class CommonProxy implements IGuiHandler {
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private void updateData(long ticks, Collection<AnimationData> animationData) {
|
||||
for (AnimationData data : animationData) {
|
||||
Frame frame = data.animation != null && data.animation.currentFrame() != null
|
||||
? (Frame) data.animation.currentFrame() : null;
|
||||
if (frame != null) {
|
||||
int tickDuration = frame.tickDuration();
|
||||
if (ticks % tickDuration == 0) {
|
||||
data.increaseTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean removeAnimation(AnimationData data) {
|
||||
Entity entity = null;
|
||||
if (data.parent instanceof DataDisplay) {
|
||||
|
||||
Reference in new issue
Block a user