summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/BlockEntity.h
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-10-21 17:37:03 +0200
committerHowaner <franzi.moos@googlemail.com>2014-10-21 17:37:03 +0200
commit283eda3c4eaa37acc242ccefdb3912768a80d14b (patch)
treefe9cdd385d5687c2f8bfe55d331ead942f28e4aa /src/BlockEntities/BlockEntity.h
parentLeaves are harvest-able. (diff)
parentUpdated ProtectionAreas (diff)
downloadcuberite-283eda3c4eaa37acc242ccefdb3912768a80d14b.tar
cuberite-283eda3c4eaa37acc242ccefdb3912768a80d14b.tar.gz
cuberite-283eda3c4eaa37acc242ccefdb3912768a80d14b.tar.bz2
cuberite-283eda3c4eaa37acc242ccefdb3912768a80d14b.tar.lz
cuberite-283eda3c4eaa37acc242ccefdb3912768a80d14b.tar.xz
cuberite-283eda3c4eaa37acc242ccefdb3912768a80d14b.tar.zst
cuberite-283eda3c4eaa37acc242ccefdb3912768a80d14b.zip
Diffstat (limited to 'src/BlockEntities/BlockEntity.h')
-rw-r--r--src/BlockEntities/BlockEntity.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h
index 54ab40f3e..b04d20340 100644
--- a/src/BlockEntities/BlockEntity.h
+++ b/src/BlockEntities/BlockEntity.h
@@ -5,6 +5,28 @@
+/** Place this macro in the declaration of each cBlockEntity descendant. */
+#define BLOCKENTITY_PROTODEF(classname) \
+ virtual bool IsA(const char * a_ClassName) const override \
+ { \
+ return ((strcmp(a_ClassName, #classname) == 0) || super::IsA(a_ClassName)); \
+ } \
+ virtual const char * GetClass(void) const override \
+ { \
+ return #classname; \
+ } \
+ static const char * GetClassStatic(void) \
+ { \
+ return #classname; \
+ } \
+ virtual const char * GetParentClass(void) const override \
+ { \
+ return super::GetClass(); \
+ }
+
+
+
+
namespace Json
{
@@ -55,6 +77,15 @@ public:
{
return "cBlockEntity";
}
+
+ /** Returns true if the object is the specified class, or its descendant. */
+ virtual bool IsA(const char * a_ClassName) const { return (strcmp(a_ClassName, "cBlockEntity") == 0); }
+
+ /** Returns the name of the tompost class (the most descendant). Used for Lua bindings to push the correct object type. */
+ virtual const char * GetClass(void) const { return GetClassStatic(); }
+
+ /** Returns the name of the parent class, or empty string if no parent class. */
+ virtual const char * GetParentClass(void) const { return ""; }
// tolua_begin