Fixed players on cameras not being able to see block updates
@@ -4,6 +4,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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;
import net.geforcemods.securitycraft.entity.camera.SecurityCamera;
@@ -25,6 +26,14 @@ public abstract class ChunkMapMixin {
@Shadow
protected abstract void updateChunkTracking(ServerPlayer player, ChunkPos chunkPos, Packet<?>[] packetCache, boolean wasLoaded, boolean load);
+ @Redirect(method = "checkerboardDistance(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/server/level/ServerPlayer;Z)I", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;getLastSectionPos()Lnet/minecraft/core/SectionPos;"))
+ private static SectionPos redirectLastSectionPos(ServerPlayer player) {
+ if (PlayerUtils.isPlayerMountedOnCamera(player))
+ return SectionPos.of(player.getCamera());
+
+ return player.getLastSectionPos();
+ }
+
@Inject(method = "move", at = @At(value = "TAIL"))
private void trackCameraLoadedChunks(ServerPlayer player, CallbackInfo callback) {
if (PlayerUtils.isPlayerMountedOnCamera(player)) {
