Skip to content

Commit

Permalink
Detect block data addition/removal via client level rather than chunk…
Browse files Browse the repository at this point in the history
… cache
  • Loading branch information
embeddedt committed May 15, 2024
1 parent cead28f commit 8b9d76a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 53 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package me.jellysquid.mods.sodium.mixin.core.world.map;

import me.jellysquid.mods.sodium.client.render.chunk.map.ChunkStatus;
import me.jellysquid.mods.sodium.client.render.chunk.map.ChunkTracker;
import me.jellysquid.mods.sodium.client.render.chunk.map.ChunkTrackerHolder;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.LevelChunk;
import org.apache.commons.lang3.Validate;
import org.spongepowered.asm.mixin.Mixin;
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.callback.CallbackInfo;


@Mixin(ClientLevel.class)
Expand All @@ -17,4 +23,14 @@ public class ClientWorldMixin implements ChunkTrackerHolder {
public ChunkTracker sodium$getTracker() {
return Validate.notNull(this.chunkTracker);
}

@Inject(method = "onChunkLoaded", at = @At("RETURN"))
private void markLoaded(ChunkPos pChunkPos, CallbackInfo ci) {
this.chunkTracker.onChunkStatusAdded(pChunkPos.x, pChunkPos.z, ChunkStatus.FLAG_HAS_BLOCK_DATA);
}

@Inject(method = "unload", at = @At("RETURN"))
private void markUnloaded(LevelChunk chunk, CallbackInfo ci) {
this.chunkTracker.onChunkStatusRemoved(chunk.getPos().x, chunk.getPos().z, ChunkStatus.FLAG_HAS_BLOCK_DATA);
}
}

0 comments on commit 8b9d76a

Please sign in to comment.