From e916c8b232624ddbf028cae7daa821c6cd6edf51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=80=E5=93=A5?= <3523206925@qq.com> Date: Tue, 8 Aug 2023 20:47:13 +0800 Subject: [PATCH] test: fix up test --- .../java/cn/allay/server/AllayServer.java | 1 - .../cn/allay/server/client/AllayClient.java | 30 +++++++++---------- .../entity/AllayEntityPhysicsService.java | 4 --- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/Allay-Server/src/main/java/cn/allay/server/AllayServer.java b/Allay-Server/src/main/java/cn/allay/server/AllayServer.java index b4cc4f079..4a150fb8d 100644 --- a/Allay-Server/src/main/java/cn/allay/server/AllayServer.java +++ b/Allay-Server/src/main/java/cn/allay/server/AllayServer.java @@ -107,7 +107,6 @@ private void loadWorlds() { .worldData(worldData) .setWorldGenerator(new FlatWorldGenerator()) .setWorldStorage(new AllayNonPersistentWorldStorage()) - .setWorldType(WorldType.FLAT) .build()); } diff --git a/Allay-Server/src/main/java/cn/allay/server/client/AllayClient.java b/Allay-Server/src/main/java/cn/allay/server/client/AllayClient.java index 8e3b0f821..27578017a 100644 --- a/Allay-Server/src/main/java/cn/allay/server/client/AllayClient.java +++ b/Allay-Server/src/main/java/cn/allay/server/client/AllayClient.java @@ -519,29 +519,27 @@ public PacketSignal handle(SubChunkRequestPacket packet) { return PacketSignal.HANDLED; } - @Override - public PacketSignal handle(MovePlayerPacket packet) { - var pos = packet.getPosition(); - var rot = packet.getRotation(); - playerEntity.setLocation(new Location3d( - pos.getX(), - pos.getY(), - pos.getZ(), - rot.getX(), - rot.getY(), - rot.getZ(), - getLocation().world() - )); - return PacketSignal.HANDLED; - } - @Override public PacketSignal handle(PlayerAuthInputPacket packet) { + handleMovement(packet); handleBlockAction(packet.getPlayerActions()); handleInputData(packet.getInputData()); return PacketSignal.HANDLED; } + protected void handleMovement(PlayerAuthInputPacket packet) { + var newPos = packet.getPosition(); + var newRot = packet.getRotation(); + playerEntity.getLocation().world().getEntityPhysicsService() + .offerScheduledMove( + playerEntity, + new Location3d( + newPos.getX(), newPos.getY(), newPos.getZ(), + newRot.getX(), newRot.getY(), newRot.getZ(), + getLocation().world()) + ); + } + protected void handleBlockAction(List blockActions) { if (blockActions.isEmpty()) return; for (var action : blockActions) { diff --git a/Allay-Server/src/main/java/cn/allay/server/world/entity/AllayEntityPhysicsService.java b/Allay-Server/src/main/java/cn/allay/server/world/entity/AllayEntityPhysicsService.java index 0185bae6a..6ea211b62 100644 --- a/Allay-Server/src/main/java/cn/allay/server/world/entity/AllayEntityPhysicsService.java +++ b/Allay-Server/src/main/java/cn/allay/server/world/entity/AllayEntityPhysicsService.java @@ -8,12 +8,8 @@ import cn.allay.api.math.Location3dc; import cn.allay.api.world.World; import cn.allay.api.world.entity.EntityPhysicsService; -import com.google.common.collect.Sets; import it.unimi.dsi.fastutil.Pair; -import it.unimi.dsi.fastutil.booleans.BooleanObjectImmutablePair; import it.unimi.dsi.fastutil.doubles.DoubleBooleanImmutablePair; -import it.unimi.dsi.fastutil.doubles.DoubleBooleanMutablePair; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; import org.cloudburstmc.protocol.bedrock.packet.MoveEntityDeltaPacket; import org.joml.Vector2d; import org.joml.Vector3d;