@@ -802,7 +802,8 @@ class Game {
802
802
void updateChat (f32 dtime, const v2u32 &screensize);
803
803
804
804
bool nodePlacement (const ItemDefinition &selected_def, const ItemStack &selected_item,
805
- const v3s16 &nodepos, const v3s16 &neighbourpos, const PointedThing &pointed);
805
+ const v3s16 &nodepos, const v3s16 &neighbourpos, const PointedThing &pointed,
806
+ const NodeMetadata *meta);
806
807
static const ClientEventHandler clientEventHandler[CLIENTEVENT_MAX];
807
808
808
809
InputHandler *input = nullptr ;
@@ -3199,50 +3200,26 @@ void Game::handlePointingAtNode(const PointedThing &pointed,
3199
3200
runData.repeat_rightclick_timer = 0 ;
3200
3201
infostream << " Ground right-clicked" << std::endl;
3201
3202
3202
- if (meta && !meta->getString (" formspec" ).empty () && !random_input
3203
- && !isKeyDown (KeyType::SNEAK)) {
3204
- // Report right click to server
3205
- if (nodedef_manager->get (map.getNode (nodepos)).rightclickable ) {
3206
- client->interact (INTERACT_PLACE, pointed);
3207
- }
3208
-
3209
- infostream << " Launching custom inventory view" << std::endl;
3203
+ camera->setDigging (1 ); // right click animation (always shown for feedback)
3210
3204
3211
- InventoryLocation inventoryloc;
3212
- inventoryloc.setNodeMeta (nodepos);
3205
+ soundmaker->m_player_rightpunch_sound = SimpleSoundSpec ();
3213
3206
3214
- NodeMetadataFormSource *fs_src = new NodeMetadataFormSource (
3215
- &client->getEnv ().getClientMap (), nodepos);
3216
- TextDest *txt_dst = new TextDestNodeMetadata (nodepos, client);
3217
-
3218
- auto *&formspec = m_game_ui->updateFormspec (" " );
3219
- GUIFormSpecMenu::create (formspec, client, &input->joystick , fs_src,
3220
- txt_dst, client->getFormspecPrepend ());
3221
-
3222
- formspec->setFormSpec (meta->getString (" formspec" ), inventoryloc);
3223
- } else {
3224
- // Report right click to server
3207
+ // If the wielded item has node placement prediction,
3208
+ // make that happen
3209
+ // And also set the sound and send the interact
3210
+ // But first check for meta formspec and rightclickable
3211
+ auto &def = selected_item.getDefinition (itemdef_manager);
3212
+ bool placed = nodePlacement (def, selected_item, nodepos, neighbourpos,
3213
+ pointed, meta);
3225
3214
3226
- camera->setDigging (1 ); // right click animation (always shown for feedback)
3227
-
3228
- soundmaker->m_player_rightpunch_sound = SimpleSoundSpec ();
3229
-
3230
- // If the wielded item has node placement prediction,
3231
- // make that happen
3232
- // And also set the sound and send the interact
3233
- auto &def = selected_item.getDefinition (itemdef_manager);
3234
- bool placed = nodePlacement (def, selected_item, nodepos, neighbourpos,
3235
- pointed);
3236
-
3237
- if (placed && client->modsLoaded ())
3238
- client->getScript ()->on_placenode (pointed, def);
3239
- }
3215
+ if (placed && client->modsLoaded ())
3216
+ client->getScript ()->on_placenode (pointed, def);
3240
3217
}
3241
3218
}
3242
3219
3243
3220
bool Game::nodePlacement (const ItemDefinition &selected_def,
3244
3221
const ItemStack &selected_item, const v3s16 &nodepos, const v3s16 &neighbourpos,
3245
- const PointedThing &pointed)
3222
+ const PointedThing &pointed, const NodeMetadata *meta )
3246
3223
{
3247
3224
std::string prediction = selected_def.node_placement_prediction ;
3248
3225
const NodeDefManager *nodedef = client->ndef ();
@@ -3256,6 +3233,31 @@ bool Game::nodePlacement(const ItemDefinition &selected_def,
3256
3233
return false ;
3257
3234
}
3258
3235
3236
+ // formspec in meta
3237
+ if (meta && !meta->getString (" formspec" ).empty () && !random_input
3238
+ && !isKeyDown (KeyType::SNEAK)) {
3239
+ // on_rightclick callbacks are called anyway
3240
+ if (nodedef_manager->get (map.getNode (nodepos)).rightclickable )
3241
+ client->interact (INTERACT_PLACE, pointed);
3242
+
3243
+ infostream << " Launching custom inventory view" << std::endl;
3244
+
3245
+ InventoryLocation inventoryloc;
3246
+ inventoryloc.setNodeMeta (nodepos);
3247
+
3248
+ NodeMetadataFormSource *fs_src = new NodeMetadataFormSource (
3249
+ &client->getEnv ().getClientMap (), nodepos);
3250
+ TextDest *txt_dst = new TextDestNodeMetadata (nodepos, client);
3251
+
3252
+ auto *&formspec = m_game_ui->updateFormspec (" " );
3253
+ GUIFormSpecMenu::create (formspec, client, &input->joystick , fs_src,
3254
+ txt_dst, client->getFormspecPrepend ());
3255
+
3256
+ formspec->setFormSpec (meta->getString (" formspec" ), inventoryloc);
3257
+ return false ;
3258
+ }
3259
+
3260
+ // on_rightclick callback
3259
3261
if (prediction.empty () || (nodedef->get (node).rightclickable &&
3260
3262
!isKeyDown (KeyType::SNEAK))) {
3261
3263
// Report to server
0 commit comments