6 #include "../BlockInfo.h"
8 #include "../Entities/Player.h"
9 #include "../UI/ChestWindow.h"
10 #include "../ClientHandle.h"
11 #include "../Mobs/Ocelot.h"
18 Super(a_BlockType, a_BlockMeta, a_Pos, ContentsWidth, ContentsHeight, a_World),
19 m_NumActivePlayers(0),
60 if ((Chunk ==
nullptr) || !Chunk->IsValid())
68 if ((BlockEntity ==
nullptr) || (BlockEntity->GetBlockType() !=
m_BlockType))
85 if (Window !=
nullptr)
87 Window->OwnerDestroyed();
215 cWindow * Window = PrimaryChest.GetWindow();
218 if (Window ==
nullptr)
220 PrimaryChest.OpenNewWindow();
221 Window = PrimaryChest.GetWindow();
225 if (Window !=
nullptr)
248 if ((Window ==
nullptr) && (
m_Neighbour !=
nullptr))
255 if (Window !=
nullptr)
static int GetBlock(lua_State *a_LuaState)
Templated bindings for the GetBlock___() functions.
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
Vector3< double > Vector3d
BLOCKTYPE m_BlockType
The blocktype representing this particular instance in the world.
cWorld * GetWorld() const
Vector3i GetRelPos() const
virtual void OnAddToWorld(cWorld &a_World, cChunk &a_Chunk)
Called when the block entity object is added to a world.
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
virtual void OnSlotChanged(cItemGrid *a_Grid, int a_SlotNum) override
Called whenever a slot changes.
virtual void OnAddToWorld(cWorld &a_World, cChunk &a_Chunk) override
Called when the block entity object is added to a world.
cChestEntity * GetSecondaryChest()
Returns the associated secondary chest, if any.
cChestEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
bool ScanNeighbour(cChunk &a_Chunk, Vector3i a_Position)
Search the given horizontally adjacent relative position for a neighbouring chest of the same type.
void OpenNewWindow()
Opens a new chest window where this is the primary chest and any neighbour is the secondary.
cChestEntity * m_Neighbour
Neighbouring chest that links to form a double chest.
virtual void CopyFrom(const cBlockEntity &a_Src) override
Copies all properties of a_Src into this entity, except for its m_World and location.
cChestEntity & GetPrimaryChest()
Returns the associated primary chest.
virtual bool UsedBy(cPlayer *a_Player) override
Called when a player uses this entity; should open the UI window.
bool IsBlocked()
Returns true if the chest should not be accessible by players.
virtual void OnSlotChanged(cItemGrid *a_Grid, int a_SlotNum) override
cItemGrid::cListener overrides:
int m_NumActivePlayers
Number of players who currently have this chest open.
virtual void SendTo(cClientHandle &a_Client) override
Sends the packet defining the block entity to the client specified.
void DestroyWindow()
Forces any players to close the owned window.
virtual void OnRemoveFromWorld() override
Called when the block entity object is removed from a world.
static bool IsTransparent(BLOCKTYPE Block)
Is a block transparent? (https://minecraft.wiki/w/Opacity)
cChunk * GetRelNeighborChunkAdjustCoords(Vector3i &a_RelPos) const
Returns the chunk into which the relatively-specified block belongs.
cBlockEntity * GetBlockEntityRel(Vector3i a_RelPos)
Returns the block entity at the specified (relative) coords.
void SendUpdateBlockEntity(cBlockEntity &a_BlockEntity)
StatisticsManager & GetStatistics()
Return the associated statistic and achievement manager.
void OpenWindow(cWindow &a_Window)
Opens the specified window; closes the current one first using CloseWindow()
cWindow * GetWindow(void)
void CopyFrom(const cItemGrid &a_Src)
Copies all items from a_Src to this grid.
static bool IsCatSittingOnBlock(cWorld *a_World, Vector3d a_BlockPosition)
Returns true if there's a cat sitting above the given position.
std::unordered_map< CustomStatistic, StatValue > Custom
void BroadcastWholeWindow(void)
Sends the contents of the whole window to all clients of this window.
cWindow * GetWindow(void) const
void OpenWindow(cWindow *a_Window)