summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-08-06 17:14:39 +0200
committerMattes D <github@xoft.cz>2014-08-06 17:14:39 +0200
commiteae42d91f91eadeb9b1d021a685c7cc2b3799ebe (patch)
treecc197b2a677edaa30667e71caae4ee93d5bbd8e5 /src/BlockEntities
parentResending fire to the client when the interact cancelled. (diff)
parentFixed style issues (diff)
downloadcuberite-eae42d91f91eadeb9b1d021a685c7cc2b3799ebe.tar
cuberite-eae42d91f91eadeb9b1d021a685c7cc2b3799ebe.tar.gz
cuberite-eae42d91f91eadeb9b1d021a685c7cc2b3799ebe.tar.bz2
cuberite-eae42d91f91eadeb9b1d021a685c7cc2b3799ebe.tar.lz
cuberite-eae42d91f91eadeb9b1d021a685c7cc2b3799ebe.tar.xz
cuberite-eae42d91f91eadeb9b1d021a685c7cc2b3799ebe.tar.zst
cuberite-eae42d91f91eadeb9b1d021a685c7cc2b3799ebe.zip
Diffstat (limited to 'src/BlockEntities')
-rw-r--r--src/BlockEntities/DropSpenserEntity.h11
-rw-r--r--src/BlockEntities/NoteEntity.h13
-rw-r--r--src/BlockEntities/RedstonePoweredEntity.h13
3 files changed, 33 insertions, 4 deletions
diff --git a/src/BlockEntities/DropSpenserEntity.h b/src/BlockEntities/DropSpenserEntity.h
index 9f58d0b07..be56447aa 100644
--- a/src/BlockEntities/DropSpenserEntity.h
+++ b/src/BlockEntities/DropSpenserEntity.h
@@ -11,7 +11,7 @@
#pragma once
#include "BlockEntityWithItems.h"
-
+#include "RedstonePoweredEntity.h"
@@ -31,6 +31,9 @@ class cServer;
// tolua_begin
class cDropSpenserEntity :
public cBlockEntityWithItems
+ // tolua_end
+ , public cRedstonePoweredEntity
+ // tolua_begin
{
typedef cBlockEntityWithItems super;
@@ -64,10 +67,10 @@ public:
/// Sets the dropspenser to dropspense an item in the next tick
void Activate(void);
- /// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate
- void SetRedstonePower(bool a_IsPowered);
-
// tolua_end
+
+ /// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate
+ virtual void SetRedstonePower(bool a_IsPowered) override;
protected:
bool m_ShouldDropSpense; ///< If true, the dropspenser will dropspense an item in the next tick
diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h
index e8497da3e..f538de060 100644
--- a/src/BlockEntities/NoteEntity.h
+++ b/src/BlockEntities/NoteEntity.h
@@ -2,6 +2,7 @@
#pragma once
#include "BlockEntity.h"
+#include "RedstonePoweredEntity.h"
namespace Json
@@ -30,6 +31,9 @@ enum ENUM_NOTE_INSTRUMENTS
class cNoteEntity :
public cBlockEntity
+ // tolua_end
+ , public cRedstonePoweredEntity
+ // tolua_begin
{
typedef cBlockEntity super;
public:
@@ -38,6 +42,7 @@ public:
/// Creates a new note entity. a_World may be NULL
cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
+ virtual ~cNoteEntity() {}
bool LoadFromJson(const Json::Value & a_Value);
virtual void SaveToJson(Json::Value & a_Value) override;
@@ -53,6 +58,14 @@ public:
virtual void UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle &) override {}
+
+ virtual void SetRedstonePower(bool a_Value)
+ {
+ if (a_Value)
+ {
+ MakeSound();
+ }
+ }
static const char * GetClassStatic(void) { return "cNoteEntity"; }
diff --git a/src/BlockEntities/RedstonePoweredEntity.h b/src/BlockEntities/RedstonePoweredEntity.h
new file mode 100644
index 000000000..f11df4fc4
--- /dev/null
+++ b/src/BlockEntities/RedstonePoweredEntity.h
@@ -0,0 +1,13 @@
+
+#pragma once
+
+// Interface class representing a blockEntity that responds to redstone
+class cRedstonePoweredEntity
+{
+public:
+
+ virtual ~cRedstonePoweredEntity() {};
+
+ /// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate
+ virtual void SetRedstonePower(bool a_IsPowered) = 0;
+};