11 #include "../Inventory.h"
184 virtual void DistributeStack(
cItem & a_ItemStack,
cPlayer & a_Player,
bool a_ShouldApply,
bool a_KeepEmptySlots,
bool a_BackFill)
override;
245 using cItemMap = std::map<UInt32, std::vector<cItem> >;
274 virtual void DistributeStack(
cItem & a_ItemStack,
cPlayer & a_Player,
bool a_ShouldApply,
bool a_KeepEmptySlots,
bool a_BackFill)
override;
285 typedef std::list<std::pair<UInt32, cCraftingRecipe> >
cRecipeMap;
327 virtual void DistributeStack(
cItem & a_ItemStack,
cPlayer & a_Player,
bool a_ShouldApply,
bool a_KeepEmptySlots,
bool a_BackFill)
override;
367 virtual void DistributeStack(
cItem & a_ItemStack,
cPlayer & a_Player,
bool a_ShouldApply,
bool a_KeepEmptySlots,
bool a_BackFill)
override;
393 virtual void DistributeStack(
cItem & a_ItemStack,
cPlayer & a_Player,
bool a_ShouldApply,
bool a_KeepEmptySlots,
bool a_BackFill)
override;
485 virtual void DistributeStack(
cItem & a_ItemStack,
cPlayer & a_Player,
bool a_ShouldApply,
bool a_KeepEmptySlots,
bool a_BackFill)
override;
516 virtual void DistributeStack(
cItem & a_ItemStack,
cPlayer & a_Player,
bool a_ShouldApply,
bool a_KeepEmptySlots,
bool a_BackFill)
override;
565 virtual void DistributeStack(
cItem & a_ItemStack,
cPlayer & a_Player,
bool a_ShouldApply,
bool a_KeepEmptySlots,
bool a_BackFill)
override;
eClickAction
Individual actions sent in the WindowClick packet.
This class represents the player's inventory The slots are divided into three areas:
This class is used as a callback for when a slot changes.
virtual void NumberClicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction)
Called from Clicked when the action is a number click.
virtual void OnPlayerAdded(cPlayer &a_Player)
Called when a new player opens the same parent window.
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill)
Called to store as much of a_ItemStack in the area as possible.
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem)
Called when a player clicks in the window.
cSlotArea(int a_NumSlots, cWindow &a_ParentWindow)
virtual void DblClicked(cPlayer &a_Player, int a_SlotNum)
Called from Clicked when the action is a caDblClick.
virtual void DropClicked(cPlayer &a_Player, int a_SlotNum, bool a_DropStack)
Called from Clicked when the action is a drop click.
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item)=0
Called to set an item in the specified slot for the specified player.
int GetNumSlots(void) const
virtual void OnPlayerRemoved(cPlayer &a_Player)
Called when one of the players closes the parent window.
virtual void MiddleClicked(cPlayer &a_Player, int a_SlotNum)
Called from Clicked when the action is a middleclick.
virtual bool CollectItemsToHand(cItem &a_Dragging, cPlayer &a_Player, bool a_CollectFullStacks)
Called on DblClicking to collect all stackable items into hand.
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const =0
Called to retrieve an item in the specified slot for the specified player.
virtual void ShiftClicked(cPlayer &a_Player, int a_SlotNum, const cItem &a_ClickedItem)
Called from Clicked when the action is a shiftclick (left or right)
Handles any part of the inventory, using parameters in constructor to distinguish between the parts.
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow &a_ParentWindow)
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
Handles the main inventory of each player, excluding the armor and hotbar.
cSlotAreaInventory(cWindow &a_ParentWindow)
Handles the hotbar of each player.
cSlotAreaHotBar(cWindow &a_ParentWindow)
Handles the shield of each player.
cSlotAreaShield(cWindow &a_ParentWindow)
Handles the armor area of the player's inventory.
static bool CanPlaceArmorInSlot(int a_SlotNum, const cItem &a_Item)
cSlotAreaArmor(cWindow &a_ParentWindow)
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Distributing the stack is allowed only for compatible items (helmets into helmet slot etc....
Handles any slot area that is representing a cItemGrid; same items for all the players.
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
cSlotAreaItemGrid(cItemGrid &a_ItemGrid, cWindow &a_ParentWindow)
virtual ~cSlotAreaItemGrid() override
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
A cSlotArea with items layout that is private to each player and is temporary, such as a crafting gri...
void TossItems(cPlayer &a_Player, int a_Begin, int a_End)
Tosses the player's items in slots [a_Begin, a_End) (ie.
cSlotAreaTemporary(int a_NumSlots, cWindow &a_ParentWindow)
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
std::map< UInt32, std::vector< cItem > > cItemMap
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
virtual void OnPlayerRemoved(cPlayer &a_Player) override
Called when one of the players closes the parent window.
cItem * GetPlayerSlots(cPlayer &a_Player)
Returns the pointer to the slot array for the player specified.
virtual void OnPlayerAdded(cPlayer &a_Player) override
Called when a new player opens the same parent window.
virtual void OnPlayerRemoved(cPlayer &a_Player) override
Called when one of the players closes the parent window.
void UpdateRecipe(cPlayer &a_Player)
Updates the current recipe and result slot based on the ingredients currently in the crafting grid of...
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
void ClearCraftingGrid(cPlayer &a_Player)
Clear the crafting grid.
virtual void DblClicked(cPlayer &a_Player, int a_SlotNum) override
Called from Clicked when the action is a caDblClick.
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
std::list< std::pair< UInt32, cCraftingRecipe > > cRecipeMap
Maps player's EntityID -> current recipe.
void DropClickedResult(cPlayer &a_Player)
Handles a drop-click in the result slot.
cSlotAreaCrafting(int a_GridSize, cWindow &a_ParentWindow)
a_GridSize is allowed to be only 2 or 3
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
void ClickedResult(cPlayer &a_Player)
Handles a click in the result slot.
void HandleCraftItem(const cItem &a_Result, cPlayer &a_Player)
Called after an item has been crafted to handle statistics e.t.c.
cCraftingRecipe & GetRecipeForPlayer(cPlayer &a_Player)
Retrieves the recipe for the specified player from the map, or creates one if not found.
void LoadRecipe(cPlayer &a_Player, UInt32 a_RecipeId)
Loads the given Recipe into the crafting grid.
void ShiftClickedResult(cPlayer &a_Player)
Handles a shift-click in the result slot.
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
virtual void OnPlayerRemoved(cPlayer &a_Player) override
Called when one of the players closes the parent window.
cSlotAreaAnvil(cWindow &a_ParentWindow)
char m_StackSizeToBeUsedInRepair
The stack size of the second item where was used for repair.
int m_MaximumCost
The maximum cost of repairing / renaming in the anvil.
void OnTakeResult(cPlayer &a_Player)
This function will call, when the player take the item from the slot.
bool CanTakeResultItem(cPlayer &a_Player)
Can the player take the item from the slot?
virtual void ShiftClicked(cPlayer &a_Player, int a_SlotNum, const cItem &a_ClickedItem) override
Called from Clicked when the action is a shiftclick (left or right)
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
void UpdateResult(cPlayer &a_Player)
Handles a click in the item slot.
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
static bool IsPlaceableItem(short a_ItemType)
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
cSlotAreaBeacon(cBeaconEntity *a_Beacon, cWindow &a_ParentWindow)
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
virtual ~cSlotAreaBeacon() override
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
virtual void OnPlayerRemoved(cPlayer &a_Player) override
Called when one of the players closes the parent window.
void UpdateResult(cPlayer &a_Player)
Handles a click in the item slot.
std::array< cItem, 3 > m_EnchantedItemOptions
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
unsigned GetBookshelvesCount(cWorld &a_World)
cSlotAreaEnchanting(cWindow &a_ParentWindow, Vector3i a_BlockPos)
cItem SelectEnchantedOption(size_t a_EnchantOption)
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
virtual void OnPlayerAdded(cPlayer &a_Player) override
Called when a new player opens the same parent window.
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
cSlotAreaChest(cChestEntity *a_Chest, cWindow &a_ParentWindow)
cSlotAreaDoubleChest(cChestEntity *a_TopChest, cChestEntity *a_BottomChest, cWindow &a_ParentWindow)
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
cChestEntity * m_BottomChest
cChestEntity * m_TopChest
cSlotAreaEnderChest(cEnderChestEntity *a_EnderChest, cWindow &a_ParentWindow)
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
cEnderChestEntity * m_EnderChest
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
void HandleSmeltItem(const cItem &a_Result, cPlayer &a_Player)
Called after an item has been smelted to handle statistics etc.
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
cFurnaceEntity * m_Furnace
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
virtual ~cSlotAreaFurnace() override
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
cSlotAreaFurnace(cFurnaceEntity *a_Furnace, cWindow &a_ParentWindow)
virtual ~cSlotAreaBrewingstand() override
cSlotAreaBrewingstand(cBrewingstandEntity *a_Brewingstand, cWindow &a_ParentWindow)
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
cBrewingstandEntity * m_Brewingstand
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
void HandleBrewedItem(cPlayer &a_Player, const cItem &a_ClickedItem)
Called after an item has been brewed to handle statistics etc.
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
cSlotAreaMinecartWithChest(cMinecartWithChest *a_ChestCart, cWindow &a_ParentWindow)
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
cMinecartWithChest * m_Chest
Slot area holding horse saddle and armor.
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
cSlotAreaHorse(cHorse &a_Horse, cWindow &a_ParentWindow)