aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Slot.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-08 19:08:36 -0400
committerGitHub <noreply@github.com>2026-03-08 18:08:36 -0500
commit28614b922fb77149a54da1a87bebfbc98736f296 (patch)
tree7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.World/Slot.cpp
parent88798b501d0cf6287b6f87acb2592676e3cec58d (diff)
Modernize project codebase (#906)
* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides * Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.World/Slot.cpp')
-rw-r--r--Minecraft.World/Slot.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/Minecraft.World/Slot.cpp b/Minecraft.World/Slot.cpp
index a5a53a48..2f42a27d 100644
--- a/Minecraft.World/Slot.cpp
+++ b/Minecraft.World/Slot.cpp
@@ -15,7 +15,7 @@ Slot::Slot(shared_ptr<Container> container, int slot, int x, int y) : container(
void Slot::onQuickCraft(shared_ptr<ItemInstance> picked, shared_ptr<ItemInstance> original)
{
- if (picked == NULL || original == NULL)
+ if (picked == nullptr || original == nullptr)
{
return;
}
@@ -44,14 +44,14 @@ void Slot::swap(Slot *other)
shared_ptr<ItemInstance> item1 = container->getItem(slot);
shared_ptr<ItemInstance> item2 = other->container->getItem(other->slot);
- if (item1 != NULL && item1->count > other->getMaxStackSize())
+ if (item1 != nullptr && item1->count > other->getMaxStackSize())
{
- if (item2 != NULL) return;
+ if (item2 != nullptr) return;
item2 = item1->remove(item1->count - other->getMaxStackSize());
}
- if (item2 != NULL && item2->count > getMaxStackSize())
+ if (item2 != nullptr && item2->count > getMaxStackSize())
{
- if (item1 != NULL) return;
+ if (item1 != nullptr) return;
item1 = item2->remove(item2->count - getMaxStackSize());
}
other->container->setItem(other->slot, item1);
@@ -77,7 +77,7 @@ shared_ptr<ItemInstance> Slot::getItem()
bool Slot::hasItem()
{
- return getItem() != NULL;
+ return getItem() != nullptr;
}
void Slot::set(shared_ptr<ItemInstance> item)
@@ -98,7 +98,7 @@ int Slot::getMaxStackSize() const
Icon *Slot::getNoItemIcon()
{
- return NULL;
+ return nullptr;
}
shared_ptr<ItemInstance> Slot::remove(int c)
@@ -125,7 +125,7 @@ bool Slot::mayCombine(shared_ptr<ItemInstance> second)
{
shared_ptr<ItemInstance> first = getItem();
- if(first == NULL || second == NULL) return false;
+ if(first == nullptr || second == nullptr) return false;
ArmorItem *thisItem = dynamic_cast<ArmorItem *>(first->getItem());
if(thisItem)
@@ -135,7 +135,7 @@ bool Slot::mayCombine(shared_ptr<ItemInstance> second)
return thisIsDyableArmor && itemIsDye;
}
// 4J Stu - This condition taken from Recipes::getItemFor to repair items, but added the damaged check to skip when the result is pointless
- else if (first != NULL && second != NULL && first->id == second->id && first->count == 1 && second->count == 1 && Item::items[first->id]->canBeDepleted() && (first->isDamaged() || second->isDamaged()) )
+ else if (first != nullptr && second != nullptr && first->id == second->id && first->count == 1 && second->count == 1 && Item::items[first->id]->canBeDepleted() && (first->isDamaged() || second->isDamaged()) )
{
// 4J Stu - Don't allow combinining enchanted items, the enchantment will be lost. They can use the anvil for this
return !first->isEnchanted() && !second->isEnchanted();
@@ -148,7 +148,7 @@ shared_ptr<ItemInstance> Slot::combine(shared_ptr<ItemInstance> item)
shared_ptr<ItemInstance> result = nullptr;
shared_ptr<ItemInstance> first = getItem();
- shared_ptr<CraftingContainer> craftSlots = shared_ptr<CraftingContainer>( new CraftingContainer(NULL, 2, 2) );
+ shared_ptr<CraftingContainer> craftSlots = std::make_shared<CraftingContainer>(nullptr, 2, 2);
craftSlots->setItem(0, item);
craftSlots->setItem(1, first);
@@ -159,7 +159,7 @@ shared_ptr<ItemInstance> Slot::combine(shared_ptr<ItemInstance> item)
}
else
{
- result = Recipes::getInstance()->getItemFor(craftSlots, NULL);
+ result = Recipes::getInstance()->getItemFor(craftSlots, nullptr);
}
craftSlots->setItem(0, nullptr);