From 3551beb2298947480f76c36f616227abc0c437be Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 26 Nov 2023 01:28:29 +0100 Subject: [PATCH] fix: chunk loading, if chunks are not at 0 --- .../sculkpowered/server/entity/player/SculkPlayer.java | 4 ++-- .../server/protocol/packet/play/ConfirmTeleportation.java | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/io/github/sculkpowered/server/entity/player/SculkPlayer.java b/server/src/main/java/io/github/sculkpowered/server/entity/player/SculkPlayer.java index a0e98042..2a881792 100644 --- a/server/src/main/java/io/github/sculkpowered/server/entity/player/SculkPlayer.java +++ b/server/src/main/java/io/github/sculkpowered/server/entity/player/SculkPlayer.java @@ -411,7 +411,7 @@ public void calculateChunks(final Position from, final Position to, boolean chec public void calculateChunks(final Position from, final Position to, boolean check, boolean checkAlreadyLoaded, - int range, int oldRange) { + byte range, byte oldRange) { final var fromChunkX = chunkCoordinate(from.x()); final var fromChunkZ = chunkCoordinate(from.z()); final var chunkX = chunkCoordinate(to.x()); @@ -420,8 +420,8 @@ public void calculateChunks(final Position from, final Position to, if (fromChunkX == chunkX && fromChunkZ == chunkZ) { return; } - this.send(new CenterChunk(chunkX, chunkZ)); } + this.send(new CenterChunk(chunkX, chunkZ)); final var chunks = new ArrayList((range * 2 + 1) * (range * 2 + 1)); this.connection.forChunksInRange(chunkX, chunkZ, range, (x, z) -> { final var chunk = world.chunk(x, z); diff --git a/server/src/main/java/io/github/sculkpowered/server/protocol/packet/play/ConfirmTeleportation.java b/server/src/main/java/io/github/sculkpowered/server/protocol/packet/play/ConfirmTeleportation.java index 8cfd98dd..3acbd791 100644 --- a/server/src/main/java/io/github/sculkpowered/server/protocol/packet/play/ConfirmTeleportation.java +++ b/server/src/main/java/io/github/sculkpowered/server/protocol/packet/play/ConfirmTeleportation.java @@ -2,6 +2,7 @@ import io.github.sculkpowered.server.protocol.Buffer; import io.github.sculkpowered.server.protocol.packet.Packet; +import io.github.sculkpowered.server.protocol.packet.PacketHandler; public final class ConfirmTeleportation implements Packet { @@ -12,6 +13,11 @@ public void decode(Buffer buf) { this.teleportId = buf.readVarInt(); } + @Override + public boolean handle(PacketHandler handler) { + return handler.handle(this); + } + @Override public String toString() { return "ConfirmTeleportation{" +