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/script/lua_api/l_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/script/lua_api/l_client.cpp')
-rw-r--r-- | src/script/lua_api/l_client.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 6d9d832b7..6345fc75f 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -210,17 +210,13 @@ int ModApiClient::l_get_language(lua_State *L) int ModApiClient::l_get_wielded_item(lua_State *L) { Client *client = getClient(L); + LocalPlayer *player = client->getEnv().getLocalPlayer(); + if (!player) + return 0; - Inventory local_inventory(client->idef()); - client->getLocalInventory(local_inventory); - - InventoryList *mlist = local_inventory.getList("main"); - - if (mlist && client->getPlayerItem() < mlist->getSize()) { - LuaItemStack::create(L, mlist->getItem(client->getPlayerItem())); - } else { - LuaItemStack::create(L, ItemStack()); - } + ItemStack selected_item; + player->getWieldedItem(&selected_item, nullptr); + LuaItemStack::create(L, selected_item); return 1; } |