Reduce memory usage of ImposterProtoChunks

This commit is contained in:
embeddedt 2026-03-01 15:46:52 -05:00
parent 30e3deb8e2
commit 925c7526ee
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,22 @@
package org.embeddedt.modernfix.common.mixin.perf.compact_imposterprotochunks;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.lighting.ChunkSkyLightSources;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@Mixin(ChunkAccess.class)
public class ChunkAccessMixin {
@Shadow
@Final
@Mutable
protected LevelChunkSection[] sections;
@Shadow
protected ChunkSkyLightSources skyLightSources;
}

View File

@ -0,0 +1,22 @@
package org.embeddedt.modernfix.common.mixin.perf.compact_imposterprotochunks;
import net.minecraft.world.level.chunk.ImposterProtoChunk;
import net.minecraft.world.level.chunk.LevelChunk;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ImposterProtoChunk.class)
public abstract class ImposterProtoChunkMixin extends ChunkAccessMixin {
/**
* @author embeddedt
* @reason ImposterProtoChunks allocate their own LevelChunkSection objects etc. which wastes quite
* a bit of memory
*/
@Inject(method = "<init>", at = @At("RETURN"))
private void replaceDuplicateObjects(LevelChunk wrapped, boolean allowWrites, CallbackInfo ci) {
this.sections = wrapped.getSections();
this.skyLightSources = wrapped.getSkyLightSources();
}
}