From 6e8247ae3a94c6cbfd7dbc9a981f0ee0cbb0a0c8 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Thu, 21 Mar 2024 14:40:20 +0100 Subject: [PATCH] Tentative fix for flickering with some custom animated textures --- BlueMapCommon/webapp/src/js/map/TextureAnimation.js | 4 +++- .../core/resources/resourcepack/texture/AnimationMeta.java | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/BlueMapCommon/webapp/src/js/map/TextureAnimation.js b/BlueMapCommon/webapp/src/js/map/TextureAnimation.js index 540f5abe..5f742465 100644 --- a/BlueMapCommon/webapp/src/js/map/TextureAnimation.js +++ b/BlueMapCommon/webapp/src/js/map/TextureAnimation.js @@ -44,8 +44,10 @@ export class TextureAnimation { this.frameImages = height / width; this.uniforms.animationFrameHeight.value = 1 / this.frameImages; this.frames = this.frameImages; - if (this.data.frames) { + if (this.data.frames && this.data.frames.length > 0) { this.frames = this.data.frames.length; + } else { + this.data.frames = null; } } diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/resourcepack/texture/AnimationMeta.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/resourcepack/texture/AnimationMeta.java index 0042e8fd..3aec544e 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/resourcepack/texture/AnimationMeta.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/resourcepack/texture/AnimationMeta.java @@ -101,7 +101,7 @@ public class AnimationMeta { } private void readFramesList(JsonReader in, AnimationMeta animationMeta) throws IOException { - animationMeta.frames = new ArrayList<>(); + List frames = new ArrayList<>(); in.beginArray(); while (in.hasNext()) { @@ -122,9 +122,12 @@ public class AnimationMeta { in.endObject(); } - animationMeta.frames.add(new FrameMeta(index, time)); + frames.add(new FrameMeta(index, time)); } in.endArray(); + + if (!frames.isEmpty()) + animationMeta.frames = frames; } @Override