Merge remote-tracking branch 'origin/main' into 1.18
This commit is contained in:
commit
50d02a8058
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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<MessageDigest> digestThreadLocal = ThreadLocal.withInitial(() -> {
|
||||
|
|
@ -45,6 +47,8 @@ public class CachingStructureManager {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
private static final Set<String> 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, which can cause worldgen lag; please report this to them.", location.getNamespace());
|
||||
}
|
||||
}
|
||||
/* Needs upgrade, try looking up from cache */
|
||||
MessageDigest hasher = digestThreadLocal.get();
|
||||
hasher.reset();
|
||||
|
|
|
|||
|
|
@ -43,6 +43,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)
|
||||
|
|
@ -165,7 +166,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<Map.Entry<ResourceLocation, UnbakedModel>> 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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user