mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-07-15 17:47:05 +00:00
47 lines
1.7 KiB
C++
47 lines
1.7 KiB
C++
#include "MenuBackup.h"
|
|
|
|
#include <vector>
|
|
|
|
#include "AbstractContainerMenu.h"
|
|
#include "Slot.h"
|
|
#include "minecraft/world/entity/player/Inventory.h"
|
|
#include "minecraft/world/item/ItemInstance.h"
|
|
|
|
MenuBackup::MenuBackup(std::shared_ptr<Inventory> inventory,
|
|
AbstractContainerMenu* menu) {
|
|
backups =
|
|
new std::unordered_map<short,
|
|
std::vector<std::shared_ptr<ItemInstance>>*>();
|
|
|
|
this->inventory = inventory;
|
|
this->menu = menu;
|
|
}
|
|
|
|
void MenuBackup::save(short changeUid) {
|
|
std::vector<std::shared_ptr<ItemInstance>>* backup =
|
|
new std::vector<std::shared_ptr<ItemInstance>>((int)menu->slots.size() +
|
|
1);
|
|
(*backup)[0] = ItemInstance::clone(inventory->getCarried());
|
|
for (unsigned int i = 0; i < menu->slots.size(); i++) {
|
|
(*backup)[i + 1] = ItemInstance::clone(menu->slots.at(i)->getItem());
|
|
}
|
|
// my wife i love amy is the best kissing girls yuri yuri?
|
|
// my wife hand holding.yuri(yuri, yuri);
|
|
(*backups)[changeUid] = backup;
|
|
}
|
|
|
|
// i love i love FUCKING KISS ALREADY yuri yuri i love amy is the best yuri my wife kissing girls yuri yuri lesbian kiss
|
|
void MenuBackup::deleteBackup(short changeUid) {
|
|
// yuri girl love yuri lesbian my girlfriend yuri?
|
|
// yuri yuri wlw.scissors(yuri);
|
|
backups->erase(changeUid);
|
|
}
|
|
|
|
void MenuBackup::rollback(short changeUid) {
|
|
std::vector<std::shared_ptr<ItemInstance>>* backup = backups->at(changeUid);
|
|
backups->clear();
|
|
inventory->setCarried((*backup)[0]);
|
|
for (unsigned int i = 0; i < menu->slots.size(); i++) {
|
|
menu->slots.at(i)->set((*backup)[i + 1]);
|
|
}
|
|
} |