summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-07-30 21:59:35 +0200
committerHowaner <franzi.moos@googlemail.com>2014-07-30 21:59:35 +0200
commit89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04 (patch)
tree7d22e13df345884785abbc167a4818235fd61e0a /src/ClientHandle.cpp
parentMerged branch 'howaner/Options'. (diff)
downloadcuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.tar
cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.tar.gz
cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.tar.bz2
cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.tar.lz
cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.tar.xz
cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.tar.zst
cuberite-89b1bbdc5fca5a51df1a5dd18ce91f27cb667c04.zip
Diffstat (limited to '')
-rw-r--r--src/ClientHandle.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 30ec737be..849de2ce1 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -31,6 +31,7 @@
#include "Items/ItemSword.h"
#include "polarssl/md5.h"
+#include "BlockEntities/BeaconEntity.h"
@@ -659,6 +660,10 @@ void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString
// Client <-> Server branding exchange
SendPluginMessage("MC|Brand", "MCServer");
}
+ else if (a_Channel == "MC|Beacon")
+ {
+ HandleBeaconSelection(a_Message.c_str(), a_Message.size());
+ }
else if (a_Channel == "MC|ItemName")
{
HandleAnvilItemName(a_Message.c_str(), a_Message.size());
@@ -746,6 +751,55 @@ void cClientHandle::UnregisterPluginChannels(const AStringVector & a_ChannelList
+void cClientHandle::HandleBeaconSelection(const char * a_Data, size_t a_Length)
+{
+ if (a_Length < 14)
+ {
+ SendChat("Failure setting beacon selection; bad request", mtFailure);
+ LOGD("Malformed MC|Beacon packet.");
+ return;
+ }
+
+ cWindow * Window = m_Player->GetWindow();
+ if ((Window == NULL) || (Window->GetWindowType() != cWindow::wtBeacon))
+ {
+ return;
+ }
+ cBeaconWindow * BeaconWindow = (cBeaconWindow *) Window;
+
+ if (Window->GetSlot(*m_Player, 0)->IsEmpty())
+ {
+ return;
+ }
+
+ cByteBuffer Buffer(a_Length);
+ Buffer.Write(a_Data, a_Length);
+
+ int PrimaryPotionID, SecondaryPotionID;
+ Buffer.ReadBEInt(PrimaryPotionID);
+ Buffer.ReadBEInt(SecondaryPotionID);
+
+ cEntityEffect::eType PrimaryPotion = cEntityEffect::effNoEffect;
+ if ((PrimaryPotionID >= 0) && (PrimaryPotionID <= (int)cEntityEffect::effSaturation))
+ {
+ PrimaryPotion = (cEntityEffect::eType)PrimaryPotionID;
+ }
+
+ cEntityEffect::eType SecondaryPotion = cEntityEffect::effNoEffect;
+ if ((SecondaryPotionID >= 0) && (SecondaryPotionID <= (int)cEntityEffect::effSaturation))
+ {
+ SecondaryPotion = (cEntityEffect::eType)SecondaryPotionID;
+ }
+
+ Window->SetSlot(*m_Player, 0, cItem());
+ BeaconWindow->GetBeaconEntity()->SelectPrimaryPotion(PrimaryPotion);
+ BeaconWindow->GetBeaconEntity()->SelectSecondaryPotion(SecondaryPotion);
+}
+
+
+
+
+
void cClientHandle::HandleCommandBlockMessage(const char * a_Data, size_t a_Length)
{
if (a_Length < 14)