Cuberite
A lightweight, fast and extensible game server for Minecraft
SlotArea.h
Go to the documentation of this file.
1 
2 // SlotArea.h
3 
4 // Interfaces to the cSlotArea class representing a contiguous area of slots in a UI window
5 
6 
7 
8 
9 #pragma once
10 
11 #include "../Inventory.h"
12 
13 
14 
15 
16 
17 class cHorse;
18 class cWindow;
19 class cPlayer;
20 class cBeaconEntity;
22 class cChestEntity;
23 class cEnderChestEntity;
24 class cFurnaceEntity;
25 class cMinecartWithChest;
26 class cCraftingRecipe;
27 class cWorld;
28 
29 
30 
31 
32 
33 class cSlotArea
34 {
35 public:
36  cSlotArea(int a_NumSlots, cWindow & a_ParentWindow);
37  virtual ~cSlotArea() {} // force a virtual destructor in all subclasses
38 
39  int GetNumSlots(void) const { return m_NumSlots; }
40 
42  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const = 0;
43 
45  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) = 0;
46 
48  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem);
49 
51  virtual void ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem);
52 
54  virtual void DblClicked(cPlayer & a_Player, int a_SlotNum);
55 
57  virtual void MiddleClicked(cPlayer & a_Player, int a_SlotNum);
58 
60  virtual void DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack);
61 
63  virtual void NumberClicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction);
64 
66  virtual void OnPlayerAdded(cPlayer & a_Player);
67 
69  virtual void OnPlayerRemoved(cPlayer & a_Player);
70 
76  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill);
77 
82  virtual bool CollectItemsToHand(cItem & a_Dragging, cPlayer & a_Player, bool a_CollectFullStacks);
83 
84 protected:
87 } ;
88 
89 
90 
91 
92 
95  public cSlotArea
96 {
97  using Super = cSlotArea;
98 
99 public:
100 
101  cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow & a_ParentWindow);
102 
103  // Creative inventory's click handling is somewhat different from survival inventory's, handle that here:
104  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
105 
106  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
107  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
108 
109 protected:
110  int m_SlotOffset; // Index that this area's slot 0 has in the underlying cInventory
111 } ;
112 
113 
114 
115 
116 
120 {
122 
123 public:
124 
125  cSlotAreaInventory(cWindow & a_ParentWindow):
126  Super(cInventory::invInventoryCount, cInventory::invInventoryOffset, a_ParentWindow)
127  {
128  }
129 } ;
130 
131 
132 
133 
134 
138 {
140 
141 public:
142  cSlotAreaHotBar(cWindow & a_ParentWindow):
143  Super(cInventory::invHotbarCount, cInventory::invHotbarOffset, a_ParentWindow)
144  {
145  }
146 } ;
147 
148 
149 
150 
151 
155 {
157 
158 public:
159 
160  cSlotAreaShield(cWindow & a_ParentWindow):
161  Super(cInventory::invShieldCount, cInventory::invShieldOffset, a_ParentWindow)
162  {
163  }
164 };
165 
166 
167 
168 
169 
173 {
175 
176 public:
177 
178  cSlotAreaArmor(cWindow & a_ParentWindow):
179  Super(cInventory::invArmorCount, cInventory::invArmorOffset, a_ParentWindow)
180  {
181  }
182 
184  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
185 
187  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
188 
189  static bool CanPlaceArmorInSlot(int a_SlotNum, const cItem & a_Item);
190 } ;
191 
192 
193 
194 
195 
198  public cSlotArea,
199  public cItemGrid::cListener
200 {
201  using Super = cSlotArea;
202 
203 public:
204 
205  cSlotAreaItemGrid(cItemGrid & a_ItemGrid, cWindow & a_ParentWindow);
206 
207  virtual ~cSlotAreaItemGrid() override;
208 
209  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
210  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
211 
212 protected:
214 
215  // cItemGrid::cListener overrides:
216  virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
217 } ;
218 
219 
220 
221 
222 
227  public cSlotArea
228 {
229  using Super = cSlotArea;
230 
231 public:
232 
233  cSlotAreaTemporary(int a_NumSlots, cWindow & a_ParentWindow);
234 
235  // cSlotArea overrides:
236  virtual const cItem * GetSlot (int a_SlotNum, cPlayer & a_Player) const override;
237  virtual void SetSlot (int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
238  virtual void OnPlayerAdded (cPlayer & a_Player) override;
239  virtual void OnPlayerRemoved(cPlayer & a_Player) override;
240 
242  void TossItems(cPlayer & a_Player, int a_Begin, int a_End);
243 
244 protected:
245  using cItemMap = std::map<UInt32, std::vector<cItem> >; // Maps EntityID -> items
246 
248 
250  cItem * GetPlayerSlots(cPlayer & a_Player);
251 } ;
252 
253 
254 
255 
256 
258  public cSlotAreaTemporary
259 {
261 
262 public:
263 
265  cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow);
266 
267  // cSlotAreaTemporary overrides:
268  virtual void Clicked (cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
269  virtual void DblClicked (cPlayer & a_Player, int a_SlotNum) override;
270  virtual void OnPlayerRemoved(cPlayer & a_Player) override;
271  virtual void SetSlot (int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
272 
273  // Distributing items into this area is completely disabled
274  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
275 
277  void ClearCraftingGrid(cPlayer & a_Player);
278 
280  void LoadRecipe(cPlayer & a_Player, UInt32 a_RecipeId);
281 
282 protected:
285  typedef std::list<std::pair<UInt32, cCraftingRecipe> > cRecipeMap;
286 
289 
292  void ClickedResult(cPlayer & a_Player);
293 
296  void ShiftClickedResult(cPlayer & a_Player);
297 
299  void DropClickedResult(cPlayer & a_Player);
300 
302  void UpdateRecipe(cPlayer & a_Player);
303 
306 
308  void HandleCraftItem(const cItem & a_Result, cPlayer & a_Player);
309 } ;
310 
311 
312 
313 
314 
316  public cSlotAreaTemporary
317 {
319 
320 public:
321 
322  cSlotAreaAnvil(cWindow & a_ParentWindow);
323 
324  // cSlotArea overrides:
325  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
326  virtual void ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem) override;
327  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
328 
329  // cSlotAreaTemporary overrides:
330  virtual void OnPlayerRemoved(cPlayer & a_Player) override;
331 
333  bool CanTakeResultItem(cPlayer & a_Player);
334 
336  void OnTakeResult(cPlayer & a_Player);
337 
339  void UpdateResult(cPlayer & a_Player);
340 
341 protected:
344 
347 } ;
348 
349 
350 
351 
352 
354  public cSlotArea,
355  public cItemGrid::cListener
356 {
357  using Super = cSlotArea;
358 
359 public:
360 
361  cSlotAreaBeacon(cBeaconEntity * a_Beacon, cWindow & a_ParentWindow);
362  virtual ~cSlotAreaBeacon() override;
363 
364  static bool IsPlaceableItem(short a_ItemType);
365 
366  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
367  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
368  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
369  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
370 
371 protected:
373 
374  // cItemGrid::cListener overrides:
375  virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
376 } ;
377 
378 
379 
380 
381 
382 class cSlotAreaEnchanting final :
383  public cSlotAreaTemporary
384 {
386 
387 public:
388 
389  cSlotAreaEnchanting(cWindow & a_ParentWindow, Vector3i a_BlockPos);
390 
391  // cSlotArea overrides:
392  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
393  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
394  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
395 
396  // cSlotAreaTemporary overrides:
397  virtual void OnPlayerAdded (cPlayer & a_Player) override;
398  virtual void OnPlayerRemoved(cPlayer & a_Player) override;
399 
400  /* Get the number of bookshelves which are near the enchanting table */
401  unsigned GetBookshelvesCount(cWorld & a_World);
402 
403  /* Return the enchanted item matching the chosen option (0, 1, 2)
404  Ownership of the cItem is transferred to the caller. */
405  cItem SelectEnchantedOption(size_t a_EnchantOption);
406 
407 protected:
408 
410  void UpdateResult(cPlayer & a_Player);
411 
413  std::array<cItem, 3> m_EnchantedItemOptions;
414 };
415 
416 
417 
418 
419 
421  public cSlotArea
422 {
423 public:
424  cSlotAreaChest(cChestEntity * a_Chest, cWindow & a_ParentWindow);
425 
426  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
427  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
428 
429 protected:
431 } ;
432 
433 
434 
435 
436 
438  public cSlotArea
439 {
440 public:
441  cSlotAreaDoubleChest(cChestEntity * a_TopChest, cChestEntity * a_BottomChest, cWindow & a_ParentWindow);
442 
443  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
444  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
445 
446 protected:
449 } ;
450 
451 
452 
453 
454 
456  public cSlotArea
457 {
458 public:
459  cSlotAreaEnderChest(cEnderChestEntity * a_EnderChest, cWindow & a_ParentWindow);
460 
461  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
462  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
463 
464 protected:
466 };
467 
468 
469 
470 
471 
473  public cSlotArea,
474  public cItemGrid::cListener
475 {
476  using Super = cSlotArea;
477 
478 public:
479 
480  cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow);
481 
482  virtual ~cSlotAreaFurnace() override;
483 
484  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
485  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
486  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
487  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
488 
489 protected:
491 
492  // cItemGrid::cListener overrides:
493  virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
494 
496  void HandleSmeltItem(const cItem & a_Result, cPlayer & a_Player);
497 } ;
498 
499 
500 
501 
502 
504  public cSlotArea,
505  public cItemGrid::cListener
506 {
507  using Super = cSlotArea;
508 
509 public:
510 
511  cSlotAreaBrewingstand(cBrewingstandEntity * a_Brewingstand, cWindow & a_ParentWindow);
512 
513  virtual ~cSlotAreaBrewingstand() override;
514 
515  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
516  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
517  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
518  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
519 protected:
521 
522  // cItemGrid::cListener overrides:
523  virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
524 
526  void HandleBrewedItem(cPlayer & a_Player, const cItem & a_ClickedItem);
527 } ;
528 
529 
530 
531 
532 
534  public cSlotArea
535 {
536 public:
537  cSlotAreaMinecartWithChest(cMinecartWithChest * a_ChestCart, cWindow & a_ParentWindow);
538 
539  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
540  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
541 
542 protected:
544 };
545 
546 
547 
548 
549 
552  public cSlotArea
553 {
554 public:
555  enum
556  {
558  ArmorSlot
559  };
560 
561  cSlotAreaHorse(cHorse & a_Horse, cWindow & a_ParentWindow);
562  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
563  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
564  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
565  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
566 private:
568 };
eClickAction
Individual actions sent in the WindowClick packet.
Definition: Defines.h:82
unsigned int UInt32
Definition: Globals.h:157
Definition: Player.h:29
This class represents the player's inventory The slots are divided into three areas:
Definition: Inventory.h:36
Definition: Item.h:37
This class is used as a callback for when a slot changes.
Definition: ItemGrid.h:26
Definition: Horse.h:14
virtual void NumberClicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction)
Called from Clicked when the action is a number click.
Definition: SlotArea.cpp:311
cWindow & m_ParentWindow
Definition: SlotArea.h:86
virtual void OnPlayerAdded(cPlayer &a_Player)
Called when a new player opens the same parent window.
Definition: SlotArea.cpp:336
int m_NumSlots
Definition: SlotArea.h:85
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.
Definition: SlotArea.cpp:354
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem)
Called when a player clicks in the window.
Definition: SlotArea.cpp:43
cSlotArea(int a_NumSlots, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:33
virtual void DblClicked(cPlayer &a_Player, int a_SlotNum)
Called from Clicked when the action is a caDblClick.
Definition: SlotArea.cpp:235
virtual void DropClicked(cPlayer &a_Player, int a_SlotNum, bool a_DropStack)
Called from Clicked when the action is a drop click.
Definition: SlotArea.cpp:283
virtual ~cSlotArea()
Definition: SlotArea.h:37
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
Definition: SlotArea.h:39
virtual void OnPlayerRemoved(cPlayer &a_Player)
Called when one of the players closes the parent window.
Definition: SlotArea.cpp:345
virtual void MiddleClicked(cPlayer &a_Player, int a_SlotNum)
Called from Clicked when the action is a middleclick.
Definition: SlotArea.cpp:265
virtual bool CollectItemsToHand(cItem &a_Dragging, cPlayer &a_Player, bool a_CollectFullStacks)
Called on DblClicking to collect all stackable items into hand.
Definition: SlotArea.cpp:392
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)
Definition: SlotArea.cpp:215
Handles any part of the inventory, using parameters in constructor to distinguish between the parts.
Definition: SlotArea.h:96
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.
Definition: SlotArea.cpp:2417
cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:2407
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.
Definition: SlotArea.cpp:2450
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.
Definition: SlotArea.cpp:2440
Handles the main inventory of each player, excluding the armor and hotbar.
Definition: SlotArea.h:120
cSlotAreaInventory(cWindow &a_ParentWindow)
Definition: SlotArea.h:125
Handles the hotbar of each player.
Definition: SlotArea.h:138
cSlotAreaHotBar(cWindow &a_ParentWindow)
Definition: SlotArea.h:142
Handles the shield of each player.
Definition: SlotArea.h:155
cSlotAreaShield(cWindow &a_ParentWindow)
Definition: SlotArea.h:160
Handles the armor area of the player's inventory.
Definition: SlotArea.h:173
static bool CanPlaceArmorInSlot(int a_SlotNum, const cItem &a_Item)
Definition: SlotArea.cpp:2585
cSlotAreaArmor(cWindow &a_ParentWindow)
Definition: SlotArea.h:178
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.
Definition: SlotArea.cpp:2502
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....
Definition: SlotArea.cpp:2462
Handles any slot area that is representing a cItemGrid; same items for all the players.
Definition: SlotArea.h:200
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
Definition: SlotArea.cpp:2642
cSlotAreaItemGrid(cItemGrid &a_ItemGrid, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:2604
virtual ~cSlotAreaItemGrid() override
Definition: SlotArea.cpp:2615
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.
Definition: SlotArea.cpp:2633
cItemGrid & m_ItemGrid
Definition: SlotArea.h:213
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.
Definition: SlotArea.cpp:2624
A cSlotArea with items layout that is private to each player and is temporary, such as a crafting gri...
Definition: SlotArea.h:228
void TossItems(cPlayer &a_Player, int a_Begin, int a_End)
Tosses the player's items in slots [a_Begin, a_End) (ie.
Definition: SlotArea.cpp:2736
cSlotAreaTemporary(int a_NumSlots, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:2655
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.
Definition: SlotArea.cpp:2664
cItemMap m_Items
Definition: SlotArea.h:247
std::map< UInt32, std::vector< cItem > > cItemMap
Definition: SlotArea.h:245
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.
Definition: SlotArea.cpp:2690
virtual void OnPlayerRemoved(cPlayer &a_Player) override
Called when one of the players closes the parent window.
Definition: SlotArea.cpp:2725
cItem * GetPlayerSlots(cPlayer &a_Player)
Returns the pointer to the slot array for the player specified.
Definition: SlotArea.cpp:2763
virtual void OnPlayerAdded(cPlayer &a_Player) override
Called when a new player opens the same parent window.
Definition: SlotArea.cpp:2715
virtual void OnPlayerRemoved(cPlayer &a_Player) override
Called when one of the players closes the parent window.
Definition: SlotArea.cpp:566
void UpdateRecipe(cPlayer &a_Player)
Updates the current recipe and result slot based on the ingredients currently in the crafting grid of...
Definition: SlotArea.cpp:728
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.
Definition: SlotArea.cpp:602
cRecipeMap m_Recipes
Definition: SlotArea.h:288
void ClearCraftingGrid(cPlayer &a_Player)
Clear the crafting grid.
Definition: SlotArea.cpp:833
virtual void DblClicked(cPlayer &a_Player, int a_SlotNum) override
Called from Clicked when the action is a caDblClick.
Definition: SlotArea.cpp:552
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.
Definition: SlotArea.cpp:588
std::list< std::pair< UInt32, cCraftingRecipe > > cRecipeMap
Maps player's EntityID -> current recipe.
Definition: SlotArea.h:285
void DropClickedResult(cPlayer &a_Player)
Handles a drop-click in the result slot.
Definition: SlotArea.cpp:707
cSlotAreaCrafting(int a_GridSize, cWindow &a_ParentWindow)
a_GridSize is allowed to be only 2 or 3
Definition: SlotArea.cpp:507
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.
Definition: SlotArea.cpp:518
void ClickedResult(cPlayer &a_Player)
Handles a click in the result slot.
Definition: SlotArea.cpp:615
void HandleCraftItem(const cItem &a_Result, cPlayer &a_Player)
Called after an item has been crafted to handle statistics e.t.c.
Definition: SlotArea.cpp:762
cCraftingRecipe & GetRecipeForPlayer(cPlayer &a_Player)
Retrieves the recipe for the specified player from the map, or creates one if not found.
Definition: SlotArea.cpp:740
void LoadRecipe(cPlayer &a_Player, UInt32 a_RecipeId)
Loads the given Recipe into the crafting grid.
Definition: SlotArea.cpp:784
void ShiftClickedResult(cPlayer &a_Player)
Handles a shift-click in the result slot.
Definition: SlotArea.cpp:658
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.
Definition: SlotArea.cpp:992
virtual void OnPlayerRemoved(cPlayer &a_Player) override
Called when one of the players closes the parent window.
Definition: SlotArea.cpp:1115
cSlotAreaAnvil(cWindow &a_ParentWindow)
Definition: SlotArea.cpp:851
char m_StackSizeToBeUsedInRepair
The stack size of the second item where was used for repair.
Definition: SlotArea.h:346
int m_MaximumCost
The maximum cost of repairing / renaming in the anvil.
Definition: SlotArea.h:343
void OnTakeResult(cPlayer &a_Player)
This function will call, when the player take the item from the slot.
Definition: SlotArea.cpp:1032
bool CanTakeResultItem(cPlayer &a_Player)
Can the player take the item from the slot?
Definition: SlotArea.cpp:1099
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)
Definition: SlotArea.cpp:959
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.
Definition: SlotArea.cpp:862
void UpdateResult(cPlayer &a_Player)
Handles a click in the item slot.
Definition: SlotArea.cpp:1125
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.
Definition: SlotArea.cpp:1464
static bool IsPlaceableItem(short a_ItemType)
Definition: SlotArea.cpp:1311
cBeaconEntity * m_Beacon
Definition: SlotArea.h:372
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.
Definition: SlotArea.cpp:1454
cSlotAreaBeacon(cBeaconEntity *a_Beacon, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:1291
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
Definition: SlotArea.cpp:1474
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.
Definition: SlotArea.cpp:1435
virtual ~cSlotAreaBeacon() override
Definition: SlotArea.cpp:1302
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.
Definition: SlotArea.cpp:1333
virtual void OnPlayerRemoved(cPlayer &a_Player) override
Called when one of the players closes the parent window.
Definition: SlotArea.cpp:1669
void UpdateResult(cPlayer &a_Player)
Handles a click in the item slot.
Definition: SlotArea.cpp:1691
std::array< cItem, 3 > m_EnchantedItemOptions
Definition: SlotArea.h:413
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.
Definition: SlotArea.cpp:1681
unsigned GetBookshelvesCount(cWorld &a_World)
Definition: SlotArea.cpp:1755
cSlotAreaEnchanting(cWindow &a_ParentWindow, Vector3i a_BlockPos)
Definition: SlotArea.cpp:1490
cItem SelectEnchantedOption(size_t a_EnchantOption)
Definition: SlotArea.cpp:1821
Vector3i m_BlockPos
Definition: SlotArea.h:412
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.
Definition: SlotArea.cpp:1614
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.
Definition: SlotArea.cpp:1500
virtual void OnPlayerAdded(cPlayer &a_Player) override
Called when a new player opens the same parent window.
Definition: SlotArea.cpp:1659
cChestEntity * m_Chest
Definition: SlotArea.h:430
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.
Definition: SlotArea.cpp:448
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.
Definition: SlotArea.cpp:438
cSlotAreaChest(cChestEntity *a_Chest, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:428
cSlotAreaDoubleChest(cChestEntity *a_TopChest, cChestEntity *a_BottomChest, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:460
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.
Definition: SlotArea.cpp:471
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.
Definition: SlotArea.cpp:488
cChestEntity * m_BottomChest
Definition: SlotArea.h:448
cChestEntity * m_TopChest
Definition: SlotArea.h:447
cSlotAreaEnderChest(cEnderChestEntity *a_EnderChest, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:1834
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.
Definition: SlotArea.cpp:1844
cEnderChestEntity * m_EnderChest
Definition: SlotArea.h:465
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.
Definition: SlotArea.cpp:1853
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.
Definition: SlotArea.cpp:2083
void HandleSmeltItem(const cItem &a_Result, cPlayer &a_Player)
Called after an item has been smelted to handle statistics etc.
Definition: SlotArea.cpp:2105
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.
Definition: SlotArea.cpp:2022
cFurnaceEntity * m_Furnace
Definition: SlotArea.h:490
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
Definition: SlotArea.cpp:2092
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.
Definition: SlotArea.cpp:2072
virtual ~cSlotAreaFurnace() override
Definition: SlotArea.cpp:1876
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.
Definition: SlotArea.cpp:1885
cSlotAreaFurnace(cFurnaceEntity *a_Furnace, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:1865
virtual ~cSlotAreaBrewingstand() override
Definition: SlotArea.cpp:2139
cSlotAreaBrewingstand(cBrewingstandEntity *a_Brewingstand, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:2128
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
Definition: SlotArea.cpp:2357
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.
Definition: SlotArea.cpp:2347
cBrewingstandEntity * m_Brewingstand
Definition: SlotArea.h:520
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.
Definition: SlotArea.cpp:2148
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.
Definition: SlotArea.cpp:2274
void HandleBrewedItem(cPlayer &a_Player, const cItem &a_ClickedItem)
Called after an item has been brewed to handle statistics etc.
Definition: SlotArea.cpp:2261
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.
Definition: SlotArea.cpp:2336
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.
Definition: SlotArea.cpp:2383
cSlotAreaMinecartWithChest(cMinecartWithChest *a_ChestCart, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:2373
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.
Definition: SlotArea.cpp:2394
cMinecartWithChest * m_Chest
Definition: SlotArea.h:543
Slot area holding horse saddle and armor.
Definition: SlotArea.h:553
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.
Definition: SlotArea.cpp:2837
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.
Definition: SlotArea.cpp:2873
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.
Definition: SlotArea.cpp:2856
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.
Definition: SlotArea.cpp:2790
cHorse & m_Horse
Definition: SlotArea.h:567
cSlotAreaHorse(cHorse &a_Horse, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:2780
Represents a UI window.
Definition: Window.h:54
Definition: World.h:53