diff options
Diffstat (limited to 'src/Entities/Floater.cpp')
-rw-r--r-- | src/Entities/Floater.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp index bb326f70b..2738c12d3 100644 --- a/src/Entities/Floater.cpp +++ b/src/Entities/Floater.cpp @@ -101,11 +101,16 @@ void cFloater::SpawnOn(cClientHandle & a_Client) void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { - auto & Random = GetRandomProvider(); - HandlePhysics(a_Dt, a_Chunk); - if (IsBlockWater(m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT)) - && (m_World->GetBlockMeta(POSX_TOINT, POSY_TOINT, POSZ_TOINT) == 0)) + + PREPARE_REL_AND_CHUNK(GetPosition().Floor(), a_Chunk); + if (!RelSuccess) + { + return; + } + + auto & Random = GetRandomProvider(); + if (IsBlockWater(Chunk->GetBlock(Rel)) && (Chunk->GetMeta(Rel) == 0)) { if (!m_CanPickupItem && (m_AttachedMobID == cEntity::INVALID_ID)) // Check if you can't already pickup a fish and if the floater isn't attached to a mob. { @@ -113,7 +118,7 @@ void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { m_BitePos = GetPosition(); m_World->BroadcastSoundEffect("entity.bobber.splash", GetPosition(), 1, 1); - SetPosY(GetPosY() - 1); + AddSpeedY(-10); m_CanPickupItem = true; m_PickupCountDown = 20; m_CountDownTime = Random.RandInt(100, 900); @@ -132,9 +137,9 @@ void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) } m_CountDownTime--; - if (m_World->GetHeight(POSX_TOINT, POSZ_TOINT) == POSY_TOINT) + if (Chunk->IsWeatherWetAt(Rel)) { - if (m_World->IsWeatherWet() && Random.RandBool(0.25)) // 25% chance of an extra countdown when being rained on. + if (Random.RandBool(0.25)) // 25% chance of an extra countdown when being rained on. { m_CountDownTime--; } @@ -150,7 +155,10 @@ void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) } // Check water at the top of floater otherwise it floats into the air above the water - if (IsBlockWater(m_World->GetBlock(POSX_TOINT, FloorC(GetPosY() + GetHeight()), POSZ_TOINT))) + if ( + const auto Above = Rel.addedY(FloorC(GetPosY() + GetHeight())); + (Above.y < cChunkDef::Height) && IsBlockWater(m_World->GetBlock(Above)) + ) { SetSpeedY(0.7); } |