Skip to content

Commit

Permalink
Optimize zero offset
Browse files Browse the repository at this point in the history
  • Loading branch information
cavallium committed Jun 7, 2022
1 parent 14c3495 commit d8bace5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public int getZChunk() {
return ((int) z) / 16;
}

public boolean isZero() {
return x == 0 && z == 0;
}

public void validate() {
if ((int) (Math.round(x / 16f) * 16) != x) {
throw new IllegalArgumentException("x is not aligned with the chunks!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public static void incoming(Logger logger, final PacketContainer packet, final P
}
CoordinateOffset offset = PlayerManager.getOffsetOrJoinPlayer(player, player.getWorld());
Objects.requireNonNull(offset);
if (offset.isZero()) {
return;
}
switch (packet.getType().name()) {
case "POSITION":
case "VEHICLE_MOVE":
Expand Down

0 comments on commit d8bace5

Please sign in to comment.