Merge 1.20.2 into 1.20.3
This commit is contained in:
commit
850fdcbf1b
|
|
@ -3,6 +3,7 @@ package org.embeddedt.modernfix.forge.mixin.perf.dynamic_resources;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.RemovalNotification;
|
import com.google.common.cache.RemovalNotification;
|
||||||
|
import com.google.common.collect.ForwardingMap;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.color.block.BlockColors;
|
import net.minecraft.client.color.block.BlockColors;
|
||||||
|
|
@ -36,6 +37,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
@ -74,9 +76,14 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
|
|
||||||
private HashMap<ResourceLocation, UnbakedModel> smallLoadingCache = new HashMap<>();
|
private HashMap<ResourceLocation, UnbakedModel> smallLoadingCache = new HashMap<>();
|
||||||
|
|
||||||
|
// disable fabric recursion
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private boolean fabric_enableGetOrLoadModelGuard;
|
||||||
|
|
||||||
|
|
||||||
@Redirect(method = "<init>", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/client/resources/model/ModelBakery;blockColors:Lnet/minecraft/client/color/block/BlockColors;"))
|
@Redirect(method = "<init>", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/client/resources/model/ModelBakery;blockColors:Lnet/minecraft/client/color/block/BlockColors;"))
|
||||||
private void replaceTopLevelBakedModels(ModelBakery bakery, BlockColors val) {
|
private void replaceTopLevelBakedModels(ModelBakery bakery, BlockColors val) {
|
||||||
|
fabric_enableGetOrLoadModelGuard = false;
|
||||||
this.blockColors = val;
|
this.blockColors = val;
|
||||||
this.loadedBakedModels = CacheBuilder.newBuilder()
|
this.loadedBakedModels = CacheBuilder.newBuilder()
|
||||||
.expireAfterAccess(ModelBakeryHelpers.MAX_MODEL_LIFETIME_SECS, TimeUnit.SECONDS)
|
.expireAfterAccess(ModelBakeryHelpers.MAX_MODEL_LIFETIME_SECS, TimeUnit.SECONDS)
|
||||||
|
|
@ -93,7 +100,19 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
.softValues()
|
.softValues()
|
||||||
.build();
|
.build();
|
||||||
this.bakedCache = loadedBakedModels.asMap();
|
this.bakedCache = loadedBakedModels.asMap();
|
||||||
this.unbakedCache = loadedModels.asMap();
|
ConcurrentMap<ResourceLocation, UnbakedModel> unbakedCacheBackingMap = loadedModels.asMap();
|
||||||
|
this.unbakedCache = new ForwardingMap<ResourceLocation, UnbakedModel>() {
|
||||||
|
@Override
|
||||||
|
protected Map<ResourceLocation, UnbakedModel> delegate() {
|
||||||
|
return unbakedCacheBackingMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UnbakedModel put(ResourceLocation key, UnbakedModel value) {
|
||||||
|
smallLoadingCache.put(key, value);
|
||||||
|
return super.put(key, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
this.bakedTopLevelModels = new DynamicBakedModelProvider((ModelBakery)(Object)this, bakedCache);
|
this.bakedTopLevelModels = new DynamicBakedModelProvider((ModelBakery)(Object)this, bakedCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,8 @@ public class ModernFixPlatformHooksImpl implements ModernFixPlatformHooks {
|
||||||
noGroupField.setAccessible(true);
|
noGroupField.setAccessible(true);
|
||||||
InjectorGroupInfo noGroup = (InjectorGroupInfo)noGroupField.get(null);
|
InjectorGroupInfo noGroup = (InjectorGroupInfo)noGroupField.get(null);
|
||||||
groupMembersField.set(noGroup, new DummyList<>());
|
groupMembersField.set(noGroup, new DummyList<>());
|
||||||
|
} catch(NoSuchFieldException ignored) {
|
||||||
|
// Connector will replace FML's mixin with one which already has the fix, don't bother logging
|
||||||
} catch(RuntimeException | ReflectiveOperationException e) {
|
} catch(RuntimeException | ReflectiveOperationException e) {
|
||||||
ModernFixMixinPlugin.instance.logger.error("Failed to patch mixin memory leak", e);
|
ModernFixMixinPlugin.instance.logger.error("Failed to patch mixin memory leak", e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user