diff --git a/ClassicalSharp/Game/PickingHandler.cs b/ClassicalSharp/Game/PickingHandler.cs
index da3f79f21..74fc4311f 100644
--- a/ClassicalSharp/Game/PickingHandler.cs
+++ b/ClassicalSharp/Game/PickingHandler.cs
@@ -40,31 +40,25 @@ namespace ClassicalSharp {
int btns = (left ? 1 : 0) + (right ? 1 : 0) + (middle ? 1 : 0);
if (btns > 1 || game.Gui.ActiveScreen.HandlesAllInput || inv.Selected == Block.Invalid) return;
-
- // always play delete animations, even if we aren't picking a block.
- if (left) {
- game.HeldBlockRenderer.ClickAnim(true);
- byte id = game.Entities.GetClosetPlayer(game.LocalPlayer);
- if (id != EntityList.SelfID && game.Mode.PickEntity(id)) return;
- }
- if (!game.SelectedPos.Valid) return;
-
+
if (middle) {
Vector3I pos = game.SelectedPos.BlockPos;
- if (!game.World.IsValidPos(pos)) return;
+ if (!game.SelectedPos.Valid || !game.World.IsValidPos(pos)) return;
BlockID old = game.World.GetBlock(pos);
game.Mode.PickMiddle(old);
} else if (left) {
+ if (game.Mode.PickingLeft()) return;
Vector3I pos = game.SelectedPos.BlockPos;
- if (!game.World.IsValidPos(pos)) return;
+ if (!game.SelectedPos.Valid || !game.World.IsValidPos(pos)) return;
BlockID old = game.World.GetBlock(pos);
if (BlockInfo.Draw[old] == DrawType.Gas || !BlockInfo.CanDelete[old]) return;
game.Mode.PickLeft(old);
} else if (right) {
+ if (game.Mode.PickingRight()) return;
Vector3I pos = game.SelectedPos.TranslatedPos;
- if (!game.World.IsValidPos(pos)) return;
+ if (!game.SelectedPos.Valid || !game.World.IsValidPos(pos)) return;
BlockID old = game.World.GetBlock(pos);
BlockID block = inv.Selected;
diff --git a/ClassicalSharp/Mode/Creative.cs b/ClassicalSharp/Mode/Creative.cs
index b377474a5..97e7b98e4 100644
--- a/ClassicalSharp/Mode/Creative.cs
+++ b/ClassicalSharp/Mode/Creative.cs
@@ -33,6 +33,14 @@ namespace ClassicalSharp.Mode {
return false;
}
+ public bool PickingLeft() {
+ // always play delete animations, even if we aren't picking a block.
+ game.HeldBlockRenderer.ClickAnim(true);
+ return false;
+ }
+
+ public bool PickingRight() { return false; }
+
public void PickLeft(BlockID old) {
Vector3I pos = game.SelectedPos.BlockPos;
game.UpdateBlock(pos.X, pos.Y, pos.Z, Block.Air);
@@ -67,13 +75,10 @@ namespace ClassicalSharp.Mode {
game.UpdateBlock(pos.X, pos.Y, pos.Z, block);
game.UserEvents.RaiseBlockChanged(pos, old, block);
}
+
+ public Widget MakeHotbar() { return new HotbarWidget(game); }
- public bool PickEntity(byte id) { return false; }
- public Widget MakeHotbar() { return new HotbarWidget(game); }
-
-
- public void OnNewMapLoaded(Game game) {
- }
+ public void OnNewMapLoaded(Game game) { }
public void Init(Game game) {
this.game = game;
diff --git a/ClassicalSharp/Mode/IGameMode.cs b/ClassicalSharp/Mode/IGameMode.cs
index c8268897a..6478862d6 100644
--- a/ClassicalSharp/Mode/IGameMode.cs
+++ b/ClassicalSharp/Mode/IGameMode.cs
@@ -14,10 +14,11 @@ namespace ClassicalSharp.Mode {
public interface IGameMode : IGameComponent {
bool HandlesKeyDown(Key key);
+ bool PickingLeft();
+ bool PickingRight();
void PickLeft(BlockID old);
void PickMiddle(BlockID old);
- void PickRight(BlockID old, BlockID block);
- bool PickEntity(byte id);
+ void PickRight(BlockID old, BlockID block);
Widget MakeHotbar();
void BeginFrame(double delta);
void EndFrame(double delta);
diff --git a/ClassicalSharp/Mode/Survival.cs b/ClassicalSharp/Mode/Survival.cs
index cddddc021..9a01fda46 100644
--- a/ClassicalSharp/Mode/Survival.cs
+++ b/ClassicalSharp/Mode/Survival.cs
@@ -24,7 +24,29 @@ namespace ClassicalSharp.Mode {
public SurvivalGameMode() { invCount[8] = 10; } // tnt
- public bool HandlesKeyDown(Key key) { return false; }
+ public bool HandlesKeyDown(Key key) { return false; }
+
+ public bool PickingLeft() {
+ // always play delete animations, even if we aren't picking a block.
+ game.HeldBlockRenderer.ClickAnim(true);
+ byte id = game.Entities.GetClosetPlayer(game.LocalPlayer);
+ return id != EntityList.SelfID && PickEntity(id);
+ }
+
+ public bool PickingRight() {
+ if (game.Inventory.Selected == Block.RedMushroom) {
+ DepleteInventoryHeld();
+ game.LocalPlayer.Health -= 5;
+ CheckPlayerDied();
+ return true;
+ } else if (game.Inventory.Selected == Block.BrownMushroom) {
+ DepleteInventoryHeld();
+ game.LocalPlayer.Health += 5;
+ if (game.LocalPlayer.Health > 20) game.LocalPlayer.Health = 20;
+ return true;
+ }
+ return false;
+ }
public void PickLeft(BlockID old) {
Vector3I pos = game.SelectedPos.BlockPos;
@@ -33,8 +55,7 @@ namespace ClassicalSharp.Mode {
HandleDelete(old);
}
- public void PickMiddle(BlockID old) {
- }
+ public void PickMiddle(BlockID old) { }
public void PickRight(BlockID old, BlockID block) {
int index = game.Inventory.SelectedIndex, offset = game.Inventory.Offset;
@@ -43,7 +64,11 @@ namespace ClassicalSharp.Mode {
Vector3I pos = game.SelectedPos.TranslatedPos;
game.UpdateBlock(pos.X, pos.Y, pos.Z, block);
game.UserEvents.RaiseBlockChanged(pos, old, block);
-
+ DepleteInventoryHeld();
+ }
+
+ void DepleteInventoryHeld() {
+ int index = game.Inventory.SelectedIndex, offset = game.Inventory.Offset;
invCount[offset + index]--;
if (invCount[offset + index] != 0) return;
@@ -52,7 +77,7 @@ namespace ClassicalSharp.Mode {
game.Events.RaiseHeldBlockChanged();
}
- public bool PickEntity(byte id) {
+ bool PickEntity(byte id) {
Entity entity = game.Entities[id];
LocalPlayer p = game.LocalPlayer;
@@ -184,6 +209,11 @@ namespace ClassicalSharp.Mode {
}
wasOnGround = p.onGround;
+ CheckPlayerDied();
+ }
+
+ void CheckPlayerDied() {
+ LocalPlayer p = game.LocalPlayer;
if (p.Health <= 0 && !showedDeathScreen) {
showedDeathScreen = true;
game.Gui.SetNewScreen(new DeathScreen(game));
diff --git a/ClassicalSharp/Network/Utils/AsyncDownloader.cs b/ClassicalSharp/Network/Utils/AsyncDownloader.cs
index d38f7761e..7f3dd47e5 100644
--- a/ClassicalSharp/Network/Utils/AsyncDownloader.cs
+++ b/ClassicalSharp/Network/Utils/AsyncDownloader.cs
@@ -369,14 +369,11 @@ namespace ClassicalSharp.Network {
public DateTime TimeAdded;
/// Point in time the item was fully downloaded.
- public DateTime TimeDownloaded;
+ public DateTime TimeDownloaded;
/// Full URL this item was downloaded from.
public string Url;
- /// HTTP status code returned by the server for this request.
- public HttpStatusCode ResponseCode;
-
/// Unique identifier assigned by the server to this item.
public string ETag;
@@ -390,7 +387,6 @@ namespace ClassicalSharp.Network {
TimeAdded = timeAdded;
TimeDownloaded = DateTime.UtcNow;
Url = url;
- ResponseCode = code;
ETag = etag;
LastModified = lastModified;
}
diff --git a/Launcher2/WebService/IWebTask.cs b/Launcher2/WebService/IWebTask.cs
index fe83791af..6a54c7de0 100644
--- a/Launcher2/WebService/IWebTask.cs
+++ b/Launcher2/WebService/IWebTask.cs
@@ -56,7 +56,7 @@ namespace Launcher.Web {
request.KeepAlive = true;
request.CookieContainer = cookies;
- request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
+ request.AutomaticDecompression = DecompressionMethods.GZip;
if (data != null) {
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8;";
diff --git a/src/Client/Camera.c b/src/Client/Camera.c
index 2c627e78c..f47195c53 100644
--- a/src/Client/Camera.c
+++ b/src/Client/Camera.c
@@ -65,19 +65,19 @@ void PerspectiveCamera_RegrabMouse(void) {
delta = Point2D_Empty;
}
-#define sensiFactor (0.0002f / 3.0f * MATH_RAD2DEG)
-#define slippery 0.97f
-#define adjust 0.025f
+#define CAMERA_SENSI_FACTOR (0.0002f / 3.0f * MATH_RAD2DEG)
+#define CAMERA_SLIPPERY 0.97f
+#define CAMERA_ADJUST 0.025f
Real32 speedX = 0.0f, speedY = 0.0f;
void PerspectiveCamera_UpdateMouseRotation(void) {
- Real32 sensitivity = sensiFactor * Game_MouseSensitivity;
+ Real32 sensitivity = CAMERA_SENSI_FACTOR * Game_MouseSensitivity;
if (Game_SmoothCamera) {
- speedX += delta.X * adjust;
- speedX *= slippery;
- speedY += delta.Y * adjust;
- speedY *= slippery;
+ speedX += delta.X * CAMERA_ADJUST;
+ speedX *= CAMERA_SLIPPERY;
+ speedY += delta.Y * CAMERA_ADJUST;
+ speedY *= CAMERA_SLIPPERY;
} else {
speedX = (Real32)delta.X;
speedY = (Real32)delta.Y;
diff --git a/src/Client/Entity.c b/src/Client/Entity.c
index 91fb8d3a7..f8c239832 100644
--- a/src/Client/Entity.c
+++ b/src/Client/Entity.c
@@ -128,13 +128,12 @@ bool Entity_TouchesAnyWater(Entity* entity) {
}
-#define maxAngle (110 * MATH_DEG2RAD)
-#define armMax (60.0f * MATH_DEG2RAD)
-#define legMax (80.0f * MATH_DEG2RAD)
-#define idleMax (3.0f * MATH_DEG2RAD)
-#define idleXPeriod (2.0f * MATH_PI / 5.0f)
-#define idleZPeriod (2.0f * MATH_PI / 3.5f)
-
+#define ANIM_MAX_ANGLE (110 * MATH_DEG2RAD)
+#define ANIM_ARM_MAX (60.0f * MATH_DEG2RAD)
+#define ANIM_LEG_MAX (80.0f * MATH_DEG2RAD)
+#define ANIM_IDLE_MAX (3.0f * MATH_DEG2RAD)
+#define ANIM_IDLE_XPERIOD (2.0f * MATH_PI / 5.0f)
+#define ANIM_IDLE_ZPERIOD (2.0f * MATH_PI / 3.5f)
void AnimatedComp_DoTilt(Real32* tilt, bool reduce) {
if (reduce) {
@@ -147,8 +146,8 @@ void AnimatedComp_DoTilt(Real32* tilt, bool reduce) {
void AnimatedComp_PerpendicularAnim(AnimatedComp* anim, Real32 flapSpeed, Real32 idleXRot, Real32 idleZRot, bool left) {
Real32 verAngle = 0.5f + 0.5f * Math_Sin(anim->WalkTime * flapSpeed);
- Real32 zRot = -idleZRot - verAngle * anim->Swing * maxAngle;
- Real32 horAngle = Math_Cos(anim->WalkTime) * anim->Swing * armMax * 1.5f;
+ Real32 zRot = -idleZRot - verAngle * anim->Swing * ANIM_MAX_ANGLE;
+ Real32 horAngle = Math_Cos(anim->WalkTime) * anim->Swing * ANIM_ARM_MAX * 1.5f;
Real32 xRot = idleXRot + horAngle;
if (left) {
@@ -205,12 +204,12 @@ void AnimatedComp_GetCurrent(AnimatedComp* anim, Real32 t, bool calcHumanAnims)
anim->BobStrength = Math_Lerp(anim->BobStrengthO, anim->BobStrengthN, t);
Real32 idleTime = (Real32)Game_Accumulator;
- Real32 idleXRot = Math_Sin(idleTime * idleXPeriod) * idleMax;
- Real32 idleZRot = idleMax + Math_Cos(idleTime * idleZPeriod) * idleMax;
+ Real32 idleXRot = Math_Sin(idleTime * ANIM_IDLE_XPERIOD) * ANIM_IDLE_MAX;
+ Real32 idleZRot = ANIM_IDLE_MAX + Math_Cos(idleTime * ANIM_IDLE_ZPERIOD) * ANIM_IDLE_MAX;
- anim->LeftArmX = (Math_Cos(anim->WalkTime) * anim->Swing * armMax) - idleXRot;
+ anim->LeftArmX = (Math_Cos(anim->WalkTime) * anim->Swing * ANIM_ARM_MAX) - idleXRot;
anim->LeftArmZ = -idleZRot;
- anim->LeftLegX = -(Math_Cos(anim->WalkTime) * anim->Swing * legMax);
+ anim->LeftLegX = -(Math_Cos(anim->WalkTime) * anim->Swing * ANIM_LEG_MAX);
anim->LeftLegZ = 0;
anim->RightLegX = -anim->LeftLegX; anim->RightLegZ = -anim->LeftLegZ;