1
0
Fork 0

Add no_change_anim group

main-2-0-4
luk3yx 2023-06-19 17:50:22 +12:00
parent d2408a9324
commit d12f19fabf
4 changed files with 13 additions and 5 deletions

View File

@ -1708,6 +1708,8 @@ to games.
### Node, item and tool groups
* `no_change_anim`: Disables the wielditem changing animation when switching
to the item in the hotbar.
* `not_in_creative_inventory`: (*) Special group for inventory mods to indicate
that the item should be hidden in item lists.

View File

@ -648,15 +648,20 @@ void Camera::setDigging(s32 button)
m_digging_button = button;
}
void Camera::wield(const ItemStack &item)
void Camera::wield(const ItemStack &item, const bool no_change_anim)
{
if (item.name != m_wield_item_next.name ||
item.metadata != m_wield_item_next.metadata) {
m_wield_item_next = item;
if (m_wield_change_timer > 0)
if (no_change_anim) {
// Change items immediately
m_wieldnode->setItem(item, m_client);
m_wield_change_timer = 0.125f;
} else if (m_wield_change_timer > 0) {
m_wield_change_timer = -m_wield_change_timer;
else if (m_wield_change_timer == 0)
} else if (m_wield_change_timer == 0) {
m_wield_change_timer = -0.001;
}
}
}

View File

@ -154,7 +154,7 @@ public:
void setDigging(s32 button);
// Replace the wielded item mesh
void wield(const ItemStack &item);
void wield(const ItemStack &item, const bool no_change_anim);
// Draw the wielded tool.
// This has to happen *after* the main scene is drawn.

View File

@ -3948,7 +3948,8 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
// Update wielded tool
ItemStack selected_item, hand_item;
ItemStack &tool_item = player->getWieldedItem(&selected_item, &hand_item);
camera->wield(tool_item);
const ItemDefinition &item_def = tool_item.getDefinition(itemdef_manager);
camera->wield(tool_item, itemgroup_get(item_def.groups, "no_change_anim") > 0);
}
/*