diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-01-15 23:36:19 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-01-15 23:36:19 +0100 |
commit | 3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0 (patch) | |
tree | e307ee5d190723f9c4cd8294458f823a522dd6e8 /src | |
parent | Merge pull request #545 from mc-server/VarArgs (diff) | |
download | cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.tar cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.tar.gz cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.tar.bz2 cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.tar.lz cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.tar.xz cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.tar.zst cuberite-3c31f2d8d8caa9660ab5a2ca67a658ff3cf47ee0.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/ClientHandle.cpp | 11 | ||||
-rw-r--r-- | src/Defines.h | 1 | ||||
-rw-r--r-- | src/Entities/Player.cpp | 11 |
3 files changed, 20 insertions, 3 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 9348a1825..fb7ea27d9 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -629,6 +629,17 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, ch return; } + case DIG_STATUS_DROP_STACK: + { + if (PlgMgr->CallHookPlayerTossingItem(*m_Player)) + { + // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch) + return; + } + m_Player->TossItem(false, 64); // Toss entire slot - if there aren't enough items, the maximum will be ejected + return; + } + default: { ASSERT(!"Unhandled DIG_STATUS"); diff --git a/src/Defines.h b/src/Defines.h index cc04d8026..7a86f499e 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -85,6 +85,7 @@ enum DIG_STATUS_STARTED = 0, DIG_STATUS_CANCELLED = 1, DIG_STATUS_FINISHED = 2, + DIG_STATUS_DROP_STACK= 3, DIG_STATUS_DROP_HELD = 4, DIG_STATUS_SHOOT_EAT = 5, } ; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index fa6422389..22cbf656b 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1382,11 +1382,16 @@ void cPlayer::TossItem( cItem DroppedItem(GetInventory().GetEquippedItem()); if (!DroppedItem.IsEmpty()) { - if (GetInventory().RemoveOneEquippedItem()) + char NewAmount = a_Amount; + if (NewAmount > GetInventory().GetEquippedItem().m_ItemCount) { - DroppedItem.m_ItemCount = 1; // RemoveItem decreases the count, so set it to 1 again - Drops.push_back(DroppedItem); + NewAmount = GetInventory().GetEquippedItem().m_ItemCount; // Drop only what's there } + + GetInventory().GetHotbarGrid().ChangeSlotCount(GetInventory().GetEquippedSlotNum() /* Returns hotbar subslot, which HotbarGrid takes */, -a_Amount); + + DroppedItem.m_ItemCount = NewAmount; + Drops.push_back(DroppedItem); } } } |