bool look_for_object, const v3s16 &camera_offset);
void handlePointingAtNothing(const ItemStack &playerItem);
void handlePointingAtNode(const PointedThing &pointed,
- const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime);
+ const ItemStack &selected_item, const ItemStack &hand_item,
+ const ItemStack &place_item, f32 dtime);
void handlePointingAtObject(const PointedThing &pointed, const ItemStack &playeritem,
const v3f &player_position, bool show_debug);
void handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
if (g_gamecallback->changepassword_requested) {
(new GUIPasswordChange(guienv, guiroot, -1,
- &g_menumgr, client, texture_src))->drop();
+ &g_menumgr, client, texture_src))->drop();
g_gamecallback->changepassword_requested = false;
}
if (g_gamecallback->changevolume_requested) {
(new GUIVolumeChange(guienv, guiroot, -1,
- &g_menumgr, texture_src))->drop();
+ &g_menumgr, texture_src))->drop();
g_gamecallback->changevolume_requested = false;
}
if (g_gamecallback->keyconfig_requested) {
(new GUIKeyChangeMenu(guienv, guiroot, -1,
- &g_menumgr, texture_src))->drop();
+ &g_menumgr, texture_src))->drop();
g_gamecallback->keyconfig_requested = false;
}
*new_playeritem = player->getWieldIndex();
s32 wheel = input->getMouseWheel();
u16 max_item = MYMIN(PLAYER_INVENTORY_SIZE - 1,
- player->hud_hotbar_itemcount - 1);
+ player->hud_hotbar_itemcount - 1);
s32 dir = wheel;
// Update sound listener
v3s16 camera_offset = camera->getOffset();
sound->updateListener(camera->getCameraNode()->getPosition() + intToFloat(camera_offset, BS),
- v3f(0, 0, 0), // velocity
- camera->getDirection(),
- camera->getCameraNode()->getUpVector());
+ v3f(0, 0, 0), // velocity
+ camera->getDirection(),
+ camera->getCameraNode()->getUpVector());
bool mute_sound = g_settings->getBool("mute_sound");
if (mute_sound) {
Calculate what block is the crosshair pointing to
*/
- ItemStack selected_item, hand_item;
+ ItemStack selected_item, hand_item, offhand_item, place_item;
const ItemStack &tool_item = player->getWieldedItem(&selected_item, &hand_item);
const ItemDefinition &selected_def = selected_item.getDefinition(itemdef_manager);
!runData.btn_down_for_dig,
camera_offset);
+ player->getOffhandWieldedItem(&offhand_item, &place_item, itemdef_manager, pointed);
+
if (pointed != runData.pointed_old)
infostream << "Pointing at " << pointed.dump() << std::endl;
!client->getScript()->on_item_use(selected_item, pointed)))
client->interact(INTERACT_USE, pointed);
} else if (pointed.type == POINTEDTHING_NODE) {
- handlePointingAtNode(pointed, selected_item, hand_item, dtime);
+ handlePointingAtNode(pointed, selected_item, hand_item, place_item, dtime);
} else if (pointed.type == POINTEDTHING_OBJECT) {
v3f player_position = player->getPosition();
bool basic_debug_allowed = client->checkPrivilege("debug") || (player->hud_flags & HUD_FLAG_BASIC_DEBUG);
if (wasKeyPressed(KeyType::DIG) && client->modsLoaded())
client->getScript()->on_item_use(selected_item, pointed);
} else if (wasKeyPressed(KeyType::PLACE)) {
- handlePointingAtNothing(selected_item);
+ handlePointingAtNothing(place_item);
}
runData.pointed_old = pointed;
if (runData.punching || wasKeyPressed(KeyType::DIG))
- camera->setDigging(0); // dig animation
+ camera->setDigging(0, MAINHAND); // dig animation
input->clearWasKeyPressed();
input->clearWasKeyReleased();
void Game::handlePointingAtNode(const PointedThing &pointed,
- const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime)
+ const ItemStack &selected_item, const ItemStack &hand_item,
+ const ItemStack &place_item, f32 dtime)
{
v3s16 nodepos = pointed.node_undersurface;
v3s16 neighborpos = pointed.node_abovesurface;
infostream << "Place button pressed while looking at ground" << std::endl;
// Placing animation (always shown for feedback)
- camera->setDigging(1);
+ if (place_item == selected_item)
+ camera->setDigging(1, MAINHAND);
+ else
+ camera->setDigging(1, OFFHAND);
soundmaker->m_player_rightpunch_sound = SimpleSoundSpec();
// make that happen
// And also set the sound and send the interact
// But first check for meta formspec and rightclickable
- auto &def = selected_item.getDefinition(itemdef_manager);
- bool placed = nodePlacement(def, selected_item, nodepos, neighborpos,
+ auto &def = place_item.getDefinition(itemdef_manager);
+ bool placed = nodePlacement(def, place_item, nodepos, neighborpos,
pointed, meta);
if (placed && client->modsLoaded())
client->setCrack(-1, nodepos);
}
- camera->setDigging(0); // Dig animation
+ camera->setDigging(0, MAINHAND); // Dig animation
}
void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
direct_brightness = client->getEnv().getClientMap()
.getBackgroundBrightness(MYMIN(runData.fog_range * 1.2, 60 * BS),
daynight_ratio, (int)(old_brightness * 255.5), &sunlight_seen)
- / 255.0;
+ / 255.0;
}
float time_of_day_smooth = runData.time_of_day_smooth;
if (client->updateWieldedItem()) {
// Update wielded tool
- ItemStack selected_item, hand_item;
+ ItemStack selected_item, hand_item, offhand_item;
ItemStack &tool_item = player->getWieldedItem(&selected_item, &hand_item);
- camera->wield(tool_item);
+ camera->wield(tool_item, MAINHAND);
+ player->getOffhandWieldedItem(&offhand_item, nullptr, itemdef_manager, PointedThing());
+ camera->wield(offhand_item, OFFHAND);
}
/*