Permalink
Browse files

Fix preciserespawn debacle in ClassicalSharp

  • Loading branch information...
Goodlyay committed Jan 7, 2019
1 parent 9e313bd commit 790b1c094c961588303471f498e75be291168151
Showing with 9 additions and 8 deletions.
  1. +0 −3 ClassicalSharp/Entities/Components/HacksComponent.cs
  2. +9 −5 ClassicalSharp/Entities/LocalPlayer.cs
@@ -33,7 +33,6 @@ public sealed class HacksComponent {
public bool CanSpeed = true;
public bool CanFly = true;
public bool CanRespawn = true;
public bool CanPreciseRespawn = false;
public bool CanNoclip = true;
public bool CanPushbackBlocks = true;
public bool CanSeeAllNames = true;
@@ -139,7 +138,6 @@ public sealed class HacksComponent {
public void UpdateHacksState() {
SetAllHacks(true);
CanBePushed = true;
CanPreciseRespawn = false;
if (HacksFlags == null) return;

// By default (this is also the case with WoM), we can use hacks.
@@ -149,7 +147,6 @@ public sealed class HacksComponent {
ParseFlag(ref CanNoclip, "noclip");
ParseFlag(ref CanSpeed, "speed");
ParseFlag(ref CanRespawn, "respawn");
ParseFlag(ref CanPreciseRespawn, "preciserespawn");
ParseFlag(ref CanBePushed, "push");

if (UserType == 0x64) ParseAllFlag("ophax");
@@ -180,7 +180,7 @@ public class LocalPlayer : Player, IGameComponent {
AABB bb;

// Spawn player at highest valid position
if (!Hacks.CanPreciseRespawn) {
if (Hacks.CanAnyHacks) {
if (game.World.IsValidPos(P)) {
bb = AABB.Make(spawn, Size);
for (int y = P.Y; y <= game.World.Height; y++) {
@@ -196,7 +196,7 @@ public class LocalPlayer : Player, IGameComponent {
}
}

if (!Hacks.CanPreciseRespawn) { spawn.Y += 2/16f; }
spawn.Y += 2/16f;
LocationUpdate update = LocationUpdate.MakePosAndOri(spawn, SpawnRotY, SpawnHeadX, false);
SetLocation(update, false);
Velocity = Vector3.Zero;
@@ -208,7 +208,7 @@ public class LocalPlayer : Player, IGameComponent {
}

bool HandleRespawn() {
if (Hacks.CanRespawn || Hacks.CanPreciseRespawn) {
if (Hacks.CanRespawn) {
DoRespawn();
return true;
} else if (!warnedRespawn) {
@@ -219,8 +219,12 @@ public class LocalPlayer : Player, IGameComponent {
}

bool HandleSetSpawn() {
if (Hacks.CanRespawn || Hacks.CanPreciseRespawn) {
if (Hacks.CanPreciseRespawn) {
if (Hacks.CanRespawn) {
if (!Hacks.CanAnyHacks && !onGround) {
game.Chat.Add("&cCannot set spawn mid-air while hacks are disabled");
return false;
}
if (!Hacks.CanAnyHacks) {
Spawn.X = Position.X;
Spawn.Y = Position.Y;
Spawn.Z = Position.Z;

0 comments on commit 790b1c0

Please sign in to comment.