2015-06-26 18:24:51 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "RedstoneHandler.h"
|
2018-08-28 20:51:25 -04:00
|
|
|
#include "../../BlockEntities/NoteEntity.h"
|
2015-06-26 18:24:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-26 09:15:00 -04:00
|
|
|
class cNoteBlockHandler: public cRedstoneHandler
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2020-07-26 09:15:00 -04:00
|
|
|
virtual unsigned char GetPowerDeliveredToPosition(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2020-07-26 09:15:00 -04:00
|
|
|
UNUSED(a_Chunk);
|
2015-06-26 18:24:51 -04:00
|
|
|
UNUSED(a_Position);
|
|
|
|
UNUSED(a_BlockType);
|
|
|
|
UNUSED(a_Meta);
|
|
|
|
UNUSED(a_QueryPosition);
|
|
|
|
UNUSED(a_QueryBlockType);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-26 09:15:00 -04:00
|
|
|
virtual void Update(cChunk & a_Chunk, cChunk &, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2015-12-24 10:57:45 -05:00
|
|
|
// LOGD("Evaluating sparky the magical note block (%d %d %d) %i", a_Position.x, a_Position.y, a_Position.z, a_PoweringData.PowerLevel);
|
2015-06-26 18:24:51 -04:00
|
|
|
|
2020-07-26 09:15:00 -04:00
|
|
|
auto Previous = DataForChunk(a_Chunk).ExchangeUpdateOncePowerData(a_Position, a_PoweringData);
|
2015-06-26 18:24:51 -04:00
|
|
|
if ((Previous.PowerLevel != 0) || (a_PoweringData.PowerLevel == 0))
|
|
|
|
{
|
|
|
|
// If we're already powered or received an update of no power, don't make a sound
|
2020-07-26 09:15:00 -04:00
|
|
|
return;
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
|
2020-07-26 09:15:00 -04:00
|
|
|
a_Chunk.DoWithNoteBlockAt(a_Position, [](cNoteEntity & a_NoteBlock)
|
|
|
|
{
|
|
|
|
a_NoteBlock.MakeSound();
|
|
|
|
return false;
|
|
|
|
});
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
|
2020-07-26 09:15:00 -04:00
|
|
|
virtual void ForValidSourcePositions(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, SourceCallback Callback) const override
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2020-07-26 09:15:00 -04:00
|
|
|
UNUSED(a_Chunk);
|
2015-06-26 18:24:51 -04:00
|
|
|
UNUSED(a_BlockType);
|
|
|
|
UNUSED(a_Meta);
|
2020-07-26 09:15:00 -04:00
|
|
|
InvokeForAdjustedRelatives(Callback, a_Position, RelativeAdjacents);
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
};
|