Reduce memory usage of ImposterProtoChunks
This commit is contained in:
parent
30e3deb8e2
commit
925c7526ee
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user