mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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
This commit is contained in:
parent
003af74213
commit
e462a9a5ef
14 changed files with 154 additions and 249 deletions
13
src/tool.cpp
13
src/tool.cpp
|
@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
*/
|
||||
|
||||
#include "tool.h"
|
||||
#include "itemdef.h"
|
||||
#include "itemgroup.h"
|
||||
#include "log.h"
|
||||
#include "inventory.h"
|
||||
|
@ -277,4 +278,16 @@ PunchDamageResult getPunchDamage(
|
|||
return result;
|
||||
}
|
||||
|
||||
f32 getToolRange(const ItemDefinition &def_selected, const ItemDefinition &def_hand)
|
||||
{
|
||||
float max_d = def_selected.range;
|
||||
float max_d_hand = def_hand.range;
|
||||
|
||||
if (max_d < 0 && max_d_hand >= 0)
|
||||
max_d = max_d_hand;
|
||||
else if (max_d < 0)
|
||||
max_d = 4.0f;
|
||||
|
||||
return max_d;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue