Cuberite
A lightweight, fast and extensible game server for Minecraft
BlockNoteBlock.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "BlockEntity.h"
5 #include "../BlockEntities/NoteEntity.h"
6 
7 
8 
9 
10 
12  public cBlockEntityHandler
13 {
15 
16 public:
17 
18  using Super::Super;
19 
20 private:
21 
22  virtual void OnDigging(
23  cChunkInterface & a_ChunkInterface,
24  cWorldInterface & a_WorldInterface,
25  cPlayer & a_Player,
26  const Vector3i a_BlockPos
27  ) const override
28  {
29  a_WorldInterface.DoWithBlockEntityAt(a_BlockPos, [](cBlockEntity & a_BlockEntity)
30  {
31  ASSERT(a_BlockEntity.GetBlockType() == E_BLOCK_NOTE_BLOCK);
32 
33  static_cast<cNoteEntity &>(a_BlockEntity).MakeSound();
34  return false;
35  });
36  }
37 };
@ E_BLOCK_NOTE_BLOCK
Definition: BlockType.h:35
#define ASSERT(x)
Definition: Globals.h:276
BLOCKTYPE GetBlockType() const
Definition: BlockEntity.h:97
Wrapper for blocks that have a cBlockEntity descendant attached to them and can be "used" by the play...
Definition: BlockEntity.h:16
cBlockHandler Super
Definition: BlockEntity.h:17
virtual void OnDigging(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos) const override
Called when the player starts digging the block.
virtual bool DoWithBlockEntityAt(Vector3i a_Position, cBlockEntityCallback a_Callback)=0
Calls the callback for the block entity at the specified coords; returns false if there's no block en...
Definition: Player.h:29