summaryrefslogtreecommitdiffstats
path: root/src/Blocks/ClearMetaOnDrop.h
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-07-15 14:44:18 +0200
committermadmaxoft <github@xoft.cz>2014-07-15 14:44:18 +0200
commit639dfdb67db01248579910955061f5ca8ce49be8 (patch)
treef2a7636189fac9695620c13cd1bf67a10ead969b /src/Blocks/ClearMetaOnDrop.h
parentMerge pull request #1188 from mc-server/FindClosestPlayerFix (diff)
parentAdded super typedef (diff)
downloadcuberite-639dfdb67db01248579910955061f5ca8ce49be8.tar
cuberite-639dfdb67db01248579910955061f5ca8ce49be8.tar.gz
cuberite-639dfdb67db01248579910955061f5ca8ce49be8.tar.bz2
cuberite-639dfdb67db01248579910955061f5ca8ce49be8.tar.lz
cuberite-639dfdb67db01248579910955061f5ca8ce49be8.tar.xz
cuberite-639dfdb67db01248579910955061f5ca8ce49be8.tar.zst
cuberite-639dfdb67db01248579910955061f5ca8ce49be8.zip
Diffstat (limited to 'src/Blocks/ClearMetaOnDrop.h')
-rw-r--r--src/Blocks/ClearMetaOnDrop.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Blocks/ClearMetaOnDrop.h b/src/Blocks/ClearMetaOnDrop.h
new file mode 100644
index 000000000..3f8c33819
--- /dev/null
+++ b/src/Blocks/ClearMetaOnDrop.h
@@ -0,0 +1,24 @@
+
+#pragma once
+
+// mixin for use to clear meta values when the block is converted to a pickup
+
+// Usage: inherit from this class, passing the parent class as the parameter Base
+// For example to use in class Foo which should inherit Bar use
+// class Foo : public cClearMetaOnDrop<Bar>;
+
+template<class Base>
+class cClearMetaOnDrop : public Base
+{
+public:
+
+ cClearMetaOnDrop(BLOCKTYPE a_BlockType) :
+ Base(a_BlockType)
+ {}
+
+ virtual ~cClearMetaOnDrop() {}
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(this->m_BlockType));
+ }
+};