summaryrefslogtreecommitdiff
path: root/server/src/main/java/kz/ilotterytea/frogartha/server/ServerHandlers.java
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-01-22 01:00:49 +0500
committerilotterytea <iltsu@alright.party>2025-01-22 01:00:49 +0500
commitb3739521c1dcaed9bd451e00067b7d304521745f (patch)
tree04403d23708e2cdfa35452243323c9f24cde5e26 /server/src/main/java/kz/ilotterytea/frogartha/server/ServerHandlers.java
parenta7f77c115bc95eb8a667df1146cc26dc17367879 (diff)
feat: player direction is now calculated by server
Diffstat (limited to 'server/src/main/java/kz/ilotterytea/frogartha/server/ServerHandlers.java')
-rw-r--r--server/src/main/java/kz/ilotterytea/frogartha/server/ServerHandlers.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/server/src/main/java/kz/ilotterytea/frogartha/server/ServerHandlers.java b/server/src/main/java/kz/ilotterytea/frogartha/server/ServerHandlers.java
index 44162ae..b6dcc3c 100644
--- a/server/src/main/java/kz/ilotterytea/frogartha/server/ServerHandlers.java
+++ b/server/src/main/java/kz/ilotterytea/frogartha/server/ServerHandlers.java
@@ -4,8 +4,10 @@ import com.badlogic.gdx.math.Vector3;
import kz.ilotterytea.frogartha.FrogarthaConstants;
import kz.ilotterytea.frogartha.domain.Identity;
import kz.ilotterytea.frogartha.domain.PlayerState;
+import kz.ilotterytea.frogartha.domain.client.ChangedDirectionAction;
import kz.ilotterytea.frogartha.domain.client.PlayerJumpAction;
import kz.ilotterytea.frogartha.domain.server.Acknowledge;
+import kz.ilotterytea.frogartha.events.ChangedDirectionEvent;
import kz.ilotterytea.frogartha.events.PlayerJumpEvent;
import kz.ilotterytea.frogartha.exceptions.PlayerKickException;
import kz.ilotterytea.frogartha.utils.Logger;
@@ -59,4 +61,13 @@ public class ServerHandlers {
));
log.log("{} jumped from {} to {} with strength {}", player, startPosition, endPosition, action.getJumpStrength());
}
+
+ public static void handleChangedDirectionAction(PlayerConnection player, ChangedDirectionAction action) {
+ PlayerState state = player.getState();
+ Vector3 direction = action.getDirection();
+
+ state.setDirection(direction.x, state.getPosition().y, direction.z);
+
+ player.send(new ChangedDirectionEvent(player.getId(), state.getDirection()));
+ }
}