Remove unused skyLightSources
There is no point in initialising the sources in Starlight, as we do not use them. Additionally, they are not saved to disk so we do not need them. Maintaining and initialising them is not a negligible cost, which is why they are being removed.
This commit is contained in:
@@ -3,12 +3,22 @@ package ca.spottedleaf.moonrise.mixin.starlight.chunk;
|
||||
import ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk;
|
||||
import ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.lighting.ChunkSkyLightSources;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ChunkAccess.class)
|
||||
public abstract class ChunkAccessMixin implements StarlightChunk {
|
||||
|
||||
@Shadow
|
||||
protected ChunkSkyLightSources skyLightSources;
|
||||
|
||||
|
||||
@Unique
|
||||
private volatile SWMRNibbleArray[] blockNibbles;
|
||||
|
||||
@@ -60,4 +70,31 @@ public abstract class ChunkAccessMixin implements StarlightChunk {
|
||||
public void setBlockEmptinessMap(final boolean[] emptinessMap) {
|
||||
this.blockEmptinessMap = emptinessMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Remove unused skylight sources
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Inject(
|
||||
method = "<init>",
|
||||
at = @At(
|
||||
value = "RETURN"
|
||||
)
|
||||
)
|
||||
private void nullSources(final CallbackInfo ci) {
|
||||
this.skyLightSources = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Remove unused skylight sources
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Redirect(
|
||||
method = "initializeLightSources",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/lighting/ChunkSkyLightSources;fillFrom(Lnet/minecraft/world/level/chunk/ChunkAccess;)V"
|
||||
)
|
||||
)
|
||||
private void skipInit(final ChunkSkyLightSources instance, final ChunkAccess chunkAccess) {}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package ca.spottedleaf.moonrise.mixin.starlight.chunk;
|
||||
import ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk;
|
||||
import ca.spottedleaf.moonrise.patches.starlight.light.StarLightEngine;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
@@ -10,10 +11,12 @@ import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.chunk.UpgradeData;
|
||||
import net.minecraft.world.level.levelgen.blending.BlendingData;
|
||||
import net.minecraft.world.level.lighting.ChunkSkyLightSources;
|
||||
import net.minecraft.world.ticks.LevelChunkTicks;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(LevelChunk.class)
|
||||
@@ -46,4 +49,20 @@ public abstract class LevelChunkMixin implements StarlightChunk {
|
||||
this.setBlockNibbles(StarLightEngine.getFilledEmptyLight(level));
|
||||
this.setSkyNibbles(StarLightEngine.getFilledEmptyLight(level));
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Remove unused skylight sources
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Redirect(
|
||||
method = "setBlockState",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/lighting/ChunkSkyLightSources;update(Lnet/minecraft/world/level/BlockGetter;III)Z"
|
||||
)
|
||||
)
|
||||
private boolean skipLightSources(final ChunkSkyLightSources instance, final BlockGetter blockGetter,
|
||||
final int x, final int y, final int z) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package ca.spottedleaf.moonrise.mixin.starlight.chunk;
|
||||
import ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk;
|
||||
import ca.spottedleaf.moonrise.patches.starlight.light.StarLightEngine;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
import net.minecraft.world.level.chunk.ImposterProtoChunk;
|
||||
@@ -10,10 +11,12 @@ import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.chunk.UpgradeData;
|
||||
import net.minecraft.world.level.levelgen.blending.BlendingData;
|
||||
import net.minecraft.world.level.lighting.ChunkSkyLightSources;
|
||||
import net.minecraft.world.ticks.ProtoChunkTicks;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ProtoChunk.class)
|
||||
@@ -34,4 +37,20 @@ public abstract class ProtoChunkMixin implements StarlightChunk {
|
||||
this.setBlockNibbles(StarLightEngine.getFilledEmptyLight(levelHeightAccessor));
|
||||
this.setSkyNibbles(StarLightEngine.getFilledEmptyLight(levelHeightAccessor));
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Remove unused skylight sources
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Redirect(
|
||||
method = "setBlockState",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/lighting/ChunkSkyLightSources;update(Lnet/minecraft/world/level/BlockGetter;III)Z"
|
||||
)
|
||||
)
|
||||
private boolean skipLightSources(final ChunkSkyLightSources instance, final BlockGetter blockGetter,
|
||||
final int x, final int y, final int z) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user