From 270fec309eda01737855aa3830b1613979d36d7d Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Thu, 4 May 2023 11:42:25 -0400 Subject: [PATCH 1/4] Complain once per mod ID if an outdated structure is found --- .../modernfix/structure/CachingStructureManager.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/src/main/java/org/embeddedt/modernfix/structure/CachingStructureManager.java b/common/src/main/java/org/embeddedt/modernfix/structure/CachingStructureManager.java index 73345285..b131bb3f 100644 --- a/common/src/main/java/org/embeddedt/modernfix/structure/CachingStructureManager.java +++ b/common/src/main/java/org/embeddedt/modernfix/structure/CachingStructureManager.java @@ -1,6 +1,7 @@ package org.embeddedt.modernfix.structure; import com.mojang.datafixers.DataFixer; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import net.minecraft.SharedConstants; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; @@ -15,6 +16,7 @@ import org.embeddedt.modernfix.util.FileUtil; import java.io.*; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.util.Set; public class CachingStructureManager { private static ThreadLocal digestThreadLocal = ThreadLocal.withInitial(() -> { @@ -45,6 +47,8 @@ public class CachingStructureManager { return sb.toString(); } + private static final Set laggyStructureMods = new ObjectOpenHashSet<>(); + public static CompoundTag readStructureTag(ResourceLocation location, DataFixer datafixer, InputStream stream) throws IOException { byte[] structureBytes = toBytes(stream); CompoundTag currentTag = NbtIo.readCompressed(new ByteArrayInputStream(structureBytes)); @@ -53,6 +57,11 @@ public class CachingStructureManager { } int currentDataVersion = currentTag.getInt("DataVersion"); if(currentDataVersion < SharedConstants.getCurrentVersion().getWorldVersion()) { + synchronized (laggyStructureMods) { + if(laggyStructureMods.add(location.getNamespace())) { + ModernFix.LOGGER.warn("Mod {} is shipping outdated structure files; please report this to them.", location.getNamespace()); + } + } /* Needs upgrade, try looking up from cache */ MessageDigest hasher = digestThreadLocal.get(); hasher.reset(); From 05901b4514b1128d794b8048d8419e8ecb3294cb Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Thu, 4 May 2023 11:43:06 -0400 Subject: [PATCH 2/4] Clearer message --- .../embeddedt/modernfix/structure/CachingStructureManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/org/embeddedt/modernfix/structure/CachingStructureManager.java b/common/src/main/java/org/embeddedt/modernfix/structure/CachingStructureManager.java index b131bb3f..b5ed3b88 100644 --- a/common/src/main/java/org/embeddedt/modernfix/structure/CachingStructureManager.java +++ b/common/src/main/java/org/embeddedt/modernfix/structure/CachingStructureManager.java @@ -59,7 +59,7 @@ public class CachingStructureManager { if(currentDataVersion < SharedConstants.getCurrentVersion().getWorldVersion()) { synchronized (laggyStructureMods) { if(laggyStructureMods.add(location.getNamespace())) { - ModernFix.LOGGER.warn("Mod {} is shipping outdated structure files; please report this to them.", location.getNamespace()); + ModernFix.LOGGER.warn("Mod {} is shipping outdated structure files, which can cause worldgen lag; please report this to them.", location.getNamespace()); } } /* Needs upgrade, try looking up from cache */ From 5260d55f91c86208c29fa040ac265994a880ad65 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Thu, 4 May 2023 14:06:17 -0400 Subject: [PATCH 3/4] New README [skip ci] --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index d9266842..e1543d82 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # ModernFix -A Forge 1.16 mod that uses mixins to make the game slightly more performant (and hopefully less buggy too). - -In the words of asiekierka, questionable "performance improvements" that are not in Forge for probably very good reasons. +A performance mod for modern Minecraft that significantly improves launch times, world load times, memory usage, etc. Some fixes are based on prior work in various Forge PRs (check commit history and/or code comments). The config system is directly derived from Sodium and used under the terms of the LGPL-3.0 license. From 2b8fc0827cc0f833abd6d7d4ac66f56a8002aa04 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Thu, 4 May 2023 15:55:52 -0400 Subject: [PATCH 4/4] Bake non-vanilla models on Fabric and then throw away the cache --- .../mixin/perf/dynamic_resources/ModelBakeryMixin.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fabric/src/main/java/org/embeddedt/modernfix/fabric/mixin/perf/dynamic_resources/ModelBakeryMixin.java b/fabric/src/main/java/org/embeddedt/modernfix/fabric/mixin/perf/dynamic_resources/ModelBakeryMixin.java index e902b4f0..83a50d35 100644 --- a/fabric/src/main/java/org/embeddedt/modernfix/fabric/mixin/perf/dynamic_resources/ModelBakeryMixin.java +++ b/fabric/src/main/java/org/embeddedt/modernfix/fabric/mixin/perf/dynamic_resources/ModelBakeryMixin.java @@ -40,6 +40,7 @@ import java.util.*; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; import java.util.function.Function; +import java.util.function.Predicate; /* high priority so that our injectors are added before other mods' */ @Mixin(value = ModelBakery.class, priority = 600) @@ -162,7 +163,13 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery { }; // discard unwrapped models int oldSize = this.unbakedCache.size(); - this.unbakedCache.entrySet().removeIf(entry -> entry.getValue() instanceof BlockModel || entry.getValue() instanceof MultiVariant || entry.getValue() instanceof MultiPart); + Predicate> isVanillaModel = entry -> entry.getValue() instanceof BlockModel || entry.getValue() instanceof MultiVariant || entry.getValue() instanceof MultiPart; + // bake indigo models + this.topLevelModels.entrySet().forEach((entry) -> { + if(!isVanillaModel.test(entry)) + this.bake(entry.getKey(), BlockModelRotation.X0_Y0); + }); + this.unbakedCache.entrySet().removeIf(isVanillaModel); ModernFix.LOGGER.info("{} models evicted, {} custom models loaded permanently", oldSize - this.unbakedCache.size(), this.unbakedCache.size()); this.unbakedCache = new LayeredForwardingMap<>(new Map[] { this.unbakedCache, mutableBackingMap }); this.bakedTopLevelModels = new DynamicBakedModelProvider((ModelBakery)(Object)this, bakedCache);