8 #include "../Entities/Player.h"
9 #include "../BlockEntities/BeaconEntity.h"
10 #include "../BlockEntities/BrewingstandEntity.h"
11 #include "../BlockEntities/ChestEntity.h"
12 #include "../BlockEntities/DropSpenserEntity.h"
13 #include "../BlockEntities/EnderChestEntity.h"
14 #include "../BlockEntities/FurnaceEntity.h"
15 #include "../Entities/Minecart.h"
16 #include "../Items/ItemHandler.h"
18 #include "../CraftingRecipes.h"
20 #include "../FastRandom.h"
21 #include "../BlockArea.h"
22 #include "../EffectID.h"
23 #include "../ClientHandle.h"
24 #include "../Mobs/Horse.h"
34 m_NumSlots(a_NumSlots),
35 m_ParentWindow(a_ParentWindow)
56 if (
GetSlot(a_SlotNum, a_Player) ==
nullptr)
58 LOGWARNING(
"GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
70 switch (a_ClickAction)
116 LOGWARNING(
"*** Window lost sync at item %d in SlotArea with %d items ***", a_SlotNum,
m_NumSlots);
122 switch (a_ClickAction)
153 DraggingItem.
Empty();
156 else if (!DraggingItem.
IsEqual(Slot))
159 cItem tmp(DraggingItem);
169 if (!DraggingItem.
IsEqual(Slot))
172 cItem tmp(DraggingItem);
182 ASSERT(!
"Bad item stack size - where did we get more items in a slot than allowed?");
185 char Filling =
static_cast<char>((FreeSlots > DraggingItem.
m_ItemCount) ? DraggingItem.
m_ItemCount : FreeSlots);
191 DraggingItem.
Empty();
204 SetSlot(a_SlotNum, a_Player, Slot);
225 SetSlot(a_SlotNum, a_Player, Slot);
241 Dragging = *
GetSlot(a_SlotNum, a_Player);
243 SetSlot(a_SlotNum, a_Player, EmptyItem);
247 LOGD(
"%s DblClicked with an empty hand over empty slot, ignoring", a_Player.
GetName().c_str());
302 SetSlot(a_SlotNum, a_Player, Slot);
318 int HotbarSlot =
static_cast<int>(a_ClickAction -
caNumber1);
323 if (ItemInHotbar.
IsEqual(ItemInSlot))
329 SetSlot(a_SlotNum, a_Player, ItemInHotbar);
358 int SlotNum = (a_BackFill) ? (
m_NumSlots - 1 - i) : i;
361 if (!Slot->
IsEqual(a_ItemStack) && (!Slot->
IsEmpty() || a_KeepEmptySlots))
372 NumFit = std::min(NumFit, a_ItemStack.
m_ItemCount);
376 cItem NewSlot(a_ItemStack);
378 SetSlot(SlotNum, a_Player, NewSlot);
395 for (
int i = 0; i < NumSlots; i++)
398 if (!SlotItem.
IsEqual(a_Dragging))
408 cItem NewSlot(SlotItem);
462 m_TopChest(a_TopChest),
463 m_BottomChest(a_BottomChest)
509 m_GridSize(a_GridSize)
511 ASSERT((a_GridSize == 2) || (a_GridSize == 3));
544 Super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
572 for (cRecipeMap::iterator itr =
m_Recipes.begin(), end =
m_Recipes.end(); itr != end; ++itr)
629 DraggingItem = Result;
635 else if (DraggingItem.
IsEqual(Result))
670 cItem ResultCopy(Result);
742 for (cRecipeMap::iterator itr =
m_Recipes.begin(), end =
m_Recipes.end(); itr != end; ++itr)
795 for (
auto itrS = Recipe->m_Ingredients.begin(); itrS != Recipe->m_Ingredients.end(); ++itrS)
798 if (FoundItem ==
nullptr)
807 if ((itrS->x == -1) && (itrS->y == -1))
812 else if (itrS->x == -1)
817 auto itemCheck =
GetSlot(pos, a_Player);
818 if (itemCheck->IsEmpty())
838 if (
Item->m_ItemCount > 0)
854 m_StackSizeToBeUsedInRepair(0)
867 Super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
873 if (
GetSlot(a_SlotNum, a_Player) ==
nullptr)
875 LOGWARNING(
"GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
879 switch (a_ClickAction)
915 LOGWARNING(
"*** Window lost sync at item %d in SlotArea with %d items ***", a_SlotNum,
m_NumSlots);
943 DraggingItem.
Empty();
944 SetSlot(a_SlotNum, a_Player, Slot);
946 DraggingItem = NewItem;
982 SetSlot(a_SlotNum, a_Player, Slot);
994 for (
int i = 0; i < 2; i++)
996 int SlotNum = (a_BackFill) ? (2 - 1 - i) : i;
999 if (!Slot->
IsEqual(a_ItemStack) && (!Slot->
IsEmpty() || a_KeepEmptySlots))
1010 NumFit = std::min(NumFit, a_ItemStack.
m_ItemCount);
1014 cItem NewSlot(a_ItemStack);
1016 SetSlot(SlotNum, a_Player, NewSlot);
1048 SetSlot(1, a_Player, NewSecondItem);
1076 if (AnvilDamage > 2)
1106 (!
GetSlot(2, a_Player)->IsEmpty()) &&
1144 int RepairCost =
Target.m_RepairCost;
1154 int DamageDiff = std::min(
static_cast<int>(
Target.m_ItemDamage),
static_cast<int>(
Target.GetMaxDamage()) / 4);
1155 if (DamageDiff <= 0)
1165 char NumItemsConsumed = 0;
1168 while ((DamageDiff > 0) && (NumItemsConsumed < Sacrifice.
m_ItemCount))
1171 NeedExp += std::max(1, DamageDiff / 100) +
static_cast<int>(
Target.m_Enchantments.Count());
1172 DamageDiff = std::min(
static_cast<int>(Output.
m_ItemDamage),
static_cast<int>(
Target.GetMaxDamage()) / 4);
1183 if (!IsEnchantBook && (!
Target.IsSameType(Sacrifice) || !
Target.IsDamageable()))
1194 if (
Target.IsDamageable() && !IsEnchantBook && (
Target.m_ItemDamage!=0))
1197 const short TargetDurability =
Target.GetMaxDamage() -
Target.m_ItemDamage;
1201 const short RepairDurability = SacrificeDurability +
Target.GetMaxDamage() * 12 / 100;
1204 short NewItemDamage = std::max<short>(
Target.GetMaxDamage() - (TargetDurability + RepairDurability), 0);
1206 if (NewItemDamage <
Target.m_ItemDamage)
1209 NeedExp += std::max(1, RepairDurability / 100);
1215 NeedExp += EnchantmentCost;
1219 int NameChangeExp = 0;
1221 if (RepairedItemName.empty())
1224 if (!
Target.m_CustomName.empty())
1226 NameChangeExp = (
Target.IsDamageable()) ? 7 : (
Target.m_ItemCount * 5);
1227 NeedExp += NameChangeExp;
1231 else if (RepairedItemName !=
Target.m_CustomName)
1234 NameChangeExp = (
Target.IsDamageable()) ? 7 : (
Target.m_ItemCount * 5);
1235 NeedExp += NameChangeExp;
1237 if (!
Target.m_CustomName.empty())
1239 RepairCost += NameChangeExp / 2;
1252 if ((NameChangeExp == NeedExp) && (NameChangeExp > 0) && (
m_MaximumCost >= 40))
1268 RepairCost = std::max(RepairCost, 0);
1274 if (
Target.IsEqual(Output))
1337 bool bAsync =
false;
1338 if (
GetSlot(a_SlotNum, a_Player) ==
nullptr)
1340 LOGWARNING(
"GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
1344 switch (a_ClickAction)
1385 LOGWARNING(
"*** Window lost sync at item %d in SlotArea with %d items ***", a_SlotNum,
m_NumSlots);
1394 DraggingItem = Slot;
1404 Slot = DraggingItem.
CopyOne();
1408 DraggingItem.
Empty();
1419 cItem tmp(DraggingItem);
1420 DraggingItem = Slot;
1424 SetSlot(a_SlotNum, a_Player, Slot);
1447 a_ItemStack.
Empty();
1492 m_BlockPos(a_BlockPos)
1504 bool bAsync =
false;
1505 if (
GetSlot(a_SlotNum, a_Player) ==
nullptr)
1507 LOGWARNING(
"GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
1511 switch (a_ClickAction)
1557 LOGWARNING(
"*** Window lost sync at item %d in SlotArea with %d items ***", a_SlotNum,
m_NumSlots);
1583 std::swap(DraggingItem, Slot);
1589 Slot = DraggingItem.
CopyOne();
1594 DraggingItem.
Empty();
1600 std::swap(DraggingItem, Slot);
1603 SetSlot(a_SlotNum, a_Player, Slot);
1626 NumFit = std::min(NumFit, a_ItemStack.
m_ItemCount);
1630 cItem NewSlot(a_ItemStack);
1632 SetSlot(1, a_Player, NewSlot);
1651 a_ItemStack.
Empty();
1707 const auto Base = (Random.RandInt(1U, 8U) + (Bookshelves / 2) + Random.RandInt(0U, Bookshelves));
1708 const std::array<unsigned, 3> OptionLevels
1710 std::max(Base / 3, 1U),
1712 std::max(Base, Bookshelves * 2)
1720 for (
size_t i = 0; i != OptionLevels.size(); i++)
1735 const auto EnchantmentID =
static_cast<short>(EnchantedItem.
m_Enchantments.
begin()->first);
1741 ASSERT(EnchantmentLevel > 0);
1762 int m_BookX, m_BookY, m_BookZ;
1763 int m_AirX, m_AirY, m_AirZ;
1766 { 0, 0, 0, 1, 0, 1 },
1767 { 0, 0, 1, 1, 0, 1 },
1768 { 0, 0, 2, 1, 0, 2 },
1769 { 0, 0, 3, 1, 0, 3 },
1770 { 0, 0, 4, 1, 0, 3 },
1771 { 1, 0, 4, 1, 0, 3 },
1772 { 2, 0, 4, 2, 0, 3 },
1773 { 3, 0, 4, 3, 0, 3 },
1774 { 4, 0, 4, 3, 0, 3 },
1775 { 4, 0, 3, 3, 0, 3 },
1776 { 4, 0, 2, 3, 0, 2 },
1777 { 4, 0, 1, 3, 0, 1 },
1778 { 4, 0, 0, 3, 0, 1 },
1779 { 3, 0, 0, 3, 0, 1 },
1780 { 2, 0, 0, 2, 0, 1 },
1781 { 1, 0, 0, 1, 0, 1 },
1783 { 0, 1, 0, 1, 1, 1 },
1784 { 0, 1, 1, 1, 1, 1 },
1785 { 0, 1, 2, 1, 1, 2 },
1786 { 0, 1, 3, 1, 1, 3 },
1787 { 0, 1, 4, 1, 1, 3 },
1788 { 1, 1, 4, 1, 1, 3 },
1789 { 2, 1, 4, 2, 1, 3 },
1790 { 3, 1, 4, 3, 1, 3 },
1791 { 4, 1, 4, 3, 1, 3 },
1792 { 4, 1, 3, 3, 1, 3 },
1793 { 4, 1, 2, 3, 1, 2 },
1794 { 4, 1, 1, 3, 1, 1 },
1795 { 4, 1, 0, 3, 1, 1 },
1796 { 3, 1, 0, 3, 1, 1 },
1797 { 2, 1, 0, 2, 1, 1 },
1798 { 1, 1, 0, 1, 1, 1 },
1801 unsigned Bookshelves = 0;
1803 for (
size_t i = 0; i <
ARRAYCOUNT(CheckCoords); i++)
1836 m_EnderChest(a_EnderChest)
1867 m_Furnace(a_Furnace)
1889 LOGERROR(
"cSlotAreaFurnace::Clicked(): m_Furnace == nullptr");
1890 ASSERT(!
"cSlotAreaFurnace::Clicked(): m_Furnace == nullptr");
1905 else if (a_SlotNum == 2)
1907 bool bAsync =
false;
1908 if (
GetSlot(a_SlotNum, a_Player) ==
nullptr)
1910 LOGWARNING(
"GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
1917 LOGWARNING(
"*** Window lost sync at item %d in SlotArea with %d items ***", a_SlotNum,
m_NumSlots);
1923 switch (a_ClickAction)
1958 if (!DraggingItem.
IsEqual(Slot))
1973 switch (a_ClickAction)
1982 DraggingItem = Slot;
1989 DraggingItem = Slot.
CopyOne();
2002 ASSERT(!
"Unhandled click type!");
2007 SetSlot(a_SlotNum, a_Player, Slot);
2015 Super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
2031 else if (FurnaceRecipes->
IsFuel(a_ItemStack))
2041 if (!Slot->
IsEqual(a_ItemStack) && (!Slot->
IsEmpty() || a_KeepEmptySlots))
2053 NumFit = std::min(NumFit, a_ItemStack.
m_ItemCount);
2057 cItem NewSlot(a_ItemStack);
2059 SetSlot(SlotNum, a_Player, NewSlot);
2130 m_Brewingstand(a_Brewingstand)
2152 LOGERROR(
"cSlotAreaBrewingstand::Clicked(): m_Brewingstand == nullptr");
2153 ASSERT(!
"cSlotAreaBrewingstand::Clicked(): m_Brewingstand == nullptr");
2157 if (
GetSlot(a_SlotNum, a_Player) ==
nullptr)
2159 LOGWARNING(
"GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
2167 if ((a_SlotNum >= 0) && (a_SlotNum <= 2))
2170 switch (a_ClickAction)
2208 if ((a_SlotNum == 3) && !DraggingItem.
IsEmpty())
2211 switch (a_ClickAction)
2231 if ((a_SlotNum == 4) && !DraggingItem.
IsEmpty())
2234 switch (a_ClickAction)
2244 if (!BR->
IsFuel(DraggingItem))
2254 Super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
2280 for (
int i = 0;i < 3;i++)
2282 if (
GetSlot(i, a_Player)->IsEmpty())
2305 if (!Slot->
IsEqual(a_ItemStack) && (!Slot->
IsEmpty() || a_KeepEmptySlots))
2317 NumFit = std::min(NumFit, a_ItemStack.
m_ItemCount);
2321 cItem NewSlot(a_ItemStack);
2323 SetSlot(SlotNum, a_Player, NewSlot);
2409 m_SlotOffset(a_SlotOffset)
2428 SetSlot(a_SlotNum, a_Player, a_ClickedItem);
2433 Super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
2515 SetSlot(a_SlotNum, a_Player, a_ClickedItem);
2519 bool bAsync =
false;
2520 if (
GetSlot(a_SlotNum, a_Player) ==
nullptr)
2522 LOGWARNING(
"GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
2526 switch (a_ClickAction)
2553 LOGWARNING(
"*** Window lost sync at item %d in SlotArea with %d items ***", a_SlotNum,
m_NumSlots);
2569 cItem tmp(DraggingItem);
2570 DraggingItem = Slot;
2574 SetSlot(a_SlotNum, a_Player, Slot);
2593 default:
return false;
2605 Super(a_ItemGrid.GetNumSlots(), a_ParentWindow),
2606 m_ItemGrid(a_ItemGrid)
2669 LOGERROR(
"cSlotAreaTemporary: player \"%s\" not found for slot %d!", a_Player.
GetName().c_str(), a_SlotNum);
2670 ASSERT(!
"cSlotAreaTemporary: player not found!");
2676 if (a_SlotNum >=
static_cast<int>(itr->second.size()))
2678 LOGERROR(
"cSlotAreaTemporary: asking for more slots than actually stored!");
2679 ASSERT(!
"cSlotAreaTemporary: asking for more slots than actually stored!");
2683 return &(itr->second[
static_cast<size_t>(a_SlotNum)]);
2696 LOGWARNING(
"cSlotAreaTemporary: player not found!");
2700 if (a_SlotNum >=
static_cast<int>(itr->second.size()))
2702 LOGERROR(
"cSlotAreaTemporary: asking for more slots than actually stored!");
2706 itr->second[
static_cast<size_t>(a_SlotNum)] = a_Item;
2741 LOGWARNING(
"Player tossing items (%s) not found in the item map", a_Player.
GetName().c_str());
2746 for (
int i = a_Begin; i < a_End; i++)
2748 cItem &
Item = itr->second[
static_cast<size_t>(i)];
2749 if (!
Item.IsEmpty())
2751 Drops.push_back(
Item);
2770 return itr->second.data();
2794 switch (a_ClickAction)
2839 static const cItem InvalidItem;
2846 LOGWARN(
"cSlotAreaHorse::GetSlot: Invalid slot number %d", a_SlotNum);
2847 return &InvalidItem;
2864 LOGWARN(
"cSlotAreaHorse::SetSlot: Invalid slot number %d", a_SlotNum);
AString ItemToFullString(const cItem &a_Item)
Translates a full item into a fully-specified string (including meta and count).
@ E_BLOCK_ENCHANTMENT_TABLE
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
const char * ClickActionToString(int a_ClickAction)
Returns a textual representation of the click action.
eClickAction
Individual actions sent in the WindowClick packet.
MTRand & GetRandomProvider()
Returns the current thread's random number source.
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
void LOGERROR(std::string_view a_Format, const Args &... args)
void LOGWARNING(std::string_view a_Format, const Args &... args)
bool IsHelmet(short a_ItemType)
bool IsLeggings(short a_ItemType)
bool IsChestPlate(short a_ItemType)
bool IsBoots(short a_ItemType)
bool IsHorseArmor(short a_ItemType)
BLOCKTYPE GetRelBlockType(int a_RelX, int a_RelY, int a_RelZ) const
bool Read(cForEachChunkProvider &a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes=baTypes|baMetas|baBlockEntities)
Reads an area of blocks specified.
cItemGrid & GetContents(void)
Returns the ItemGrid used for storing the contents.
const cItem & GetSlot(int a_SlotNum) const
void SetSlot(int a_SlotNum, const cItem &a_Item)
int GetAndResetReward(void)
Calculates, resets, and returns the experience reward in this furnace.
bool IsIngredient(const cItem &a_Ingredient) const
Returns true if the item is a ingredient, false if not.
bool IsBottle(const cItem &a_Item) const
Returns true if the item is a bottle / potion, false if not.
bool IsFuel(const cItem &a_Item) const
Returns true if the item is the fuel, false if not.
void SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem &a_Item)
void CopyToItems(cItem *a_Items) const
Copies internal contents into the item array specified.
void ConsumeIngredients(cCraftingGrid &a_CraftingGrid)
Consumes ingredients from the crafting grid specified.
const cItem & GetResult(void) const
void GetRecipe(cPlayer &a_Player, cCraftingGrid &a_CraftingGrid, cCraftingRecipe &a_Recipe)
Returns the recipe for current crafting grid.
cRecipe * GetRecipeById(UInt32 a_RecipeId)
Returns the recipe by id.
unsigned int GetLevel(int a_EnchantmentID) const
Returns the level for the specified enchantment; 0 if not stored.
AString ToString(void) const
Serializes all the enchantments into a string.
cMap::const_iterator end() const
cMap::const_iterator begin() const
Make this class iterable.
double GetPosX(void) const
double GetPosZ(void) const
UInt32 GetUniqueID(void) const
double GetPosY(void) const
cWorld * GetWorld(void) const
const cItem & GetSlot(int a_Idx) const
void SetSlot(int a_Idx, const cItem &a_Item)
cClientHandle * GetClientHandle(void) const
const AString & GetName(void) const
void AwardAchievement(CustomStatistic a_Ach)
Awards the player an achievement.
void CloseWindow(bool a_CanRefuse=true)
Closes the current window, resets current window to m_InventoryWindow.
void TossItems(const cItems &a_Items)
Tosses a list of items.
void AddKnownItem(const cItem &a_Item)
Adds an Item to the list of known items.
void TossPickup(const cItem &a_Item)
tosses a pickup newly created from a_Item
int DeltaExperience(int a_Xp_delta)
int GetXpLevel(void) const
Gets the current level - XpLevel.
bool IsGameModeCreative(void) const
Returns true if the player is in Creative mode, either explicitly, or by inheriting from current worl...
cInventory & GetInventory(void)
cItem & GetDraggingItem(void)
In UI windows, get the item that the player is dragging.
bool IsGameModeSpectator(void) const
Returns true if the player is in Spectator mode, either explicitly, or by inheriting from current wor...
cItemGrid & GetEnderChestContents(void)
Gets the contents of the player's associated enderchest.
MTRand GetEnchantmentRandomProvider()
Get a copy of the PRNG for enchanting related generation, don't use this for other purposes.
static int XpForLevel(int a_Level)
Calculates the amount of XP needed for a given level Ref: https://minecraft.wiki/w/XP.
bool RandBool(double a_TrueProbability=0.5)
Return a random bool with the given probability of being true.
const cRecipe * GetRecipeFrom(const cItem &a_Ingredient) const
Returns a recipe for the specified input, nullptr if no recipe found.
bool IsFuel(const cItem &a_Item) const
Returns true if the item is a fuel, false if not.
char AddItem(const cItem &a_ItemStack, bool a_AllowNewStacks=true)
Adds as many items out of a_ItemStack as can fit.
const cItem & GetHotbarSlot(int a_HotBarSlotNum) const
Returns current item in a_ArmorSlotNum in hotbar slots.
cItem * FindItem(const cItem &a_RecipeItem)
Finds an item based on ItemType and ItemDamage (<- defines the itemType, too)
void SetSlot(int a_SlotNum, const cItem &a_Item)
Puts a_Item item in a_SlotNum slot number.
const cItem & GetSlot(int a_SlotNum) const
Returns current item in a_SlotNum slot.
void SetHotbarSlot(int a_HotBarSlotNum, const cItem &a_Item)
Puts a_Item item in a_HotBarSlotNum slot number in hotbar slots.
int RemoveItem(const cItem &a_ItemStack)
Removes the specified item from the inventory, as many as possible, up to a_ItemStack....
static bool IsEnchantable(short a_ItemType, bool a_FromBook=false)
Returns true if the specified item type is enchantable.
cEnchantments m_Enchantments
bool EnchantByXPLevels(unsigned a_NumXPLevels, MTRand &a_Random)
Randomly enchants the item using the specified number of XP levels.
char GetMaxStackSize(void) const
Returns the maximum amount of stacked items of this type.
bool IsEmpty(void) const
Returns true if the item represents an empty stack - either the type is invalid, or count is zero.
bool IsEqual(const cItem &a_Item) const
int AddEnchantmentsFromItem(const cItem &a_Other)
Adds the enchantments on a_Other to this item, returning the XP cost of the transfer.
void Empty(void)
Empties the item and frees up any dynamic storage used by the internals.
short GetMaxDamage(void) const
Returns the maximum damage value that this item can have; zero if damage is not applied.
bool IsFullStack(void) const
Returns true if the item is stacked up to its maximum stacking.
cItem CopyOne(void) const
Returns a copy of this item with m_ItemCount set to 1.
bool IsSameType(const cItem &a_Item) const
This class bridges a vector of cItem for safe access via Lua.
void SetSlot(int a_X, int a_Y, const cItem &a_Item)
const cItem & GetSlot(int a_X, int a_Y) const
void AddListener(cListener &a_Listener)
Adds a callback that gets called whenever a slot changes.
void RemoveListener(cListener &a_Listener)
Removes a slot-change-callback.
const cItem & GetHorseArmorItem() const
void SetHorseSaddle(cItem a_SaddleItem)
Set the horse's saddle to the given item.
bool IsSaddled(void) const
void SetHorseArmor(cItem a_ArmorItem)
Set the horse's armor slot to the given item.
const cItem & GetHorseSaddle() const
cFurnaceRecipe * GetFurnaceRecipe(void)
cBrewingRecipes * GetBrewingRecipes(void)
cCraftingRecipes * GetCraftingRecipes(void)
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)
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.
static bool CanPlaceArmorInSlot(int a_SlotNum, const cItem &a_Item)
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....
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.
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.
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.
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
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)
virtual void SetProperty(size_t a_Property, short a_Value)
Updates a numerical property associated with the window.
void BroadcastWholeWindow(void)
Sends the contents of the whole window to all clients of this window.
virtual void DistributeStack(cItem &a_ItemStack, int a_Slot, cPlayer &a_Player, cSlotArea *a_ClickedArea, bool a_ShouldApply)=0
Called on shift-clicking to distribute the stack into other areas; Modifies a_ItemStack as it is dist...
bool CollectItemsToHand(cItem &a_Dragging, cSlotArea &a_Area, cPlayer &a_Player, bool a_CollectFullStacks)
Called on DblClicking to collect all stackable items from all areas into hand.
void SendSlot(cPlayer &a_Player, cSlotArea *a_SlotArea, int a_RelativeSlotNum)
Used by cSlotAreas to send individual slots to clients, a_RelativeSlotNum is the slot number relative...
int GetWindowType(void) const
void BroadcastSlot(cSlotArea *a_Area, int a_LocalSlotNum)
Sends the specified slot's contents to all clients of this window; the slot is specified as local in ...
bool GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Retrieves the block type and meta at the specified coords.
virtual void BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle *a_Exclude=nullptr) override
virtual std::vector< UInt32 > SpawnSplitExperienceOrbs(Vector3d a_Pos, int a_Reward) override
Spawns experience orbs of the specified total value at the given location.
void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData)
Sets the meta for the specified block, while keeping the blocktype.
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.