From 365cbc6e1cea96741e26c9ce912b003f8fd2c62c Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 29 Sep 2019 14:59:24 +0200 Subject: Refactored more of Entities and BlockEntities to use Vector3. (#4403) --- src/BlockEntities/BlockEntityWithItems.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/BlockEntities/BlockEntityWithItems.cpp') diff --git a/src/BlockEntities/BlockEntityWithItems.cpp b/src/BlockEntities/BlockEntityWithItems.cpp index 924882820..1ec4f2068 100644 --- a/src/BlockEntities/BlockEntityWithItems.cpp +++ b/src/BlockEntities/BlockEntityWithItems.cpp @@ -1,11 +1,5 @@ // BlockEntityWithItems.cpp -// Implements the cBlockEntityWithItems class representing a common ancestor for all block entities that have an ItemGrid - - - - - #include "Globals.h" #include "BlockEntityWithItems.h" #include "../Simulator/RedstoneSimulator.h" @@ -17,11 +11,11 @@ cBlockEntityWithItems::cBlockEntityWithItems( BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, - int a_BlockX, int a_BlockY, int a_BlockZ, + Vector3i a_Pos, int a_ItemGridWidth, int a_ItemGridHeight, cWorld * a_World ): - Super(a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, a_World), + super(a_BlockType, a_BlockMeta, a_Pos, a_World), cBlockEntityWindowOwner(this), m_Contents(a_ItemGridWidth, a_ItemGridHeight) { @@ -39,7 +33,7 @@ void cBlockEntityWithItems::Destroy(void) cItems Pickups; m_Contents.CopyToItems(Pickups); m_Contents.Clear(); - m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block + m_World->SpawnItemPickups(Pickups, m_Pos.x + 0.5, m_Pos.y + 0.5, m_Pos.z + 0.5); // Spawn in centre of block } @@ -48,7 +42,7 @@ void cBlockEntityWithItems::Destroy(void) void cBlockEntityWithItems::CopyFrom(const cBlockEntity & a_Src) { - Super::CopyFrom(a_Src); + super::CopyFrom(a_Src); auto & src = static_cast(a_Src); m_Contents.CopyFrom(src.m_Contents); } @@ -69,10 +63,9 @@ void cBlockEntityWithItems::OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) } m_World->MarkChunkDirty(GetChunkX(), GetChunkZ()); - auto Pos = Vector3i(m_PosX, m_PosY, m_PosZ); - m_World->DoWithChunkAt(Pos, [&](cChunk & a_Chunk) + m_World->DoWithChunkAt(m_Pos, [&](cChunk & a_Chunk) { - m_World->GetRedstoneSimulator()->WakeUp(Pos, &a_Chunk); + m_World->GetRedstoneSimulator()->WakeUp(m_Pos, &a_Chunk); return true; } ); -- cgit v1.2.3