Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
cBrewingstandEntity Class Reference

#include <BrewingstandEntity.h>

Inheritance diagram for cBrewingstandEntity:
Inheritance graph
[legend]
Collaboration diagram for cBrewingstandEntity:
Collaboration graph
[legend]

Public Types

enum  {
  bsLeftBottle = 0 , bsMiddleBottle = 1 , bsRightBottle = 2 , bsIngredient = 3 ,
  bsFuel = 4 , ContentsWidth = 5 , ContentsHeight = 1
}
 

Public Member Functions

 cBrewingstandEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 Constructor used for normal operation. More...
 
void ContinueBrewing (void)
 Starts the brewing proccess. More...
 
virtual void CopyFrom (const cBlockEntity &a_Src) override
 Copies all properties of a_Src into this entity, except for its m_World and location. More...
 
short GetBrewingTimeLeft (void) const
 Returns the time until the current items finishes brewing, in ticks. More...
 
const cItemGetFuelSlot (void) const
 Returns the item in the fuel slot. More...
 
const cItemGetIndgredientSlot (void) const
 Returns the item in the ingredient slot
More...
 
const cItemGetLeftBottleSlot (void) const
 Returns the item in the left bottle slot
More...
 
const cItemGetMiddleBottleSlot (void) const
 Returns the item in the middle bottle slot
More...
 
short GetRemainingFuel (void)
 Returns the remaining fuel that is left. More...
 
const cItemGetResultItem (size_t a_SlotNumber)
 Get the expected result item for the given slot number. More...
 
const cItemGetRightBottleSlot (void) const
 Returns the item in the right bottle slot
More...
 
short GetTimeBrewed (void)
 Returns the time that the current items has been brewing, in ticks. More...
 
void LoadRecipes (void)
 Gets the recipes. More...
 
virtual void OnRemoveFromWorld () override
 Called when the block entity object is removed from a world. More...
 
virtual void SendTo (cClientHandle &a_Client) override
 Sends the packet defining the block entity to the client specified. More...
 
void SetFuelSlot (const cItem &a_Item)
 Sets the item in the fuel slot
More...
 
void SetIngredientSlot (const cItem &a_Item)
 Sets the item in the ingredient slot
More...
 
void SetLeftBottleSlot (const cItem &a_Item)
 Sets the item in the left bottle slot
More...
 
void SetMiddleBottleSlot (const cItem &a_Item)
 Sets the item in the middle bottle slot
More...
 
void SetRemainingFuel (short a_RemainingFuel)
 Sets the remaining fuel. More...
 
void SetRightBottleSlot (const cItem &a_Item)
 Sets the item in the right bottle slot
More...
 
void SetTimeBrewed (short a_TimeBrewed)
 Sets the current brewing time. More...
 
