Merge 1.19.4 into 1.20
This commit is contained in:
commit
ef341932a3
|
|
@ -0,0 +1,41 @@
|
||||||
|
package org.embeddedt.modernfix.common.mixin.bugfix.world_leaks;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
|
import net.minecraft.world.level.chunk.LevelChunk;
|
||||||
|
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||||
|
import org.embeddedt.modernfix.ModernFix;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
|
|
||||||
|
@Mixin(Minecraft.class)
|
||||||
|
public class MinecraftMixin {
|
||||||
|
@Shadow @Nullable public ClientLevel level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To mitigate the effect of leaked client worlds, clear most of the data structures that waste memory.
|
||||||
|
*/
|
||||||
|
@Inject(method = "clearLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/client/Minecraft;level:Lnet/minecraft/client/multiplayer/ClientLevel;"))
|
||||||
|
private void clearLevelDataForLeaks(CallbackInfo ci) {
|
||||||
|
if(this.level != null) {
|
||||||
|
try {
|
||||||
|
AtomicReferenceArray<LevelChunk> chunks = this.level.getChunkSource().storage.chunks;
|
||||||
|
for(int i = 0; i < chunks.length(); i++) {
|
||||||
|
chunks.set(i, null);
|
||||||
|
}
|
||||||
|
this.level.getChunkSource().lightEngine = new LevelLightEngine(this.level.getChunkSource(), false, false);
|
||||||
|
// clear BE list otherwise they will hold chunks
|
||||||
|
this.level.blockEntityTickers.clear();
|
||||||
|
} catch(RuntimeException e) {
|
||||||
|
ModernFix.LOGGER.error("Exception clearing level data", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
||||||
* Replacement backing map for CompoundTags that interns keys.
|
* Replacement backing map for CompoundTags that interns keys.
|
||||||
*/
|
*/
|
||||||
public class CanonizingStringMap<T> extends HashMap<String, T> {
|
public class CanonizingStringMap<T> extends HashMap<String, T> {
|
||||||
private static final Interner<String> KEY_INTERNER = Interners.newStrongInterner();
|
private static final Interner<String> KEY_INTERNER = Interners.newWeakInterner();
|
||||||
|
|
||||||
private static String intern(String key) {
|
private static String intern(String key) {
|
||||||
return key != null ? KEY_INTERNER.intern(key) : null;
|
return key != null ? KEY_INTERNER.intern(key) : null;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,13 @@
|
||||||
accessWidener v2 named
|
accessWidener v2 named
|
||||||
|
|
||||||
|
accessible field net/minecraft/client/multiplayer/ClientChunkCache storage Lnet/minecraft/client/multiplayer/ClientChunkCache$Storage;
|
||||||
|
accessible field net/minecraft/client/multiplayer/ClientChunkCache lightEngine Lnet/minecraft/world/level/lighting/LevelLightEngine;
|
||||||
|
mutable field net/minecraft/client/multiplayer/ClientChunkCache lightEngine Lnet/minecraft/world/level/lighting/LevelLightEngine;
|
||||||
|
accessible class net/minecraft/client/multiplayer/ClientChunkCache$Storage
|
||||||
|
accessible field net/minecraft/client/multiplayer/ClientChunkCache$Storage chunks Ljava/util/concurrent/atomic/AtomicReferenceArray;
|
||||||
|
|
||||||
|
accessible field net/minecraft/world/level/Level blockEntityTickers Ljava/util/List;
|
||||||
|
|
||||||
accessible class net/minecraft/client/renderer/RenderType$CompositeRenderType
|
accessible class net/minecraft/client/renderer/RenderType$CompositeRenderType
|
||||||
accessible method net/minecraft/nbt/CompoundTag <init> (Ljava/util/Map;)V
|
accessible method net/minecraft/nbt/CompoundTag <init> (Ljava/util/Map;)V
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,15 @@
|
||||||
},
|
},
|
||||||
"license": "LGPL-3.0",
|
"license": "LGPL-3.0",
|
||||||
"icon": "icon.png",
|
"icon": "icon.png",
|
||||||
|
"custom": {
|
||||||
|
"modmenu": {
|
||||||
|
"links": {
|
||||||
|
"modmenu.kofi": "https://ko-fi.com/embeddedt",
|
||||||
|
"modmenu.github_releases": "https://github.com/embeddedt/ModernFix/releases",
|
||||||
|
"modmenu.curseforge": "https://www.curseforge.com/minecraft/mc-mods/modernfix"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user