From a0bf0155ac3594ec18315ad57a6f15bd2f08614b Mon Sep 17 00:00:00 2001 From: RainWarrior Date: Tue, 26 Jan 2016 01:22:17 +0300 Subject: [PATCH] Fix NoSuchElementException in ModelBlockAnimation caused by empty event list. --- .../model/animation/ModelBlockAnimation.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java b/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java index ca07406e78..a7480b20d7 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java +++ b/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java @@ -109,31 +109,34 @@ public class ModelBlockAnimation if(jointClips == null) { ImmutableMap.Builder builder = ImmutableMap.builder(); - for(Map.Entry> e : jointClipsFlat.entrySet()) + for (Map.Entry> e : jointClipsFlat.entrySet()) { builder.put(e.getKey(), new MBJointClip(loop, e.getValue())); } jointClips = builder.build(); events = Maps.newTreeMap(); - TreeMap times = Maps.newTreeMap(); - for(String time : eventsRaw.keySet()) + if (!eventsRaw.isEmpty()) { - times.put(Float.parseFloat(time), time); - } - float lastTime = Float.POSITIVE_INFINITY; - if(loop) - { - lastTime = times.firstKey(); - } - for(Map.Entry entry : times.descendingMap().entrySet()) - { - float time = entry.getKey(); - float offset = lastTime - time; - if(loop) + TreeMap times = Maps.newTreeMap(); + for (String time : eventsRaw.keySet()) { - offset = 1 - (1 - offset) % 1; + times.put(Float.parseFloat(time), time); + } + float lastTime = Float.POSITIVE_INFINITY; + if (loop) + { + lastTime = times.firstKey(); + } + for (Map.Entry entry : times.descendingMap().entrySet()) + { + float time = entry.getKey(); + float offset = lastTime - time; + if (loop) + { + offset = 1 - (1 - offset) % 1; + } + events.put(time, new Event(eventsRaw.get(entry.getValue()), offset)); } - events.put(time, new Event(eventsRaw.get(entry.getValue()), offset)); } } }