summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-11-15 01:36:15 +0100
committerHowaner <franzi.moos@googlemail.com>2014-11-15 01:36:15 +0100
commit98d5ef978b02e37bc7c027126b050684348461ee (patch)
tree2b620382584ccc8f755fc7490c4beb486e2c1ffb
parentAPIDump: Fixed example cCompositeChat URL (diff)
downloadcuberite-98d5ef978b02e37bc7c027126b050684348461ee.tar
cuberite-98d5ef978b02e37bc7c027126b050684348461ee.tar.gz
cuberite-98d5ef978b02e37bc7c027126b050684348461ee.tar.bz2
cuberite-98d5ef978b02e37bc7c027126b050684348461ee.tar.lz
cuberite-98d5ef978b02e37bc7c027126b050684348461ee.tar.xz
cuberite-98d5ef978b02e37bc7c027126b050684348461ee.tar.zst
cuberite-98d5ef978b02e37bc7c027126b050684348461ee.zip
-rw-r--r--src/BlockID.h14
-rw-r--r--src/BlockInfo.cpp1
-rw-r--r--src/Blocks/BlockButton.h6
-rw-r--r--src/Blocks/BlockFence.h30
-rw-r--r--src/Blocks/BlockHandler.cpp2
-rw-r--r--src/Blocks/CMakeLists.txt1
-rw-r--r--src/ClientHandle.cpp258
-rw-r--r--src/ClientHandle.h6
-rw-r--r--src/Protocol/Protocol17x.cpp6
-rw-r--r--src/Protocol/Protocol18x.cpp33
-rw-r--r--src/Protocol/Protocol18x.h2
11 files changed, 177 insertions, 182 deletions
diff --git a/src/BlockID.h b/src/BlockID.h
index 24de2dc8a..eaed0ecdd 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -484,13 +484,13 @@ enum
E_META_BREWING_STAND_FILLED_SLOT_XM_ZM = 4,
// E_BLOCK_BUTTON metas
- E_BLOCK_BUTTON_YM = 0,
- E_BLOCK_BUTTON_XP = 1,
- E_BLOCK_BUTTON_XM = 2,
- E_BLOCK_BUTTON_ZP = 3,
- E_BLOCK_BUTTON_ZM = 4,
- E_BLOCK_BUTTON_YP = 5,
- E_BLOCK_BUTTON_PRESSED = 8,
+ E_META_BUTTON_YM = 0,
+ E_META_BUTTON_XP = 1,
+ E_META_BUTTON_XM = 2,
+ E_META_BUTTON_ZP = 3,
+ E_META_BUTTON_ZM = 4,
+ E_META_BUTTON_YP = 5,
+ E_META_BUTTON_PRESSED = 8,
// E_BLOCK_CARPET metas:
E_META_CARPET_WHITE = 0,
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index bcab21e77..c5158f098 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -774,6 +774,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_JUNGLE_DOOR ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_ACACIA_DOOR ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_DARK_OAK_DOOR ].m_PlaceSound = "dig.wood";
+ a_Info[E_BLOCK_WOODEN_BUTTON ].m_PlaceSound = "dig.wood";
}
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index 8e4f04740..3cb6afffb 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -99,6 +99,12 @@ public:
return (a_RelY > 0) && (cBlockInfo::FullyOccupiesVoxel(BlockIsOn));
}
+
+ virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
+ {
+ // Sends the button back to the client.
+ a_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
+ }
} ;
diff --git a/src/Blocks/BlockFence.h b/src/Blocks/BlockFence.h
new file mode 100644
index 000000000..d79d840a0
--- /dev/null
+++ b/src/Blocks/BlockFence.h
@@ -0,0 +1,30 @@
+
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockFenceHandler :
+ public cBlockHandler
+{
+ typedef cBlockHandler super;
+public:
+
+ cBlockFenceHandler(BLOCKTYPE a_BlockType) :
+ super(a_BlockType)
+ {
+ }
+
+
+ virtual bool IsUseable(void) override
+ {
+ return true;
+ }
+};
+
+
+
+
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 60f13a747..f149685f8 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -28,6 +28,7 @@
#include "BlockEnderchest.h"
#include "BlockEntity.h"
#include "BlockFarmland.h"
+#include "BlockFence.h"
#include "BlockFenceGate.h"
#include "BlockFire.h"
#include "BlockFlower.h"
@@ -220,6 +221,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_ENCHANTMENT_TABLE: return new cBlockEnchantmentTableHandler(a_BlockType);
case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler (a_BlockType);
+ case E_BLOCK_FENCE: return new cBlockFenceHandler (a_BlockType);
case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType);
case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType);
diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt
index eed949aab..6eddb03ff 100644
--- a/src/Blocks/CMakeLists.txt
+++ b/src/Blocks/CMakeLists.txt
@@ -35,6 +35,7 @@ SET (HDRS
BlockEnderchest.h
BlockEntity.h
BlockFarmland.h
+ BlockFence.h
BlockFenceGate.h
BlockFire.h
BlockFlower.h
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 94bace43a..a4be87fd1 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -960,22 +960,14 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
/* Check for clickthrough-blocks:
When the user breaks a fire block, the client send the wrong block location.
We must find the right block with the face direction. */
- int BlockX = a_BlockX;
- int BlockY = a_BlockY;
- int BlockZ = a_BlockZ;
- AddFaceDirection(BlockX, BlockY, BlockZ, a_BlockFace);
- if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(BlockX, BlockY, BlockZ))->IsClickedThrough())
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true);
+ BLOCKTYPE Block = m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ if (!cBlockInfo::GetHandler(Block)->IsClickedThrough())
{
- a_BlockX = BlockX;
- a_BlockY = BlockY;
- a_BlockZ = BlockZ;
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false);
}
- if (
- ((Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) ||
- (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) ||
- (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6))
- )
+ if ((Vector3i(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() > 6)
{
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
return;
@@ -1012,7 +1004,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
m_Player->AbortEating();
return;
}
- else
+ else if (m_Player->GetEquippedItem().m_ItemType == E_ITEM_BOW)
{
if (PlgMgr->CallHookPlayerShooting(*m_Player))
{
@@ -1234,145 +1226,149 @@ void cClientHandle::FinishDigAnimation()
void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem)
{
- // TODO: Rewrite this function
-
LOGD("HandleRightClick: {%d, %d, %d}, face %d, HeldItem: %s",
a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, ItemToFullString(a_HeldItem).c_str()
);
-
- cWorld * World = m_Player->GetWorld();
- bool AreRealCoords = (Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() <= 5;
- if (
- (a_BlockFace != BLOCK_FACE_NONE) && // The client is interacting with a specific block
- IsValidBlock(a_HeldItem.m_ItemType) &&
- !AreRealCoords
- )
+ // Check equipped item.
+ const cItem & Equipped = m_Player->GetInventory().GetEquippedItem();
+ if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1))
{
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- if ((a_BlockX != -1) && (a_BlockY >= 0) && (a_BlockZ != -1))
- {
- World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
- if (a_BlockY < cChunkDef::Height - 1)
- {
- World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things
- }
- if (a_BlockY > 0)
- {
- World->SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, m_Player); // 2 block high things
- }
- }
- m_Player->GetInventory().SendEquippedSlot();
+ // Only compare ItemType, not meta (torches have different metas)
+ // The -1 check is there because sometimes the client sends -1 instead of the held item
+ // Ref.: http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502
+ LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)",
+ m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType
+ );
+
+ AbortRightClick(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
return;
}
- if (!AreRealCoords)
+ cPluginManager * PlgManager = cRoot::Get()->GetPluginManager();
+
+ if (PlgManager->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
{
- a_BlockFace = BLOCK_FACE_NONE;
+ AbortRightClick(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ return;
}
- cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
- if (PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
+ // Check block interactions ticks:
{
- // A plugin doesn't agree with the action, replace the block on the client and quit:
- if (AreRealCoords)
+ m_NumBlockChangeInteractionsThisTick++;
+ if (!CheckBlockInteractionsRate())
{
- cChunkInterface ChunkInterface(World->GetChunkMap());
- BLOCKTYPE BlockType = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType);
- BlockHandler->OnCancelRightClick(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
-
- if (a_BlockFace != BLOCK_FACE_NONE)
- {
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
- World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things
- m_Player->GetInventory().SendEquippedSlot();
- }
+ Kick("Too many blocks were placed/interacted with per unit time - hacked client?");
+ return;
}
- return;
}
- m_NumBlockChangeInteractionsThisTick++;
-
- if (!CheckBlockInteractionsRate())
- {
- Kick("Too many blocks were placed/interacted with per unit time - hacked client?");
- return;
- }
-
- const cItem & Equipped = m_Player->GetInventory().GetEquippedItem();
+ cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType);
+ cWorld * World = m_Player->GetWorld();
+ cChunkInterface ChunkInterface(World->GetChunkMap());
- if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1))
+ if (a_BlockFace != BLOCK_FACE_NONE)
{
- // Only compare ItemType, not meta (torches have different metas)
- // The -1 check is there because sometimes the client sends -1 instead of the held item
- // Ref.: http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502
- LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)",
- m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType
- );
-
- // Let's send the current world block to the client, so that it can immediately "let the user know" that they haven't placed the block
- if (a_BlockFace != BLOCK_FACE_NONE)
+ // The client is interacting with a block.
+
+ // First test if the interacted block is a clickable block (like buttons)
+ if (!m_Player->IsCrouched())
{
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
- }
- return;
- }
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta);
+ cBlockHandler * Handler = cBlockInfo::GetHandler(BlockType);
- if (AreRealCoords)
- {
- BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta);
- cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType);
+ if (Handler->IsUseable())
+ {
+ // Test the coordinates:
+ if ((Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() > 6)
+ {
+ Handler->OnCancelRightClick(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ return;
+ }
- if (BlockHandler->IsUseable() && !m_Player->IsCrouched())
+ if (PlgManager->CallHookPlayerUsingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta))
+ {
+ // A plugin doesn't agree with using the block, abort.
+ Handler->OnCancelRightClick(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ return;
+ }
+
+ Handler->OnUse(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ);
+ PlgManager->CallHookPlayerUsedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
+ return;
+ }
+ }
+
+ // Then test if the block is placeable
+ if (ItemHandler->IsPlaceable())
{
- if (PlgMgr->CallHookPlayerUsingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta))
+ // Test the coordinates:
+ if ((Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() > 6)
{
- // A plugin doesn't agree with using the block, abort
+ AbortRightClick(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
return;
}
- cChunkInterface ChunkInterface(World->GetChunkMap());
- BlockHandler->OnUse(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ);
- PlgMgr->CallHookPlayerUsedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
+
+ HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
return;
}
}
-
- short EquippedDamage = Equipped.m_ItemDamage;
- cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType);
-
- if (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE))
- {
- HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
- }
- else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage)))
+
+ if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(Equipped.m_ItemDamage))
{
- if ((m_Player->IsSatiated() || m_Player->IsGameModeCreative()) &&
- ItemHandler->IsFood() && (Equipped.m_ItemType != E_ITEM_GOLDEN_APPLE))
+ if ((m_Player->IsSatiated() || m_Player->IsGameModeCreative()) && ItemHandler->IsFood() && (Equipped.m_ItemType != E_ITEM_GOLDEN_APPLE))
{
// The player is satiated or in creative, and trying to eat
return;
}
+
m_Player->StartEating();
- if (PlgMgr->CallHookPlayerEating(*m_Player))
+ if (PlgManager->CallHookPlayerEating(*m_Player))
{
// A plugin won't let us eat, abort (send the proper packets to the client, too):
m_Player->AbortEating();
}
+ return;
}
- else
+
+ // -> No special right click.
+ if (PlgManager->CallHookPlayerUsingItem(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
+ {
+ // A plugin doesn't agree with using the item, abort
+ return;
+ }
+
+ ItemHandler->OnItemUse(World, m_Player, Equipped, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ PlgManager->CallHookPlayerUsedItem(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ);
+}
+
+
+
+
+
+void cClientHandle::AbortRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
+{
+ m_Player->GetInventory().SendEquippedSlot();
+
+ if ((a_BlockFace != BLOCK_FACE_NONE) && (a_BlockY >= 0) && (a_BlockY < cChunkDef::Height))
{
- if (PlgMgr->CallHookPlayerUsingItem(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
+ cBlockHandler * Handler = cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY, a_BlockZ));
+ if (!m_Player->IsCrouched() && Handler->IsUseable())
{
- // A plugin doesn't agree with using the item, abort
- return;
+ cChunkInterface ChunkInterface(m_Player->GetWorld()->GetChunkMap());
+ Handler->OnCancelRightClick(ChunkInterface, *m_Player->GetWorld(), m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ }
+ else if (Handler->DoesIgnoreBuildCollision())
+ {
+ m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
+ }
+ else
+ {
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
}
- ItemHandler->OnItemUse(World, m_Player, Equipped, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- PlgMgr->CallHookPlayerUsedItem(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ);
}
}
@@ -1516,7 +1512,6 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e
}
World->BroadcastSoundEffect(PlaceSound, a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5, Volume, Pitch);
-
cRoot::Get()->GetPluginManager()->CallHookPlayerPlacedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
}
@@ -1583,45 +1578,6 @@ void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_
-void cClientHandle::HandleAnimation(char a_Animation)
-{
- if (cPluginManager::Get()->CallHookPlayerAnimation(*m_Player, a_Animation))
- {
- // Plugin disagrees, bail out
- return;
- }
-
- // Because the animation ID sent to servers by clients are different to those sent back, we need this
- switch (a_Animation)
- {
- case 0: // No animation - wiki.vg doesn't say that client has something specific for it, so I suppose it will just become -1
- case 1:
- case 2:
- case 3:
- {
- a_Animation--; // Offset by -1
- break;
- }
- case 5:
- case 6:
- case 7:
- {
- a_Animation -= 2; // Offset by -2
- break;
- }
- default: // Anything else is the same
- {
- break;
- }
- }
-
- m_Player->GetWorld()->BroadcastEntityAnimation(*m_Player, a_Animation, this);
-}
-
-
-
-
-
void cClientHandle::HandleSlotSelected(short a_SlotNum)
{
m_Player->GetInventory().SetEquippedSlotNum(a_SlotNum);
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 082ed2fcc..f8b5bcb5b 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -246,9 +246,6 @@ public:
void PacketBufferFull(void);
void PacketUnknown(UInt32 a_PacketType);
void PacketError(unsigned char a_PacketType);
-
- // Calls that cProtocol descendants use for handling packets:
- void HandleAnimation(char a_Animation);
/** Called when the protocol receives a MC|ItemName plugin message, indicating that the player named
an item in the anvil UI. */
@@ -443,6 +440,9 @@ private:
UInt32 m_ProtocolVersion;
+ /** Handles the block resending part if the right click failed. */
+ void AbortRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace);
+
/** Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) */
void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler);
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 1d108ce9c..47918b5d8 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -1841,7 +1841,11 @@ void cProtocol172::HandlePacketAnimation(cByteBuffer & a_ByteBuffer)
{
HANDLE_READ(a_ByteBuffer, ReadBEInt, int, EntityID);
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Animation);
- m_Client->HandleAnimation(Animation);
+
+ if (Animation == 1)
+ {
+ m_Client->GetPlayer()->GetWorld()->BroadcastEntityAnimation(*m_Client->GetPlayer(), 0, m_Client);
+ }
}
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index 8170a494f..28906c7fa 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -1883,7 +1883,7 @@ bool cProtocol180::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
case 0x07: HandlePacketBlockDig (a_ByteBuffer); return true;
case 0x08: HandlePacketBlockPlace (a_ByteBuffer); return true;
case 0x09: HandlePacketSlotSelect (a_ByteBuffer); return true;
- case 0x0a: HandlePacketAnimation (a_ByteBuffer); return true;
+ case 0xa: HandlePacketAnimation (a_ByteBuffer); return true;
case 0x0b: HandlePacketEntityAction (a_ByteBuffer); return true;
case 0x0c: HandlePacketSteerVehicle (a_ByteBuffer); return true;
case 0x0d: HandlePacketWindowClose (a_ByteBuffer); return true;
@@ -2085,17 +2085,6 @@ void cProtocol180::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
-void cProtocol180::HandlePacketAnimation(cByteBuffer & a_ByteBuffer)
-{
- HANDLE_READ(a_ByteBuffer, ReadBEInt, int, EntityID);
- HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Animation);
- m_Client->HandleAnimation(Animation);
-}
-
-
-
-
-
void cProtocol180::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer)
{
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Status);
@@ -2122,11 +2111,8 @@ void cProtocol180::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
return;
}
- HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Face);
- if (Face == 255)
- {
- Face = 0;
- }
+ HANDLE_READ(a_ByteBuffer, ReadByte, Byte, FaceByte);
+ eBlockFace Face = (FaceByte == 255) ? BLOCK_FACE_NONE : static_cast<eBlockFace>(FaceByte);
cItem Item;
ReadItem(a_ByteBuffer, Item, 3);
@@ -2134,7 +2120,7 @@ void cProtocol180::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, CursorX);
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, CursorY);
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, CursorZ);
- m_Client->HandleRightClick(BlockX, BlockY, BlockZ, static_cast<eBlockFace>(Face), CursorX, CursorY, CursorZ, m_Client->GetPlayer()->GetEquippedItem());
+ m_Client->HandleRightClick(BlockX, BlockY, BlockZ, Face, CursorX, CursorY, CursorZ, m_Client->GetPlayer()->GetEquippedItem());
}
@@ -2215,6 +2201,15 @@ void cProtocol180::HandlePacketCreativeInventoryAction(cByteBuffer & a_ByteBuffe
+void cProtocol180::HandlePacketAnimation(cByteBuffer & a_ByteBuffer)
+{
+ m_Client->GetPlayer()->GetWorld()->BroadcastEntityAnimation(*m_Client->GetPlayer(), 0, m_Client);
+}
+
+
+
+
+
void cProtocol180::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer)
{
HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt32, PlayerID);
@@ -2431,7 +2426,7 @@ void cProtocol180::HandlePacketUseEntity(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, TargetY);
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, TargetZ);
- // TODO: Do anything
+ m_Client->GetPlayer()->GetWorld()->BroadcastEntityAnimation(*m_Client->GetPlayer(), 0, m_Client);
break;
}
default:
diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h
index 92d9825ef..77821358f 100644
--- a/src/Protocol/Protocol18x.h
+++ b/src/Protocol/Protocol18x.h
@@ -288,13 +288,13 @@ protected:
void HandlePacketLoginStart(cByteBuffer & a_ByteBuffer);
// Packet handlers while in the Game state (m_State == 3):
- void HandlePacketAnimation (cByteBuffer & a_ByteBuffer);
void HandlePacketBlockDig (cByteBuffer & a_ByteBuffer);
void HandlePacketBlockPlace (cByteBuffer & a_ByteBuffer);
void HandlePacketChatMessage (cByteBuffer & a_ByteBuffer);
void HandlePacketClientSettings (cByteBuffer & a_ByteBuffer);
void HandlePacketClientStatus (cByteBuffer & a_ByteBuffer);
void HandlePacketCreativeInventoryAction(cByteBuffer & a_ByteBuffer);
+ void HandlePacketAnimation (cByteBuffer & a_ByteBuffer);
void HandlePacketEntityAction (cByteBuffer & a_ByteBuffer);
void HandlePacketKeepAlive (cByteBuffer & a_ByteBuffer);
void HandlePacketPlayer (cByteBuffer & a_ByteBuffer);