virtual bool Tick (std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
 Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. More...
 
virtual bool UsedBy (cPlayer *a_Player) override
 Called when a player uses this entity; should open the UI window. More...
 
- Public Member Functions inherited from cBlockEntityWithItems
 cBlockEntityWithItems (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, int a_ItemGridWidth, int a_ItemGridHeight, cWorld *a_World)
 
virtual cItems ConvertToPickups () const override
 Returns the contents of this block entity that it would drop if broken. More...
 
cItemGridGetContents (void)
 Returns the ItemGrid used for storing the contents. More...
 
const cItemGridGetContents (void) const
 Const version of the GetContents() function for C++ type-safety. More...
 
const cItemGetSlot (int a_SlotNum) const
 
const cItemGetSlot (int a_X, int a_Y) const
 
void SetSlot (int a_SlotNum, const cItem &a_Item)
 
void SetSlot (int a_X, int a_Y, const cItem &a_Item)
 
- Public Member Functions inherited from cBlockEntity
OwnedBlockEntity Clone (Vector3i a_Pos)
 Makes an exact copy of this block entity, except for its m_World (set to nullptr), and at a new position. More...
 
virtual void Destroy ()
 Called when this block entity's associated block is destroyed. More...
 
BLOCKTYPE GetBlockType () const
 
int GetChunkX () const
 
int GetChunkZ () const
 
Vector3i GetPos () const
 
int GetPosX () const
 
int GetPosY () const
 
int GetPosZ () const
 
Vector3i GetRelPos () const
 
int GetRelX () const
 
int GetRelZ () const
 
cWorldGetWorld () const
 
virtual void OnAddToWorld (cWorld &a_World, cChunk &a_Chunk)
 Called when the block entity object is added to a world. More...
 
void SetPos (Vector3i a_NewPos)
 Updates the internally stored position. More...
 
void SetWorld (cWorld *a_World)
 
virtual ~cBlockEntity ()=default
 
- Public Member Functions inherited from cItemGrid::cListener
virtual ~cListener ()
 
- Public Member Functions inherited from cBlockEntityWindowOwner
 cBlockEntityWindowOwner (cBlockEntity *a_BlockEntity)
 
virtual Vector3i GetBlockPos (void) override
 Returns the block position at which the element owning the window is. More...
 
- Public Member Functions inherited from cWindowOwner
void CloseWindow (void)
 
 cWindowOwner ()
 
cWindowGetWindow (void) const
 
void OpenWindow (cWindow *a_Window)
 
virtual ~cWindowOwner ()
 

Protected Member Functions

void BroadcastProgress (size_t a_ProgressbarID, short a_Value)
 Sends the specified progressbar value to all clients of the window. More...
 
virtual void OnSlotChanged (cItemGrid *a_ItemGrid, int a_SlotNum) override
 Called whenever a slot changes. More...
 
void UpdateProgressBars (bool a_ForceUpdate=false)
 
- Protected Member Functions inherited from cBlockEntity
 cBlockEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 

Protected Attributes

std::array< const cBrewingRecipes::cRecipe *, 3 > m_CurrentBrewingRecipes = {}
 Store the current brewing recipes. More...
 
bool m_IsBrewing
 Set to true if the brewing stand is brewing an item. More...
 
const short m_NeedBrewingTime = 400
 Brewing time is 400 ticks. More...
 
short m_RemainingFuel
 The remaining fuel for the brewing stand. More...
 
std::array< cItem, 3 > m_Results
 Result items for the bottle inputs. More...
 
short m_TimeBrewed
 Amount of ticks that the current item has been brewed. More...
 
- Protected Attributes inherited from cBlockEntityWithItems
cItemGrid m_Contents
 
- Protected Attributes inherited from cBlockEntity
NIBBLETYPE m_BlockMeta
 The block meta representing this particular instance in the world Mainly used for directional entities, such as dispensers. More...
 
BLOCKTYPE m_BlockType
 The blocktype representing this particular instance in the world. More...
 
Vector3i m_Pos
 Position in absolute block coordinates. More...
 
int m_RelX
 Position relative to the chunk, used to speed up ticking. More...
 
int m_RelZ
 
cWorldm_World
 

Private Types

using Super = cBlockEntityWithItems
 

Additional Inherited Members

- Static Public Member Functions inherited from cBlockEntity
static OwnedBlockEntity CreateByBlockType (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World=nullptr)
 Creates a new block entity for the specified block type at the specified absolute pos. More...
 
static bool IsBlockEntityBlockType (BLOCKTYPE a_BlockType)
 Returns true if the specified blocktype is supposed to have an associated block entity. More...
 

Detailed Description

Definition at line 19 of file BrewingstandEntity.h.

Member Typedef Documentation

◆ Super

Definition at line 24 of file BrewingstandEntity.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
bsLeftBottle 
bsMiddleBottle 
bsRightBottle 
bsIngredient 
bsFuel 
ContentsWidth 
ContentsHeight 

Definition at line 30 of file BrewingstandEntity.h.

Constructor & Destructor Documentation

◆ cBrewingstandEntity()

cBrewingstandEntity::cBrewingstandEntity ( BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta,
Vector3i  a_Pos,
cWorld a_World 
)

Constructor used for normal operation.

Definition at line 14 of file BrewingstandEntity.cpp.

Member Function Documentation

◆ BroadcastProgress()

void cBrewingstandEntity::BroadcastProgress ( size_t  a_ProgressbarID,
short  a_Value 
)
protected

Sends the specified progressbar value to all clients of the window.

Definition at line 175 of file BrewingstandEntity.cpp.

◆ ContinueBrewing()

void cBrewingstandEntity::ContinueBrewing ( void  )

Starts the brewing proccess.

Will be called if the brewing stand gets loaded from the world.

Definition at line 298 of file BrewingstandEntity.cpp.

◆ CopyFrom()

void cBrewingstandEntity::CopyFrom ( const cBlockEntity a_Src)
overridevirtual

Copies all properties of a_Src into this entity, except for its m_World and location.

Each non-abstract descendant should override to copy its specific properties, and call Super::CopyFrom(a_Src) to copy the common ones.

Reimplemented from cBlockEntityWithItems.

Definition at line 27 of file BrewingstandEntity.cpp.

◆ GetBrewingTimeLeft()

short cBrewingstandEntity::GetBrewingTimeLeft ( void  ) const
inline

Returns the time until the current items finishes brewing, in ticks.

Definition at line 57 of file BrewingstandEntity.h.

◆ GetFuelSlot()

const cItem& cBrewingstandEntity::GetFuelSlot ( void  ) const
inline

Returns the item in the fuel slot.

Definition at line 78 of file BrewingstandEntity.h.

◆ GetIndgredientSlot()

const cItem& cBrewingstandEntity::GetIndgredientSlot ( void  ) const
inline

Returns the item in the ingredient slot

Definition at line 75 of file BrewingstandEntity.h.

◆ GetLeftBottleSlot()

const cItem& cBrewingstandEntity::GetLeftBottleSlot ( void  ) const
inline

Returns the item in the left bottle slot

Definition at line 66 of file BrewingstandEntity.h.

◆ GetMiddleBottleSlot()

const cItem& cBrewingstandEntity::GetMiddleBottleSlot ( void  ) const
inline

Returns the item in the middle bottle slot

Definition at line 69 of file BrewingstandEntity.h.

◆ GetRemainingFuel()

short cBrewingstandEntity::GetRemainingFuel ( void  )
inline

Returns the remaining fuel that is left.

Definition at line 63 of file BrewingstandEntity.h.

◆ GetResultItem()

const cItem& cBrewingstandEntity::GetResultItem ( size_t  a_SlotNumber)
inline

Get the expected result item for the given slot number.

Definition at line 81 of file BrewingstandEntity.h.

◆ GetRightBottleSlot()

const cItem& cBrewingstandEntity::GetRightBottleSlot ( void  ) const
inline

Returns the item in the right bottle slot

Definition at line 72 of file BrewingstandEntity.h.

◆ GetTimeBrewed()

short cBrewingstandEntity::GetTimeBrewed ( void  )
inline

Returns the time that the current items has been brewing, in ticks.

Definition at line 60 of file BrewingstandEntity.h.

◆ LoadRecipes()

void cBrewingstandEntity::LoadRecipes ( void  )

Gets the recipes.

Will be called if the brewing stand gets loaded from the world.

Definition at line 311 of file BrewingstandEntity.cpp.

◆ OnRemoveFromWorld()

void cBrewingstandEntity::OnRemoveFromWorld ( )
overridevirtual

Called when the block entity object is removed from a world.

This occurs when the chunk it resides in is unloaded, or when the associated block is destroyed. If it is the latter, Destroy() is guaranteed to be called first.

Reimplemented from cBlockEntity.

Definition at line 42 of file BrewingstandEntity.cpp.

◆ OnSlotChanged()

void cBrewingstandEntity::OnSlotChanged ( cItemGrid a_ItemGrid,
int  a_SlotNum 
)
overrideprotectedvirtual

Called whenever a slot changes.

Reimplemented from cBlockEntityWithItems.

Definition at line 188 of file BrewingstandEntity.cpp.

◆ SendTo()

void cBrewingstandEntity::SendTo ( cClientHandle a_Client)
overridevirtual

Sends the packet defining the block entity to the client specified.

To send to all eligible clients, use cWorld::BroadcastBlockEntity()

Implements cBlockEntity.

Definition at line 56 of file BrewingstandEntity.cpp.

◆ SetFuelSlot()

void cBrewingstandEntity::SetFuelSlot ( const cItem a_Item)
inline

Sets the item in the fuel slot

Definition at line 96 of file BrewingstandEntity.h.

◆ SetIngredientSlot()

void cBrewingstandEntity::SetIngredientSlot ( const cItem a_Item)
inline

Sets the item in the ingredient slot

Definition at line 93 of file BrewingstandEntity.h.

◆ SetLeftBottleSlot()

void cBrewingstandEntity::SetLeftBottleSlot ( const cItem a_Item)
inline

Sets the item in the left bottle slot

Definition at line 84 of file BrewingstandEntity.h.

◆ SetMiddleBottleSlot()

void cBrewingstandEntity::SetMiddleBottleSlot ( const cItem a_Item)
inline

Sets the item in the middle bottle slot

Definition at line 87 of file BrewingstandEntity.h.

◆ SetRemainingFuel()

void cBrewingstandEntity::SetRemainingFuel ( short  a_RemainingFuel)
inline

Sets the remaining fuel.

Will be called if the brewing stand gets loaded from the world.

Definition at line 104 of file BrewingstandEntity.h.

◆ SetRightBottleSlot()

void cBrewingstandEntity::SetRightBottleSlot ( const cItem a_Item)
inline

Sets the item in the right bottle slot

Definition at line 90 of file BrewingstandEntity.h.

◆ SetTimeBrewed()

void cBrewingstandEntity::SetTimeBrewed ( short  a_TimeBrewed)
inline

Sets the current brewing time.

Will be called if the brewing stand gets loaded from the world.

Definition at line 101 of file BrewingstandEntity.h.

◆ Tick()

bool cBrewingstandEntity::Tick ( std::chrono::milliseconds  a_Dt,
cChunk a_Chunk 
)
overridevirtual

Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking.

By default does nothing.

Reimplemented from cBlockEntity.

Definition at line 66 of file BrewingstandEntity.cpp.

◆ UpdateProgressBars()

void cBrewingstandEntity::UpdateProgressBars ( bool  a_ForceUpdate = false)
protected

Definition at line 283 of file BrewingstandEntity.cpp.

◆ UsedBy()

bool cBrewingstandEntity::UsedBy ( cPlayer a_Player)
overridevirtual

Called when a player uses this entity; should open the UI window.

returns true if the use was successful, return false to use the block as a "normal" block

Implements cBlockEntity.

Definition at line 140 of file BrewingstandEntity.cpp.

Member Data Documentation

◆ m_CurrentBrewingRecipes

std::array<const cBrewingRecipes::cRecipe *, 3> cBrewingstandEntity::m_CurrentBrewingRecipes = {}
protected

Store the current brewing recipes.

Definition at line 121 of file BrewingstandEntity.h.

◆ m_IsBrewing

bool cBrewingstandEntity::m_IsBrewing
protected

Set to true if the brewing stand is brewing an item.

Definition at line 115 of file BrewingstandEntity.h.

◆ m_NeedBrewingTime

const short cBrewingstandEntity::m_NeedBrewingTime = 400
protected

Brewing time is 400 ticks.

Definition at line 118 of file BrewingstandEntity.h.

◆ m_RemainingFuel

short cBrewingstandEntity::m_RemainingFuel
protected

The remaining fuel for the brewing stand.

It's the amount of brewing operations that can be done.

Definition at line 130 of file BrewingstandEntity.h.

◆ m_Results

std::array<cItem, 3> cBrewingstandEntity::m_Results
protected

Result items for the bottle inputs.

Definition at line 124 of file BrewingstandEntity.h.

◆ m_TimeBrewed

short cBrewingstandEntity::m_TimeBrewed
protected

Amount of ticks that the current item has been brewed.

Definition at line 127 of file BrewingstandEntity.h.


The documentation for this class was generated from the following files: