MCPcopy Create free account
hub / github.com/cuberite/cuberite / ShiftClickedResult

Method ShiftClickedResult

src/UI/SlotArea.cpp:519–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517
518
519void cSlotAreaCrafting::ShiftClickedResult(cPlayer & a_Player)
520{
521 cItem Result(*GetSlot(0, a_Player));
522 if (Result.IsEmpty())
523 {
524 return;
525 }
526 cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1;
527 for (;;)
528 {
529 // Try distributing the result. If it fails, bail out:
530 cItem ResultCopy(Result);
531 m_ParentWindow.DistributeStack(ResultCopy, a_Player, this, false);
532 if (!ResultCopy.IsEmpty())
533 {
534 // Couldn't distribute all of it. Bail out
535 return;
536 }
537
538 // Distribute the result, this time for real:
539 ResultCopy = Result;
540 m_ParentWindow.DistributeStack(ResultCopy, a_Player, this, true);
541
542 // Remove the ingredients from the crafting grid and update the recipe:
543 cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);
544 cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize);
545 Recipe.ConsumeIngredients(Grid);
546 Grid.CopyToItems(PlayerSlots);
547 UpdateRecipe(a_Player);
548 if (!Recipe.GetResult().IsEqual(Result))
549 {
550 // The recipe has changed, bail out
551 return;
552 }
553 }
554}
555
556
557

Callers

nothing calls this directly

Calls 6

ConsumeIngredientsMethod · 0.80
IsEqualMethod · 0.80
GetResultMethod · 0.80
IsEmptyMethod · 0.45
DistributeStackMethod · 0.45
CopyToItemsMethod · 0.45

Tested by

no test coverage detected