- Add a activation flag to droppers and dispensers. Previously droppers and dispensers shot items with every block update.
- Fixes a range check inside cIncrementalRedstoneSimulator::Simulate
This commit is contained in:
@@ -18,6 +18,22 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
inline static bool IsActivated(NIBBLETYPE a_Meta)
|
||||
{
|
||||
return (a_Meta & E_META_DROPSPENSER_ACTIVATED) != 0;
|
||||
}
|
||||
inline static NIBBLETYPE SetActivationState(NIBBLETYPE a_Meta, bool IsOn)
|
||||
{
|
||||
if (IsOn)
|
||||
{
|
||||
return a_Meta | E_META_DROPSPENSER_ACTIVATED; // set the bit
|
||||
}
|
||||
else
|
||||
{
|
||||
return a_Meta & ~E_META_DROPSPENSER_ACTIVATED; // clear the bit
|
||||
}
|
||||
}
|
||||
|
||||
virtual unsigned char GetPowerDeliveredToPosition(const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const Vector3i & a_QueryPosition, BLOCKTYPE a_QueryBlockType) override
|
||||
{
|
||||
UNUSED(a_Position);
|
||||
@@ -39,8 +55,9 @@ public:
|
||||
virtual cVector3iArray Update(const Vector3i & a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) override
|
||||
{
|
||||
// LOGD("Evaluating spencer the dropspenser (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
|
||||
|
||||
if (a_PoweringData.PowerLevel > 0)
|
||||
bool IsPoweredNow = (a_PoweringData.PowerLevel > 0);
|
||||
bool WasPoweredPreviously = IsActivated(a_Meta);
|
||||
if (IsPoweredNow && !WasPoweredPreviously)
|
||||
{
|
||||
class cSetPowerToDropSpenser :
|
||||
public cDropSpenserCallback
|
||||
@@ -56,6 +73,12 @@ public:
|
||||
m_World.DoWithDropSpenserAt(a_Position.x, a_Position.y, a_Position.z, DrSpSP);
|
||||
}
|
||||
|
||||
// Update the internal dropspenser state if necessary
|
||||
if (IsPoweredNow != WasPoweredPreviously)
|
||||
{
|
||||
m_World.SetBlockMeta(a_Position, SetActivationState(a_Meta, IsPoweredNow));
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user