Move death and block walkthrough handling to player movement handling, fixes #385

This commit is contained in:
UnknownShadow200 2017-06-01 22:54:12 +10:00
parent 3f33038e55
commit 91f3632a92
2 changed files with 10 additions and 7 deletions

View File

@ -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) {

View File

@ -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];