diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-08-07 19:16:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-07 19:16:31 +0200 |
commit | e462a9a5ef46776d974203bb44e0b89e8c980b29 (patch) | |
tree | 4562ef5587bd896890d843877031d5818de19bbc /src/client/client.cpp | |
parent | 003af7421352ec1b8ba0d230b807862e1e4cc7e9 (diff) | |
download | minetest-e462a9a5ef46776d974203bb44e0b89e8c980b29.tar.gz minetest-e462a9a5ef46776d974203bb44e0b89e8c980b29.tar.bz2 minetest-e462a9a5ef46776d974203bb44e0b89e8c980b29.zip |
Unify wield item handling (#8677)
This moves the wield item functions to Player and the tool utils for range calculation
Also 'local_inventory' was removed due to redundancy in Client
Diffstat (limited to 'src/client/client.cpp')
-rw-r--r-- | src/client/client.cpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp index 4dc05dc09..430784b95 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -940,7 +940,7 @@ void Client::interact(u8 action, const PointedThing& pointed) NetworkPacket pkt(TOSERVER_INTERACT, 1 + 2 + 0); pkt << action; - pkt << (u16)getPlayerItem(); + pkt << myplayer->getWieldIndex(); std::ostringstream tmp_os(std::ios::binary); pointed.serialize(tmp_os); @@ -1277,19 +1277,6 @@ void Client::sendPlayerPos() Send(&pkt); } -void Client::sendPlayerItem(u16 item) -{ - LocalPlayer *myplayer = m_env.getLocalPlayer(); - if (!myplayer) - return; - - NetworkPacket pkt(TOSERVER_PLAYERITEM, 2); - - pkt << item; - - Send(&pkt); -} - void Client::removeNode(v3s16 p) { std::map<v3s16, MapBlock*> modified_blocks; @@ -1349,11 +1336,14 @@ void Client::setPlayerControl(PlayerControl &control) player->control = control; } -void Client::selectPlayerItem(u16 item) +void Client::setPlayerItem(u16 item) { - m_playeritem = item; + m_env.getLocalPlayer()->setWieldIndex(item); m_inventory_updated = true; - sendPlayerItem(item); + + NetworkPacket pkt(TOSERVER_PLAYERITEM, 2); + pkt << item; + Send(&pkt); } // Returns true if the inventory of the local player has been |