From 2ad026310166db84ec4f2afa6dbb65227c395f14 Mon Sep 17 00:00:00 2001 From: TheMode Date: Tue, 13 Jul 2021 18:10:34 +0200 Subject: [PATCH] Inline ChunkUtils#retrieve to avoid computing chunk coordinate twice --- .../java/net/minestom/server/utils/chunk/ChunkUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minestom/server/utils/chunk/ChunkUtils.java b/src/main/java/net/minestom/server/utils/chunk/ChunkUtils.java index f4d5df895..e8cc4c664 100644 --- a/src/main/java/net/minestom/server/utils/chunk/ChunkUtils.java +++ b/src/main/java/net/minestom/server/utils/chunk/ChunkUtils.java @@ -90,7 +90,11 @@ public final class ChunkUtils { } public static Chunk retrieve(Instance instance, Chunk originChunk, double x, double z) { - return ChunkUtils.same(originChunk, x, z) ? originChunk : instance.getChunkAt(x, z); + final int chunkX = getChunkCoordinate(x); + final int chunkZ = getChunkCoordinate(z); + final boolean sameChunk = originChunk.getChunkX() == chunkX && + originChunk.getChunkZ() == chunkZ; + return sameChunk ? originChunk : instance.getChunk(chunkX, chunkZ); } public static Chunk retrieve(Instance instance, Chunk originChunk, Point position) {