From 3615ec2b909aea7c0e651d7c69f1b3a905ccdd48 Mon Sep 17 00:00:00 2001 From: AJ Ferguson Date: Mon, 10 Feb 2020 18:24:09 -0900 Subject: [PATCH] Fix ChunkPosition --- .../connector/world/chunk/ChunkPosition.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/world/chunk/ChunkPosition.java b/connector/src/main/java/org/geysermc/connector/world/chunk/ChunkPosition.java index 840e2f5d9..cafb7ab04 100644 --- a/connector/src/main/java/org/geysermc/connector/world/chunk/ChunkPosition.java +++ b/connector/src/main/java/org/geysermc/connector/world/chunk/ChunkPosition.java @@ -27,12 +27,14 @@ package org.geysermc.connector.world.chunk; import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @Getter @Setter @AllArgsConstructor +@EqualsAndHashCode public class ChunkPosition { private int x; @@ -43,16 +45,9 @@ public class ChunkPosition { } public Position getChunkBlock(int x, int y, int z) { - int chunkX = x % 16; - int chunkY = y % 16; - int chunkZ = z % 16; - - if (chunkX < 0) - chunkX = -chunkX; - if (chunkY < 0) - chunkY = -chunkY; - if (chunkZ < 0) - chunkZ = -chunkZ; + int chunkX = x & 15; + int chunkY = y & 15; + int chunkZ = z & 15; return new Position(chunkX, chunkY, chunkZ); }