Skip to content

Commit

Permalink
Fixed invisible chests (cuberite#3722)
Browse files Browse the repository at this point in the history
  • Loading branch information
spekdrum authored and madmaxoft committed May 21, 2017
1 parent 2359611 commit 7586223
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/BlockEntities/ChestEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "../Item.h"
#include "../Entities/Player.h"
#include "../UI/ChestWindow.h"
#include "../ClientHandle.h"



Expand Down Expand Up @@ -35,10 +36,8 @@ cChestEntity::~cChestEntity()

void cChestEntity::SendTo(cClientHandle & a_Client)
{
// The chest entity doesn't need anything sent to the client when it's created / gets in the viewdistance
// All the actual handling is in the cWindow UI code that gets called when the chest is rclked

UNUSED(a_Client);
// Send a dummy "number of players with chest open" packet to make the chest visible:
a_Client.SendBlockAction(m_PosX, m_PosY, m_PosZ, 1, 0, m_BlockType);
}


Expand Down
11 changes: 11 additions & 0 deletions src/BlockEntities/EnderChestEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../Item.h"
#include "../Entities/Player.h"
#include "../UI/EnderChestWindow.h"
#include "../ClientHandle.h"



Expand Down Expand Up @@ -34,6 +35,16 @@ cEnderChestEntity::~cEnderChestEntity()



void cEnderChestEntity::SendTo(cClientHandle & a_Client)
{
// Send a dummy "number of players with chest open" packet to make the chest visible:
a_Client.SendBlockAction(m_PosX, m_PosY, m_PosZ, 1, 0, m_BlockType);
}





bool cEnderChestEntity::UsedBy(cPlayer * a_Player)
{
// TODO: cats are an obstruction
Expand Down
2 changes: 1 addition & 1 deletion src/BlockEntities/EnderChestEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class cEnderChestEntity :

// cBlockEntity overrides:
virtual bool UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override { UNUSED(a_Client); }
virtual void SendTo(cClientHandle & a_Client) override;

static void LoadFromJson(const Json::Value & a_Value, cItemGrid & a_Grid);
static void SaveToJson(Json::Value & a_Value, const cItemGrid & a_Grid);
Expand Down

0 comments on commit 7586223

Please sign in to comment.