summaryrefslogtreecommitdiffstats
path: root/src/UI
diff options
context:
space:
mode:
authorx12xx12x <44411062+12xx12@users.noreply.github.com>2021-12-02 00:31:10 +0100
committerGitHub <noreply@github.com>2021-12-02 00:31:10 +0100
commit3ff57559e36d3254c64e334fbe3bdd47398fe16f (patch)
tree30a73d405640285863bfa9932afbee482f36b50c /src/UI
parentAdded ExperienceAmount variable to HOOK_PLAYER_FISHING and HOOK_PLAYER_FISHED (#5345) (diff)
downloadcuberite-3ff57559e36d3254c64e334fbe3bdd47398fe16f.tar
cuberite-3ff57559e36d3254c64e334fbe3bdd47398fe16f.tar.gz
cuberite-3ff57559e36d3254c64e334fbe3bdd47398fe16f.tar.bz2
cuberite-3ff57559e36d3254c64e334fbe3bdd47398fe16f.tar.lz
cuberite-3ff57559e36d3254c64e334fbe3bdd47398fe16f.tar.xz
cuberite-3ff57559e36d3254c64e334fbe3bdd47398fe16f.tar.zst
cuberite-3ff57559e36d3254c64e334fbe3bdd47398fe16f.zip
Diffstat (limited to 'src/UI')
-rw-r--r--src/UI/SlotArea.cpp23
-rw-r--r--src/UI/Window.cpp2
2 files changed, 11 insertions, 14 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 6d27ea834..28f3054ce 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -138,8 +138,7 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
else if ((Slot.m_ItemType <= 0) || DraggingItem.IsEqual(Slot))
{
// Drop one item in slot
- cItemHandler * Handler = ItemHandler(Slot.m_ItemType);
- if ((DraggingItem.m_ItemCount > 0) && (Slot.m_ItemCount < Handler->GetMaxStackSize()))
+ if ((DraggingItem.m_ItemCount > 0) && (Slot.m_ItemCount < Slot.GetMaxStackSize()))
{
char OldSlotCount = Slot.m_ItemCount;
@@ -177,8 +176,7 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
else
{
// Same type, add items:
- cItemHandler * Handler = ItemHandler(DraggingItem.m_ItemType);
- int FreeSlots = Handler->GetMaxStackSize() - Slot.m_ItemCount;
+ int FreeSlots = DraggingItem.GetMaxStackSize() - Slot.m_ItemCount;
if (FreeSlots < 0)
{
ASSERT(!"Bad item stack size - where did we get more items in a slot than allowed?");
@@ -365,7 +363,7 @@ void cSlotArea::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_
// Different items
continue;
}
- char NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount;
+ char NumFit = Slot->GetMaxStackSize() - Slot->m_ItemCount;
if (NumFit <= 0)
{
// Full stack already
@@ -636,8 +634,7 @@ void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player)
}
else if (DraggingItem.IsEqual(Result))
{
- cItemHandler * Handler = ItemHandler(Result.m_ItemType);
- if (DraggingItem.m_ItemCount + Result.m_ItemCount <= Handler->GetMaxStackSize())
+ if (DraggingItem.m_ItemCount + Result.m_ItemCount <= Result.GetMaxStackSize())
{
DraggingItem.m_ItemCount += Result.m_ItemCount;
Recipe.ConsumeIngredients(Grid);
@@ -928,7 +925,7 @@ void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C
}
if (!DraggingItem.IsEmpty())
{
- if (!(DraggingItem.IsEqual(Slot) && ((DraggingItem.m_ItemCount + Slot.m_ItemCount) <= cItemHandler::GetItemHandler(Slot)->GetMaxStackSize())))
+ if (!(DraggingItem.IsEqual(Slot) && ((DraggingItem.m_ItemCount + Slot.m_ItemCount) <= Slot.GetMaxStackSize())))
{
return;
}
@@ -1004,7 +1001,7 @@ void cSlotAreaAnvil::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bo
// Different items
continue;
}
- char NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount;
+ char NumFit = Slot->GetMaxStackSize() - Slot->m_ItemCount;
if (NumFit <= 0)
{
// Full stack already
@@ -1151,7 +1148,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
RepairCost += Sacrifice.m_RepairCost;
// Can we repair with sacrifce material?
- if (Target.IsDamageable() && cItemHandler::GetItemHandler(Target)->CanRepairWithRawMaterial(Sacrifice.m_ItemType))
+ if (Target.IsDamageable() && Target.GetHandler().CanRepairWithRawMaterial(Sacrifice.m_ItemType))
{
// Tool and armor repair with special item (iron / gold / diamond / ...)
int DamageDiff = std::min(static_cast<int>(Target.m_ItemDamage), static_cast<int>(Target.GetMaxDamage()) / 4);
@@ -1620,7 +1617,7 @@ void cSlotAreaEnchanting::DistributeStack(cItem & a_ItemStack, cPlayer & a_Playe
{
// It's lapis, put it in the lapis spot.
const cItem * Slot = GetSlot(1, a_Player);
- char NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount;
+ char NumFit = Slot->GetMaxStackSize() - Slot->m_ItemCount;
if (NumFit <= 0)
{
// Full stack already
@@ -2036,7 +2033,7 @@ void cSlotAreaFurnace::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player,
return;
}
- char NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount;
+ char NumFit = Slot->GetMaxStackSize() - Slot->m_ItemCount;
if (NumFit <= 0)
{
// Full stack already
@@ -2300,7 +2297,7 @@ void cSlotAreaBrewingstand::DistributeStack(cItem & a_ItemStack, cPlayer & a_Pla
return;
}
- char NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount;
+ char NumFit = Slot->GetMaxStackSize() - Slot->m_ItemCount;
if (NumFit <= 0)
{
// Full stack already
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 23661e150..81704d6f0 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -696,7 +696,7 @@ void cWindow::OnMiddlePaintEnd(cPlayer & a_Player)
// Fill available slots with full stacks of the dragging item
const auto & DraggingItem = a_Player.GetDraggingItem();
- auto StackSize = ItemHandler(DraggingItem.m_ItemType)->GetMaxStackSize();
+ auto StackSize = DraggingItem.GetMaxStackSize();
if (0 < DistributeItemToSlots(a_Player, DraggingItem, StackSize, a_Player.GetInventoryPaintSlots(), false))
{
// If any items were distibuted, set dragging item empty