summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchangyong guo <guo1487@163.com>2018-06-24 11:24:10 +0200
committerpeterbell10 <peterbell10@live.co.uk>2018-06-24 11:24:10 +0200
commit2d3013d1d35a2bcba63cffd9012898defff26f93 (patch)
treee344931e67b4094671e01a3bf7dca2d600e32d3e
parentFlush stdout after resetting console colour. (#4240) (diff)
downloadcuberite-2d3013d1d35a2bcba63cffd9012898defff26f93.tar
cuberite-2d3013d1d35a2bcba63cffd9012898defff26f93.tar.gz
cuberite-2d3013d1d35a2bcba63cffd9012898defff26f93.tar.bz2
cuberite-2d3013d1d35a2bcba63cffd9012898defff26f93.tar.lz
cuberite-2d3013d1d35a2bcba63cffd9012898defff26f93.tar.xz
cuberite-2d3013d1d35a2bcba63cffd9012898defff26f93.tar.zst
cuberite-2d3013d1d35a2bcba63cffd9012898defff26f93.zip
-rw-r--r--CONTRIBUTORS1
-rw-r--r--Server/Plugins/APIDump/APIDesc.lua10
-rw-r--r--src/ClientHandle.cpp9
-rw-r--r--src/Entities/Entity.h3
-rw-r--r--src/Entities/Player.h3
5 files changed, 25 insertions, 1 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 35d8496b4..b888c83cf 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -13,6 +13,7 @@ beeduck
bibo38
birkett (Anthony Birkett)
Bond_009
+changyongGuo
Cocosushi6
derouinw
Diusrex
diff --git a/Server/Plugins/APIDump/APIDesc.lua b/Server/Plugins/APIDump/APIDesc.lua
index eed6bd40f..ee1ed0d04 100644
--- a/Server/Plugins/APIDump/APIDesc.lua
+++ b/Server/Plugins/APIDump/APIDesc.lua
@@ -3317,6 +3317,16 @@ local Hash = cCryptoHash.sha1HexString("DataToHash")
},
Notes = "Returns the weapon that the entity has equipped. Returns an empty cItem if no weapon equipped or not applicable.",
},
+ GetOffHandEquipedItem =
+ {
+ Returns =
+ {
+ {
+ Type = "cItem",
+ },
+ },
+ Notes = "Returns the item that the entity has equipped on off-hand. Returns an empty cItem if no item equipped or not applicable.",
+ },
GetGravity =
{
Returns =
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index a895dd3b3..ff649ea4d 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1188,7 +1188,14 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
case DIG_STATUS_SWAP_ITEM_IN_HAND:
{
- // TODO: Not yet implemented
+
+ cItem EquippedItem = m_Player->GetEquippedItem();
+ cItem OffhandItem = m_Player->GetOffHandEquipedItem();
+
+ cInventory & Intentory = m_Player->GetInventory();
+ Intentory.SetShieldSlot(EquippedItem);
+ Intentory.SetHotbarSlot(Intentory.GetEquippedSlotNum(), OffhandItem);
+
return;
}
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 9abf75968..7ac12c95b 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -351,6 +351,9 @@ public:
/** Returns the currently equipped boots; empty item if none */
virtual cItem GetEquippedBoots(void) const { return cItem(); }
+ /** Returns the currently offhand equipped item; empty item if none */
+ virtual cItem GetOffHandEquipedItem(void) const { return cItem(); }
+
/** Applies damage to the armor after the armor blocked the given amount */
virtual void ApplyArmorDamage(int DamageBlocked);
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 32a4b0348..f04f90a2b 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -71,6 +71,9 @@ public:
/** Returns the currently equipped boots; empty item if none */
virtual cItem GetEquippedBoots(void) const override { return m_Inventory.GetEquippedBoots(); }
+ /** Returns the currently offhand equipped item; empty item if none */
+ virtual cItem GetOffHandEquipedItem(void) const override { return m_Inventory.GetShieldSlot(); }
+
virtual void ApplyArmorDamage(int DamageBlocked) override;
// tolua_begin