diff options
Diffstat (limited to 'src/Entities')
-rw-r--r-- | src/Entities/Boat.cpp | 2 | ||||
-rw-r--r-- | src/Entities/Entity.cpp | 9 | ||||
-rw-r--r-- | src/Entities/FireChargeEntity.cpp | 2 | ||||
-rw-r--r-- | src/Entities/Minecart.cpp | 2 | ||||
-rw-r--r-- | src/Entities/Player.cpp | 30 |
5 files changed, 21 insertions, 24 deletions
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp index cc11643fd..b47771a6e 100644 --- a/src/Entities/Boat.cpp +++ b/src/Entities/Boat.cpp @@ -153,7 +153,7 @@ void cBoat::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) return; } - if (IsBlockWater(m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT))) + if (IsBlockWater(m_World->GetBlock(POS_TOINT))) { if (GetSpeedY() < 2) { diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index d6bb057f4..f1d8c989d 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1308,7 +1308,7 @@ void cEntity::DetectCacti(void) { for (int y = MinY; y <= MaxY; y++) { - if (GetWorld()->GetBlock(x, y, z) == E_BLOCK_CACTUS) + if (GetWorld()->GetBlock({ x, y, z }) == E_BLOCK_CACTUS) { TakeDamage(dtCactusContact, nullptr, 1, 0); return; @@ -1337,7 +1337,7 @@ void cEntity::DetectMagma(void) { for (int y = MinY; y <= MaxY; y++) { - if (GetWorld()->GetBlock(x, y, z) == E_BLOCK_MAGMA) + if (GetWorld()->GetBlock({ x, y, z }) == E_BLOCK_MAGMA) { TakeDamage(dtMagmaContact, nullptr, 1, 0); return; @@ -1367,10 +1367,9 @@ bool cEntity::DetectPortal() return false; } - int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; - if (cChunkDef::IsValidHeight(Y)) + if (const auto Position = m_Position.Floor(); cChunkDef::IsValidHeight(Position.y)) { - switch (GetWorld()->GetBlock(X, Y, Z)) + switch (GetWorld()->GetBlock(Position)) { case E_BLOCK_NETHER_PORTAL: { diff --git a/src/Entities/FireChargeEntity.cpp b/src/Entities/FireChargeEntity.cpp index 325c54731..3ac815ec6 100644 --- a/src/Entities/FireChargeEntity.cpp +++ b/src/Entities/FireChargeEntity.cpp @@ -23,7 +23,7 @@ void cFireChargeEntity::Explode(Vector3i a_Block) { if (m_World->GetBlock(a_Block) == E_BLOCK_AIR) { - m_World->SetBlock(a_Block.x, a_Block.y, a_Block.z, E_BLOCK_FIRE, 1); + m_World->SetBlock(a_Block, E_BLOCK_FIRE, 1); } } diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 96eebe2fd..5fc67db5a 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -1241,7 +1241,7 @@ void cMinecart::OnRemoveFromWorld(cWorld & a_World) { if (m_bIsOnDetectorRail) { - m_World->SetBlock(m_DetectorRailPosition.x, m_DetectorRailPosition.y, m_DetectorRailPosition.z, E_BLOCK_DETECTOR_RAIL, m_World->GetBlockMeta(m_DetectorRailPosition) & 0x07); + m_World->SetBlock(m_DetectorRailPosition, E_BLOCK_DETECTOR_RAIL, m_World->GetBlockMeta(m_DetectorRailPosition) & 0x07); } Super::OnRemoveFromWorld(a_World); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index b7ffbc9e4..b6997f5f1 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -2200,16 +2200,14 @@ void cPlayer::HandleFloater() bool cPlayer::IsClimbing(void) const { - int PosX = POSX_TOINT; - int PosY = POSY_TOINT; - int PosZ = POSZ_TOINT; + const auto Position = GetPosition().Floor(); - if ((PosY < 0) || (PosY >= cChunkDef::Height)) + if (!cChunkDef::IsValidHeight(Position.y)) { return false; } - BLOCKTYPE Block = m_World->GetBlock(PosX, PosY, PosZ); + BLOCKTYPE Block = m_World->GetBlock(Position); switch (Block) { case E_BLOCK_LADDER: @@ -2423,12 +2421,12 @@ bool cPlayer::DoesPlacingBlocksIntersectEntity(const sSetBlockVector & a_Blocks) int y = blk.GetY(); int z = blk.GetZ(); cBoundingBox BlockBox = cBlockHandler::For(blk.m_BlockType).GetPlacementCollisionBox( - m_World->GetBlock(x - 1, y, z), - m_World->GetBlock(x + 1, y, z), - (y == 0) ? E_BLOCK_AIR : m_World->GetBlock(x, y - 1, z), - (y == cChunkDef::Height - 1) ? E_BLOCK_AIR : m_World->GetBlock(x, y + 1, z), - m_World->GetBlock(x, y, z - 1), - m_World->GetBlock(x, y, z + 1) + m_World->GetBlock({ x - 1, y, z }), + m_World->GetBlock({ x + 1, y, z }), + (y == 0) ? E_BLOCK_AIR : m_World->GetBlock({ x, y - 1, z }), + (y == cChunkDef::Height - 1) ? E_BLOCK_AIR : m_World->GetBlock({ x, y + 1, z }), + m_World->GetBlock({ x, y, z - 1 }), + m_World->GetBlock({ x, y, z + 1 }) ); BlockBox.Move(x, y, z); @@ -2591,9 +2589,9 @@ void cPlayer::Detach() for (int z = PosZ - 1; z <= (PosZ + 1); ++z) { if ( - (m_World->GetBlock(x, y, z) == E_BLOCK_AIR) && - (m_World->GetBlock(x, y + 1, z) == E_BLOCK_AIR) && - cBlockInfo::IsSolid(m_World->GetBlock(x, y - 1, z)) + (m_World->GetBlock({ x, y, z }) == E_BLOCK_AIR) && + (m_World->GetBlock({ x, y + 1, z }) == E_BLOCK_AIR) && + cBlockInfo::IsSolid(m_World->GetBlock({ x, y - 1, z })) ) { TeleportToCoords(x + 0.5, y, z + 0.5); @@ -2674,12 +2672,12 @@ float cPlayer::GetLiquidHeightPercent(NIBBLETYPE a_Meta) bool cPlayer::IsInsideWater() { - BLOCKTYPE Block = m_World->GetBlock(FloorC(GetPosX()), FloorC(m_Stance), FloorC(GetPosZ())); + BLOCKTYPE Block = m_World->GetBlock(Vector3d(GetPosX(), m_Stance, GetPosZ()).Floor()); if ((Block != E_BLOCK_WATER) && (Block != E_BLOCK_STATIONARY_WATER)) { return false; } - NIBBLETYPE Meta = GetWorld()->GetBlockMeta(FloorC(GetPosX()), FloorC(m_Stance), FloorC(GetPosZ())); + NIBBLETYPE Meta = GetWorld()->GetBlockMeta(Vector3d(GetPosX(), m_Stance, GetPosZ()).Floor()); float f = GetLiquidHeightPercent(Meta) - 0.11111111f; float f1 = static_cast<float>(m_Stance + 1) - f; bool flag = (m_Stance < f1); |