2015-06-26 22:24:51 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-08-29 00:51:25 +00:00
|
|
|
#include "../../BlockEntities/CommandBlockEntity.h"
|
2015-06-26 22:24:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-19 20:14:40 +00:00
|
|
|
namespace CommandBlockHandler
|
2015-06-26 22:24:51 +00:00
|
|
|
{
|
2020-08-20 19:04:28 +00:00
|
|
|
inline PowerLevel GetPowerDeliveredToPosition(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked)
|
2015-06-26 22:24:51 +00:00
|
|
|
{
|
2020-07-26 13:15:00 +00:00
|
|
|
UNUSED(a_Chunk);
|
2015-06-26 22:24:51 +00:00
|
|
|
UNUSED(a_Position);
|
|
|
|
UNUSED(a_BlockType);
|
|
|
|
UNUSED(a_QueryPosition);
|
|
|
|
UNUSED(a_QueryBlockType);
|
2020-08-08 17:22:16 +00:00
|
|
|
UNUSED(IsLinked);
|
2015-06-26 22:24:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-08-20 19:04:28 +00:00
|
|
|
inline void Update(cChunk & a_Chunk, cChunk &, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const PowerLevel Power)
|
2015-06-26 22:24:51 +00:00
|
|
|
{
|
2015-12-24 15:57:45 +00:00
|
|
|
// LOGD("Evaluating commander the cmdblck (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
|
2015-06-26 22:24:51 +00:00
|
|
|
|
2020-08-20 19:04:28 +00:00
|
|
|
const auto Previous = DataForChunk(a_Chunk).ExchangeUpdateOncePowerData(a_Position, Power);
|
|
|
|
if ((Previous != 0) || (Power == 0))
|
2015-06-26 22:24:51 +00:00
|
|
|
{
|
|
|
|
// If we're already powered or received an update of no power, don't activate
|
2020-07-26 13:15:00 +00:00
|
|
|
return;
|
2015-06-26 22:24:51 +00:00
|
|
|
}
|
|
|
|
|
2020-07-26 13:15:00 +00:00
|
|
|
a_Chunk.DoWithCommandBlockAt(a_Position, [](cCommandBlockEntity & a_CommandBlock)
|
|
|
|
{
|
|
|
|
a_CommandBlock.Activate();
|
|
|
|
return false;
|
|
|
|
});
|
2015-06-26 22:24:51 +00:00
|
|
|
}
|
|
|
|
|
2020-08-19 20:14:40 +00:00
|
|
|
inline void ForValidSourcePositions(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, ForEachSourceCallback & Callback)
|
2015-06-26 22:24:51 +00:00
|
|
|
{
|
2020-07-26 13:15:00 +00:00
|
|
|
UNUSED(a_Chunk);
|
2015-06-26 22:24:51 +00:00
|
|
|
UNUSED(a_BlockType);
|
|
|
|
UNUSED(a_Meta);
|
2020-07-26 13:15:00 +00:00
|
|
|
InvokeForAdjustedRelatives(Callback, a_Position, RelativeAdjacents);
|
2015-06-26 22:24:51 +00:00
|
|
|
}
|
|
|
|
};
|