From 91f3632a92856dc5e440507bc10c7eca7e6c5431 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 1 Jun 2017 22:54:12 +1000 Subject: [PATCH] Move death and block walkthrough handling to player movement handling, fixes #385 --- MCGalaxy/Player/Player.Handlers.cs | 11 ++++++++++- MCGalaxy/Server/Tasks/ServerTasks.cs | 6 ------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/MCGalaxy/Player/Player.Handlers.cs b/MCGalaxy/Player/Player.Handlers.cs index addd9bbea..59668cb84 100644 --- a/MCGalaxy/Player/Player.Handlers.cs +++ b/MCGalaxy/Player/Player.Handlers.cs @@ -301,7 +301,7 @@ namespace MCGalaxy { } void HandleMovement(byte[] packet) { - if (!loggedIn || trainGrab || following != "") return; + if (!loggedIn || trainGrab || following != "") { CheckBlocks(Pos); return; } if (HasCpeExt(CpeExt.HeldBlock)) { RawHeldBlock = ExtBlock.FromRaw(packet[1]); } @@ -320,6 +320,7 @@ namespace MCGalaxy { int offset = 8 + (hasExtPositions ? 6 : 0); byte yaw = packet[offset + 0], pitch = packet[offset + 1]; Position next = new Position(x, y, z); + CheckBlocks(next); if (Server.Countdown.HandlesMovement(this, next, yaw, pitch)) return; @@ -340,6 +341,14 @@ namespace MCGalaxy { if (IsAfk) CmdAfk.ToggleAfk(this, ""); } + void CheckBlocks(Position pos) { + Vec3U16 P = (Vec3U16)pos.BlockCoords; + if (level.Death) CheckSurvival(P.X, P.Y, P.Z); + + CheckBlock(); + oldIndex = level.PosToInt(P.X, P.Y, P.Z); + } + bool Moved() { return lastRot.RotY != Rot.RotY || lastRot.HeadX != Rot.HeadX; } internal void CheckSurvival(ushort x, ushort y, ushort z) { diff --git a/MCGalaxy/Server/Tasks/ServerTasks.cs b/MCGalaxy/Server/Tasks/ServerTasks.cs index a17677e5b..f6425ded7 100644 --- a/MCGalaxy/Server/Tasks/ServerTasks.cs +++ b/MCGalaxy/Server/Tasks/ServerTasks.cs @@ -60,12 +60,6 @@ namespace MCGalaxy.Tasks { p.possess = ""; } - Vec3U16 P = (Vec3U16)p.Pos.BlockCoords; - if (p.level.Death) - p.CheckSurvival(P.X, P.Y, P.Z); - p.CheckBlock(); - p.oldIndex = p.level.PosToInt(P.X, P.Y, P.Z); - SchedulerTask[] tasks = p.CriticalTasks.Items; for (int i = 0; i < tasks.Length; i++) { SchedulerTask task = tasks[i];