From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.World/AbstractContainerMenu.h | 88 +++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Minecraft.World/AbstractContainerMenu.h (limited to 'Minecraft.World/AbstractContainerMenu.h') diff --git a/Minecraft.World/AbstractContainerMenu.h b/Minecraft.World/AbstractContainerMenu.h new file mode 100644 index 00000000..f34e1afc --- /dev/null +++ b/Minecraft.World/AbstractContainerMenu.h @@ -0,0 +1,88 @@ +#pragma once +using namespace std; + +#include "Player.h" +#include "net.minecraft.world.inventory.ContainerListener.h" +using net_minecraft_world_inventory::ContainerListener; + +class Inventory; +class Slot; +class Item; +class ItemInstance; +class Container; + +class AbstractContainerMenu +{ +public: + static const int CLICKED_OUTSIDE = -999; + + static const int CLICK_PICKUP = 0; + static const int CLICK_QUICK_MOVE = 1; + static const int CLICK_SWAP = 2; + static const int CLICK_CLONE = 3; + + // 4J Stu - Added these to fix problem with items picked up while in the creative menu replacing slots in the creative menu + static const int CONTAINER_ID_CARRIED = -1; + static const int CONTAINER_ID_INVENTORY = 0; + static const int CONTAINER_ID_CREATIVE = -2; + + vector > *lastSlots; + vector *slots; + int containerId; + +private: + short changeUid; + bool m_bNeedsRendered; // 4J added + +protected: + vector *containerListeners; + + // 4J Stu - The java does not have ctor here (being an abstract) but we need one to initialise the member variables + // TODO Make sure all derived classes also call this + AbstractContainerMenu(); + + Slot *addSlot(Slot *slot); + +public: + virtual ~AbstractContainerMenu(); + virtual void addSlotListener(ContainerListener *listener); + vector > *getItems(); + void sendData(int id, int value); + virtual void broadcastChanges(); + virtual bool needsRendered(); + virtual bool clickMenuButton(shared_ptr player, int buttonId); + Slot *getSlotFor(shared_ptr c, int index); + Slot *getSlot(int index); + virtual shared_ptr quickMoveStack(shared_ptr player, int slotIndex); + virtual shared_ptr clicked(int slotIndex, int buttonNum, int clickType, shared_ptr player); + virtual bool mayCombine(Slot *slot, shared_ptr item); +protected: + virtual void loopClick(int slotIndex, int buttonNum, bool quickKeyHeld, shared_ptr player); +public: + virtual void removed(shared_ptr player); + virtual void slotsChanged();// 4J used to take a shared_ptr container but wasn't using it, so removed to simplify things + bool isPauseScreen(); + void setItem(unsigned int slot, shared_ptr item); + void setAll(ItemInstanceArray *items); + virtual void setData(int id, int value); + short backup(shared_ptr inventory); + +private: + unordered_set , PlayerKeyHash, PlayerKeyEq> unSynchedPlayers; + +public: + bool isSynched(shared_ptr player); + void setSynched(shared_ptr player, bool synched); + virtual bool stillValid(shared_ptr player) = 0; + + // 4J Stu Added for UI + unsigned int getSize() { return (unsigned int)slots->size(); } + + +protected: + // 4J Stu - Changes to return bool brought forward from 1.2 + bool moveItemStackTo(shared_ptr itemStack, int startSlot, int endSlot, bool backwards); + +public: + virtual bool isOverrideResultClick(int slotNum, int buttonNum); +}; -- cgit v1.2.3