summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDerek Qu <qud@umich.edu>2020-11-26 01:58:35 +0100
committerGitHub <noreply@github.com>2020-11-26 01:58:35 +0100
commit280f7a81f4a6ec2c59768036b7e8ad8ebab00b4c (patch)
tree17db730c88e4f2127a3e07c60817cc8937a287d7 /src
parentAdded magma block contact damage (#5055) (diff)
downloadcuberite-280f7a81f4a6ec2c59768036b7e8ad8ebab00b4c.tar
cuberite-280f7a81f4a6ec2c59768036b7e8ad8ebab00b4c.tar.gz
cuberite-280f7a81f4a6ec2c59768036b7e8ad8ebab00b4c.tar.bz2
cuberite-280f7a81f4a6ec2c59768036b7e8ad8ebab00b4c.tar.lz
cuberite-280f7a81f4a6ec2c59768036b7e8ad8ebab00b4c.tar.xz
cuberite-280f7a81f4a6ec2c59768036b7e8ad8ebab00b4c.tar.zst
cuberite-280f7a81f4a6ec2c59768036b7e8ad8ebab00b4c.zip
Diffstat (limited to 'src')
-rw-r--r--src/Blocks/BlockHandler.cpp3
-rw-r--r--src/Blocks/BlockNoteBlock.h43
-rw-r--r--src/Blocks/CMakeLists.txt1
3 files changed, 46 insertions, 1 deletions
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 6342c80fb..925c53cda 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -61,6 +61,7 @@
#include "BlockMycelium.h"
#include "BlockNetherWart.h"
#include "BlockNetherrack.h"
+#include "BlockNoteBlock.h"
#include "BlockObserver.h"
#include "BlockOre.h"
#include "BlockPackedIce.h"
@@ -344,7 +345,7 @@ namespace
constexpr cBlockNetherrack BlockNetherrackHandler (E_BLOCK_NETHERRACK);
constexpr cBlockLeavesHandler BlockNewLeavesHandler (E_BLOCK_NEW_LEAVES);
constexpr cBlockSidewaysHandler BlockNewLogHandler (E_BLOCK_NEW_LOG);
- constexpr cDefaultBlockEntityHandler BlockNoteBlockHandler (E_BLOCK_NOTE_BLOCK);
+ constexpr cBlockNoteBlockHandler BlockNoteBlockHandler (E_BLOCK_NOTE_BLOCK);
constexpr cBlockDoorHandler BlockOakDoorHandler (E_BLOCK_OAK_DOOR);
constexpr cBlockFenceGateHandler BlockOakFenceGateHandler (E_BLOCK_OAK_FENCE_GATE);
constexpr cBlockStairsHandler BlockOakWoodStairsHandler (E_BLOCK_OAK_WOOD_STAIRS);
diff --git a/src/Blocks/BlockNoteBlock.h b/src/Blocks/BlockNoteBlock.h
new file mode 100644
index 000000000..ac1ab7238
--- /dev/null
+++ b/src/Blocks/BlockNoteBlock.h
@@ -0,0 +1,43 @@
+
+#pragma once
+
+#include "BlockEntity.h"
+#include "../BlockEntities/NoteEntity.h"
+
+
+
+
+
+class cBlockNoteBlockHandler final :
+ public cBlockEntityHandler
+{
+ using Super = cBlockEntityHandler;
+
+public:
+
+ using Super::Super;
+
+private:
+
+ virtual void OnDigging(
+ cChunkInterface & a_ChunkInterface,
+ cWorldInterface & a_WorldInterface,
+ cPlayer & a_Player,
+ const Vector3i a_BlockPos
+ ) const override
+ {
+ a_WorldInterface.DoWithBlockEntityAt(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, [](cBlockEntity & a_BlockEntity)
+ {
+ if (a_BlockEntity.GetBlockType() != E_BLOCK_NOTE_BLOCK)
+ {
+ return false;
+ }
+
+ auto & NoteEntity = static_cast<cNoteEntity &>(a_BlockEntity);
+
+ NoteEntity.MakeSound();
+
+ return true;
+ });
+ }
+};
diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt
index e20bda584..57c4d07a7 100644
--- a/src/Blocks/CMakeLists.txt
+++ b/src/Blocks/CMakeLists.txt
@@ -64,6 +64,7 @@ target_sources(
BlockMycelium.h
BlockNetherrack.h
BlockNetherWart.h
+ BlockNoteBlock.h
BlockObserver.h
BlockOre.h
BlockPackedIce.h