summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/DropSpenserEntity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/BlockEntities/DropSpenserEntity.cpp')
-rw-r--r--src/BlockEntities/DropSpenserEntity.cpp42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp
index 21856abb6..c301ec24c 100644
--- a/src/BlockEntities/DropSpenserEntity.cpp
+++ b/src/BlockEntities/DropSpenserEntity.cpp
@@ -15,8 +15,8 @@
-cDropSpenserEntity::cDropSpenserEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World):
- Super(a_BlockType, a_BlockMeta, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
+cDropSpenserEntity::cDropSpenserEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World):
+ super(a_BlockType, a_BlockMeta, a_Pos, ContentsWidth, ContentsHeight, a_World),
m_ShouldDropSpense(false)
{
}
@@ -39,16 +39,16 @@ cDropSpenserEntity::~cDropSpenserEntity()
-void cDropSpenserEntity::AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction)
+void cDropSpenserEntity::AddDropSpenserDir(Vector3i & a_RelCoord, NIBBLETYPE a_Direction)
{
switch (a_Direction & E_META_DROPSPENSER_FACING_MASK)
{
- case E_META_DROPSPENSER_FACING_YM: a_BlockY--; return;
- case E_META_DROPSPENSER_FACING_YP: a_BlockY++; return;
- case E_META_DROPSPENSER_FACING_ZM: a_BlockZ--; return;
- case E_META_DROPSPENSER_FACING_ZP: a_BlockZ++; return;
- case E_META_DROPSPENSER_FACING_XM: a_BlockX--; return;
- case E_META_DROPSPENSER_FACING_XP: a_BlockX++; return;
+ case E_META_DROPSPENSER_FACING_YM: a_RelCoord.y--; return;
+ case E_META_DROPSPENSER_FACING_YP: a_RelCoord.y++; return;
+ case E_META_DROPSPENSER_FACING_ZM: a_RelCoord.z--; return;
+ case E_META_DROPSPENSER_FACING_ZP: a_RelCoord.z++; return;
+ case E_META_DROPSPENSER_FACING_XM: a_RelCoord.x--; return;
+ case E_META_DROPSPENSER_FACING_XP: a_RelCoord.x++; return;
}
LOGWARNING("%s: Unhandled direction: %d", __FUNCTION__, a_Direction);
return;
@@ -75,7 +75,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
if (SlotsCnt == 0)
{
// Nothing in the dropspenser, play the click sound
- m_World->BroadcastSoundEffect("block.dispenser.fail", Vector3d(m_PosX, m_PosY, m_PosZ), 1.0f, 1.2f);
+ m_World->BroadcastSoundEffect("block.dispenser.fail", m_Pos, 1.0f, 1.2f);
return;
}
@@ -85,7 +85,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
DropSpenseFromSlot(a_Chunk, OccupiedSlots[RandomSlot]);
// Broadcast a smoke and click effects:
- NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
+ NIBBLETYPE Meta = a_Chunk.GetMeta(GetRelPos());
int SmokeDir = 0;
switch (Meta & E_META_DROPSPENSER_FACING_MASK)
{
@@ -97,7 +97,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
case E_META_DROPSPENSER_FACING_ZP: SmokeDir = static_cast<int>(SmokeDirection::NORTH); break;
}
m_World->BroadcastSoundParticleEffect(EffectID::PARTICLE_SMOKE, GetPos(), SmokeDir);
- m_World->BroadcastSoundEffect("block.dispenser.dispense", Vector3d(m_PosX, m_PosY, m_PosZ), 1.0f, 1.0f);
+ m_World->BroadcastSoundEffect("block.dispenser.dispense", m_Pos, 1.0f, 1.0f);
}
@@ -115,7 +115,7 @@ void cDropSpenserEntity::Activate(void)
void cDropSpenserEntity::CopyFrom(const cBlockEntity & a_Src)
{
- Super::CopyFrom(a_Src);
+ super::CopyFrom(a_Src);
auto & src = static_cast<const cDropSpenserEntity &>(a_Src);
m_Contents.CopyFrom(src.m_Contents);
m_ShouldDropSpense = src.m_ShouldDropSpense;
@@ -157,7 +157,7 @@ bool cDropSpenserEntity::UsedBy(cPlayer * a_Player)
cWindow * Window = GetWindow();
if (Window == nullptr)
{
- OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this));
+ OpenWindow(new cDropSpenserWindow(this));
Window = GetWindow();
}
@@ -177,11 +177,9 @@ bool cDropSpenserEntity::UsedBy(cPlayer * a_Player)
void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
{
- int DispX = m_PosX;
- int DispY = m_PosY;
- int DispZ = m_PosZ;
- NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
- AddDropSpenserDir(DispX, DispY, DispZ, Meta);
+ Vector3i dispCoord(m_Pos);
+ auto Meta = a_Chunk.GetMeta(GetRelPos());
+ AddDropSpenserDir(dispCoord, Meta);
cItems Pickups;
Pickups.push_back(m_Contents.RemoveOneItem(a_SlotNum));
@@ -199,9 +197,9 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
}
double MicroX, MicroY, MicroZ;
- MicroX = DispX + 0.5;
- MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser
- MicroZ = DispZ + 0.5;
+ MicroX = dispCoord.x + 0.5;
+ MicroY = dispCoord.y + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser
+ MicroZ = dispCoord.z + 0.5;
m_World->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ, PickupSpeedX, PickupSpeedY, PickupSpeedZ);