748b121703
+ DoWith calls now broadcast the block entity and mark the chunk dirty + Add block entity change queue to synchronise BE updates with block updates * Fixed a few incorrect assertions about BE type - Remove manual overloads
41 lines
666 B
C++
41 lines
666 B
C++
|
|
#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, [](cBlockEntity & a_BlockEntity)
|
|
{
|
|
if (a_BlockEntity.GetBlockType() != E_BLOCK_NOTE_BLOCK)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static_cast<cNoteEntity &>(a_BlockEntity).MakeSound();
|
|
return false;
|
|
});
|
|
}
|
|
};
|