1
0

Lock hopper when powered by redstone (#4347)

* Lock hopper when powered by redstone

* Add to manual bindings

* Add hopper API documentation

Co-authored-by: Mat <mail@mathias.is>
This commit is contained in:
Bond-009
2020-03-27 13:03:28 +01:00
committed by GitHub
parent 3a2f364c95
commit ea386eaab1
13 changed files with 172 additions and 4 deletions

View File

@@ -20,7 +20,8 @@
cHopperEntity::cHopperEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World):
super(a_BlockType, a_BlockMeta, a_Pos, ContentsWidth, ContentsHeight, a_World),
m_LastMoveItemsInTick(0),
m_LastMoveItemsOutTick(0)
m_LastMoveItemsOutTick(0),
m_Locked(false)
{
ASSERT(a_BlockType == E_BLOCK_HOPPER);
}
@@ -29,6 +30,15 @@ cHopperEntity::cHopperEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vect
void cHopperEntity::SetLocked(bool a_Value)
{
m_Locked = a_Value;
}
std::pair<bool, Vector3i> cHopperEntity::GetOutputBlockPos(NIBBLETYPE a_BlockMeta)
{
auto pos = GetPos();
@@ -69,9 +79,12 @@ bool cHopperEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
Int64 CurrentTick = a_Chunk.GetWorld()->GetWorldAge();
bool isDirty = false;
isDirty = MoveItemsIn (a_Chunk, CurrentTick) || isDirty;
isDirty = MovePickupsIn(a_Chunk, CurrentTick) || isDirty;
isDirty = MoveItemsOut (a_Chunk, CurrentTick) || isDirty;
if (!m_Locked)
{
isDirty = MoveItemsIn (a_Chunk, CurrentTick) || isDirty;
isDirty = MovePickupsIn(a_Chunk, CurrentTick) || isDirty;
isDirty = MoveItemsOut (a_Chunk, CurrentTick) || isDirty;
}
return isDirty;
}