diff --git a/common/src/main/java/org/embeddedt/modernfix/world/IntegratedWatchdog.java b/common/src/main/java/org/embeddedt/modernfix/world/IntegratedWatchdog.java index 24305aa5..b5e5e827 100644 --- a/common/src/main/java/org/embeddedt/modernfix/world/IntegratedWatchdog.java +++ b/common/src/main/java/org/embeddedt/modernfix/world/IntegratedWatchdog.java @@ -38,6 +38,9 @@ public class IntegratedWatchdog extends Thread { return; } if(lastTickStart.getAsLong() < 0) { + try { + Thread.sleep(10000); + } catch(InterruptedException ignored) {} continue; } long curTime = Util.getMillis(); diff --git a/neoforge/src/main/java/org/embeddedt/modernfix/neoforge/dynresources/ModelBakeEventHelper.java b/neoforge/src/main/java/org/embeddedt/modernfix/neoforge/dynresources/ModelBakeEventHelper.java index b44cad91..a8e17d93 100644 --- a/neoforge/src/main/java/org/embeddedt/modernfix/neoforge/dynresources/ModelBakeEventHelper.java +++ b/neoforge/src/main/java/org/embeddedt/modernfix/neoforge/dynresources/ModelBakeEventHelper.java @@ -2,6 +2,7 @@ package org.embeddedt.modernfix.neoforge.dynresources; import com.google.common.collect.ForwardingMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterators; import com.google.common.collect.Sets; import com.google.common.graph.GraphBuilder; import com.google.common.graph.MutableGraph; @@ -151,6 +152,11 @@ public class ModelBakeEventHelper { return ourModelLocations.contains(key) || super.containsKey(key); } + @Override + public Set> entrySet() { + return new DynamicModelEntrySet(this, ourModelLocations); + } + @Override public void replaceAll(BiFunction function) { ModernFix.LOGGER.warn("Mod '{}' is calling replaceAll on the model registry. Some hacks will be used to keep this fast, but they may not be 100% compatible.", modId); @@ -178,4 +184,61 @@ public class ModelBakeEventHelper { } }; } + + private static class DynamicModelEntrySet extends AbstractSet> { + private final Map modelRegistry; + private final Set modelLocations; + + private DynamicModelEntrySet(Map modelRegistry, Set modelLocations) { + this.modelRegistry = modelRegistry; + this.modelLocations = modelLocations; + } + + @Override + public Iterator> iterator() { + return Iterators.transform(Iterators.unmodifiableIterator(this.modelLocations.iterator()), DynamicModelEntry::new); + } + + @Override + public boolean contains(Object o) { + if(o instanceof Map.Entry entry) { + return modelRegistry.containsKey(entry.getKey()); + } else { + return false; + } + } + + @Override + public int size() { + return modelRegistry.size(); + } + + @Override + public boolean removeAll(Collection c) { + throw new UnsupportedOperationException(); + } + + private class DynamicModelEntry implements Map.Entry { + private final ModelResourceLocation location; + + private DynamicModelEntry(ModelResourceLocation location) { + this.location = location; + } + + @Override + public ModelResourceLocation getKey() { + return this.location; + } + + @Override + public BakedModel getValue() { + return modelRegistry.get(this.location); + } + + @Override + public BakedModel setValue(BakedModel value) { + return modelRegistry.put(this.location, value); + } + } + } } diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index 400e34c2..09a794b9 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -64,6 +64,6 @@ side = "BOTH" modId = "jei" type = "optional" # This version range declares a minimum of the current minecraft version up to but not including the next major version -versionRange = "[13,)" +versionRange = "[15.8.0.11,)" ordering = "BEFORE" side = "CLIENT"