From cf60df75e6f3c170a11f6311502c643053a7b0b1 Mon Sep 17 00:00:00 2001 From: HF Date: Sun, 15 Mar 2020 21:35:04 +0100 Subject: [PATCH] fixing client color check --- src/core/utils.js | 7 +++++-- src/ui/ChunkLoader2D.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/utils.js b/src/core/utils.js index b3de6bb..15df479 100644 --- a/src/core/utils.js +++ b/src/core/utils.js @@ -123,9 +123,12 @@ export function getPixelFromChunkOffset( return [x, y]; } -export function getCellInsideChunk(pixel: Cell): Cell { +export function getCellInsideChunk( + canvasSize: number, + pixel: Cell, +): Cell { // TODO assert is positive! - return pixel.map((x) => mod(x, TILE_SIZE)); + return pixel.map((x) => mod(x + canvasSize / 2, TILE_SIZE)); } export function screenToWorld( diff --git a/src/ui/ChunkLoader2D.js b/src/ui/ChunkLoader2D.js index 2654442..4eef3a0 100644 --- a/src/ui/ChunkLoader2D.js +++ b/src/ui/ChunkLoader2D.js @@ -72,7 +72,7 @@ class ChunkLoader { return 0; } return chunk.getColorIndex( - getCellInsideChunk([x, y]), + getCellInsideChunk(canvasSize, [x, y]), ); }