summaryrefslogtreecommitdiffstats
path: root/source/ClientHandle.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-25 11:54:36 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-25 11:54:36 +0200
commitfb9a00a64ed69d22a1c181bb0b3af99f8686c4dd (patch)
tree1529d406bbbc97b1f1da6e2d0d1cccc7f1be5d9c /source/ClientHandle.cpp
parentSockets are now owned by SocketThreads instead of ClientHandle (FS #246 and FS #247) (diff)
downloadcuberite-fb9a00a64ed69d22a1c181bb0b3af99f8686c4dd.tar
cuberite-fb9a00a64ed69d22a1c181bb0b3af99f8686c4dd.tar.gz
cuberite-fb9a00a64ed69d22a1c181bb0b3af99f8686c4dd.tar.bz2
cuberite-fb9a00a64ed69d22a1c181bb0b3af99f8686c4dd.tar.lz
cuberite-fb9a00a64ed69d22a1c181bb0b3af99f8686c4dd.tar.xz
cuberite-fb9a00a64ed69d22a1c181bb0b3af99f8686c4dd.tar.zst
cuberite-fb9a00a64ed69d22a1c181bb0b3af99f8686c4dd.zip
Diffstat (limited to '')
-rw-r--r--source/ClientHandle.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index 2296ae23e..e32e03f16 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -91,6 +91,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance)
, m_LastStreamedChunkZ(0x7fffffff)
, m_ShouldCheckDownloaded(false)
, m_UniqueID(0)
+ , m_BlockDigAnim(-1)
{
m_Protocol = new cProtocolRecognizer(this);
@@ -534,9 +535,28 @@ void cClientHandle::HandleBlockDig(int a_BlockX, int a_BlockY, int a_BlockZ, cha
((a_Status == DIG_STATUS_STARTED) && (m_Player->GetGameMode() == 1))
);
+ if ((a_Status == DIG_STATUS_STARTED) && (m_Player->GetGameMode() != eGameMode_Creative))
+ {
+ // Start dig animation
+ // TODO: calculate real animation speed
+ m_BlockDigAnimSpeed = 10;
+ m_BlockDigX = a_BlockX;
+ m_BlockDigY = a_BlockY;
+ m_BlockDigZ = a_BlockZ;
+ m_BlockDigAnim = 0;
+ m_Player->GetWorld()->BroadcastBlockBreakAnimation(m_UniqueID, m_BlockDigX, m_BlockDigY, m_BlockDigZ, 0, this);
+ }
+ else if (m_BlockDigAnim != -1)
+ {
+ // End dig animation
+ m_BlockDigAnim = -1;
+ // It seems that 10 ends block animation
+ m_Player->GetWorld()->BroadcastBlockBreakAnimation(m_UniqueID, m_BlockDigX, m_BlockDigY, m_BlockDigZ, 10, this);
+ }
+
cItem & Equipped = m_Player->GetInventory().GetEquippedItem();
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemID);
-
+
if (bBroken)
{
ItemHandler->OnBlockDestroyed(World, m_Player, &Equipped, a_BlockX, a_BlockY, a_BlockZ);
@@ -550,7 +570,6 @@ void cClientHandle::HandleBlockDig(int a_BlockX, int a_BlockY, int a_BlockZ, cha
Handler->OnDigging(World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
ItemHandler->OnDiggingBlock(World, m_Player, &Equipped, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
-
// Check for clickthrough-blocks:
int pX = a_BlockX;
@@ -1049,6 +1068,21 @@ void cClientHandle::Tick(float a_Dt)
m_Protocol->SendKeepAlive(m_PingID);
m_LastPingTime = m_PingStartTime;
}
+
+ // Handle block break animation:
+ if ((m_Player != NULL) && (m_BlockDigAnim > -1))
+ {
+ int lastAnimVal = m_BlockDigAnim;
+ m_BlockDigAnim += (int)(m_BlockDigAnimSpeed * a_Dt);
+ if (m_BlockDigAnim > 9000)
+ {
+ m_BlockDigAnim = 9000;
+ }
+ if (m_BlockDigAnim / 1000 != lastAnimVal / 1000)
+ {
+ m_Player->GetWorld()->BroadcastBlockBreakAnimation(m_UniqueID, m_BlockDigX, m_BlockDigY, m_BlockDigZ, (char)(m_BlockDigAnim / 1000), this);
+ }
+ }
}
@@ -1418,6 +1452,15 @@ void cClientHandle::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int
+void cClientHandle::SendBlockBreakAnim(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage)
+{
+ m_Protocol->SendBlockBreakAnim(a_entityID, a_blockX, a_blockY, a_blockZ, a_stage);
+}
+
+
+
+
+
void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
{
// Check chunks being sent, erase them from m_ChunksToSend: