summaryrefslogtreecommitdiffstats
path: root/src/Entities/Minecart.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-09-30 17:16:15 +0200
committerMattes D <github@xoft.cz>2014-09-30 17:16:15 +0200
commit1531511bbe6affcb26e6ade17e4a313f5209e8e7 (patch)
treee9aa42ac32fcb72bf306e679be80cf0082694fc8 /src/Entities/Minecart.cpp
parentMerge pull request #1484 from SphinxC0re/master (diff)
parentCompilation fix (diff)
downloadcuberite-1531511bbe6affcb26e6ade17e4a313f5209e8e7.tar
cuberite-1531511bbe6affcb26e6ade17e4a313f5209e8e7.tar.gz
cuberite-1531511bbe6affcb26e6ade17e4a313f5209e8e7.tar.bz2
cuberite-1531511bbe6affcb26e6ade17e4a313f5209e8e7.tar.lz
cuberite-1531511bbe6affcb26e6ade17e4a313f5209e8e7.tar.xz
cuberite-1531511bbe6affcb26e6ade17e4a313f5209e8e7.tar.zst
cuberite-1531511bbe6affcb26e6ade17e4a313f5209e8e7.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Minecart.cpp42
1 files changed, 34 insertions, 8 deletions
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index 2df64d5c1..f45e7bb69 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -7,7 +7,6 @@
#include "Globals.h"
#include "Minecart.h"
-#include "../World.h"
#include "../ClientHandle.h"
#include "../Chunk.h"
#include "Player.h"
@@ -1106,28 +1105,55 @@ void cRideableMinecart::OnRightClicked(cPlayer & a_Player)
// cMinecartWithChest:
cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) :
- super(mpChest, a_X, a_Y, a_Z)
+ super(mpChest, a_X, a_Y, a_Z),
+ cEntityWindowOwner(this),
+ m_Contents(ContentsWidth, ContentsHeight)
{
+ m_Contents.AddListener(*this);
}
-void cMinecartWithChest::SetSlot(size_t a_Idx, const cItem & a_Item)
+void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
{
- ASSERT(a_Idx < ARRAYCOUNT(m_Items));
-
- m_Items[a_Idx] = a_Item;
+ // If the window is not created, open it anew:
+ cWindow * Window = GetWindow();
+ if (Window == NULL)
+ {
+ OpenNewWindow();
+ Window = GetWindow();
+ }
+
+ // Open the window for the player:
+ if (Window != NULL)
+ {
+ if (a_Player.GetWindow() != Window)
+ {
+ a_Player.OpenWindow(Window);
+ }
+ }
}
-void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
+void cMinecartWithChest::OpenNewWindow()
+{
+ OpenWindow(new cMinecartWithChestWindow(this));
+}
+
+
+
+
+
+void cMinecartWithChest::Destroyed()
{
- // TODO: Show the chest UI window to the player
+ cItems Pickups;
+ m_Contents.CopyToItems(Pickups);
+ GetWorld()->SpawnItemPickups(Pickups, GetPosX(), GetPosY() + 1, GetPosZ(), 4);
}