Files
cuberite-2a/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h
T

52 lines
1.5 KiB
C++
Raw Normal View History

2015-06-26 17:24:51 -05:00
#pragma once
#include "RedstoneHandler.h"
#include "../../BlockEntities/CommandBlockEntity.h"
2015-06-26 17:24:51 -05:00
2020-07-26 14:15:00 +01:00
class cCommandBlockHandler final : public cRedstoneHandler
2015-06-26 17:24:51 -05:00
{
public:
2020-07-26 14:15:00 +01: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 17:24:51 -05:00
{
2020-07-26 14:15:00 +01:00
UNUSED(a_Chunk);
2015-06-26 17:24:51 -05:00
UNUSED(a_Position);
UNUSED(a_BlockType);
UNUSED(a_Meta);
UNUSED(a_QueryPosition);
UNUSED(a_QueryBlockType);
return 0;
}
2020-07-26 14:15:00 +01: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 17:24:51 -05:00
{
// LOGD("Evaluating commander the cmdblck (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
2015-06-26 17:24:51 -05:00
2020-07-26 14:15:00 +01:00
auto Previous = DataForChunk(a_Chunk).ExchangeUpdateOncePowerData(a_Position, a_PoweringData);
2015-06-26 17:24:51 -05:00
if ((Previous.PowerLevel != 0) || (a_PoweringData.PowerLevel == 0))
{
// If we're already powered or received an update of no power, don't activate
2020-07-26 14:15:00 +01:00
return;
2015-06-26 17:24:51 -05:00
}
2020-07-26 14:15:00 +01:00
a_Chunk.DoWithCommandBlockAt(a_Position, [](cCommandBlockEntity & a_CommandBlock)
{
a_CommandBlock.Activate();
return false;
});
2015-06-26 17:24:51 -05:00
}
2020-07-26 14:15:00 +01:00
virtual void ForValidSourcePositions(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, SourceCallback Callback) const override
2015-06-26 17:24:51 -05:00
{
2020-07-26 14:15:00 +01:00
UNUSED(a_Chunk);
2015-06-26 17:24:51 -05:00
UNUSED(a_BlockType);
UNUSED(a_Meta);
2020-07-26 14:15:00 +01:00
InvokeForAdjustedRelatives(Callback, a_Position, RelativeAdjacents);
2015-06-26 17:24:51 -05:00
}
};