diff options
| author | Loki Rautio <lokirautio@gmail.com> | 2026-03-04 03:56:03 -0600 |
|---|---|---|
| committer | Loki Rautio <lokirautio@gmail.com> | 2026-03-04 03:56:03 -0600 |
| commit | 42aec6dac53dffa6afe072560a7e1d4986112538 (patch) | |
| tree | 0836426857391df1b6a83f6368a183f83ec9b104 /Minecraft.World/SimpleContainer.cpp | |
| parent | c9d58eeac7c72f0b3038e084667b4d89a6249fce (diff) | |
| parent | ef9b6fd500dfabd9463267b0dd9e29577eea8a2b (diff) | |
Merge branch 'main' into pr/win64-world-saves
# Conflicts:
# Minecraft.Client/MinecraftServer.cpp
# README.md
Diffstat (limited to 'Minecraft.World/SimpleContainer.cpp')
| -rw-r--r-- | Minecraft.World/SimpleContainer.cpp | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/Minecraft.World/SimpleContainer.cpp b/Minecraft.World/SimpleContainer.cpp index e29bc790..a5f551e2 100644 --- a/Minecraft.World/SimpleContainer.cpp +++ b/Minecraft.World/SimpleContainer.cpp @@ -5,9 +5,11 @@ #include "SimpleContainer.h" -SimpleContainer::SimpleContainer(int name, int size) +SimpleContainer::SimpleContainer(int name, wstring stringName, bool customName, int size) { this->name = name; + this->stringName = stringName; + this->customName = customName; this->size = size; items = new ItemInstanceArray( size ); @@ -46,14 +48,14 @@ shared_ptr<ItemInstance> SimpleContainer::removeItem(unsigned int slot, int coun { shared_ptr<ItemInstance> item = (*items)[slot]; (*items)[slot] = nullptr; - this->setChanged(); + setChanged(); return item; } else { shared_ptr<ItemInstance> i = (*items)[slot]->remove(count); if ((*items)[slot]->count == 0) (*items)[slot] = nullptr; - this->setChanged(); + setChanged(); return i; } } @@ -75,7 +77,7 @@ void SimpleContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item) { (*items)[slot] = item; if (item != NULL && item->count > getMaxStackSize()) item->count = getMaxStackSize(); - this->setChanged(); + setChanged(); } unsigned int SimpleContainer::getContainerSize() @@ -83,28 +85,46 @@ unsigned int SimpleContainer::getContainerSize() return size; } -int SimpleContainer::getName() +wstring SimpleContainer::getName() { - return name; + return stringName.empty() ? app.GetString(name) : stringName; } -int SimpleContainer::getMaxStackSize() +wstring SimpleContainer::getCustomName() +{ + return hasCustomName() ? stringName : L""; +} + +bool SimpleContainer::hasCustomName() +{ + return customName; +} + +void SimpleContainer::setCustomName(const wstring &name) +{ + customName = true; + this->stringName = name; +} + +int SimpleContainer::getMaxStackSize() const { return Container::LARGE_MAX_STACK_SIZE; } void SimpleContainer::setChanged() { - // 4J - removing this as we don't seem to have any implementation of a listener containerChanged function, and shared_from_this is proving tricky to add to containers -#if 0 if (listeners != NULL) for (unsigned int i = 0; i < listeners->size(); i++) { - listeners->at(i)->containerChanged(shared_from_this()); + listeners->at(i)->containerChanged();//shared_from_this()); } -#endif } bool SimpleContainer::stillValid(shared_ptr<Player> player) { return true; +} + +bool SimpleContainer::canPlaceItem(int slot, shared_ptr<ItemInstance> item) +{ + return true; }
\ No newline at end of file |
