Skip to content

Commit

Permalink
Edit implementation of light update checking
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Jul 17, 2023
1 parent 12ff40c commit 7b7f629
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.network.packet.s2c.play.ChunkDataS2CPacket;
import net.minecraft.network.packet.s2c.play.UnloadChunkS2CPacket;
import net.minecraft.util.math.ChunkSectionPos;
import net.minecraft.world.LightType;
import net.minecraft.world.chunk.ChunkNibbleArray;
import net.minecraft.world.chunk.light.LightingProvider;
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(ClientPlayNetworkHandler.class)
Expand All @@ -17,6 +22,15 @@ private void postLoadChunk(ChunkDataS2CPacket packet, CallbackInfo ci) {
.onChunkAdded(packet.getX(), packet.getZ());
}

@Redirect(method = "updateLighting", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/light/LightingProvider;enqueueSectionData(Lnet/minecraft/world/LightType;Lnet/minecraft/util/math/ChunkSectionPos;Lnet/minecraft/world/chunk/ChunkNibbleArray;)V"))
private void postLightUpdate(LightingProvider instance, LightType lightType, ChunkSectionPos pos, ChunkNibbleArray nibbles) {
instance.enqueueSectionData(lightType, pos, nibbles);
if (nibbles != null) {
SodiumWorldRenderer.instance()
.onChunkLightAdded(pos.getX(), pos.getZ());
}
}

@Inject(method = "onUnloadChunk", at = @At("RETURN"))
private void postUnloadChunk(UnloadChunkS2CPacket packet, CallbackInfo ci) {
SodiumWorldRenderer.instance()
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/sodium.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"features.chunk_rendering.MixinClientChunkMap",
"features.chunk_rendering.MixinClientPlayNetworkHandler",
"features.chunk_rendering.MixinClientWorld",
"features.chunk_rendering.MixinLightingProvider",
"features.chunk_rendering.MixinPackedIntegerArray",
"features.chunk_rendering.MixinPalettedContainer",
"features.chunk_rendering.MixinWorldRenderer",
Expand Down

0 comments on commit 7b7f629

Please sign in to comment.