summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-01-05 03:13:02 +0100
committerTiger Wang <ziwei.tiger@outlook.com>2021-01-11 17:39:56 +0100
commit9328afe65c72b29f5cedbf1897ea8559f6b2c42f (patch)
tree92d9490d062009278ed8d78f8981014e88ba8f05 /src/Entities
parentzlib -> libdeflate (#5085) (diff)
downloadcuberite-9328afe65c72b29f5cedbf1897ea8559f6b2c42f.tar
cuberite-9328afe65c72b29f5cedbf1897ea8559f6b2c42f.tar.gz
cuberite-9328afe65c72b29f5cedbf1897ea8559f6b2c42f.tar.bz2
cuberite-9328afe65c72b29f5cedbf1897ea8559f6b2c42f.tar.lz
cuberite-9328afe65c72b29f5cedbf1897ea8559f6b2c42f.tar.xz
cuberite-9328afe65c72b29f5cedbf1897ea8559f6b2c42f.tar.zst
cuberite-9328afe65c72b29f5cedbf1897ea8559f6b2c42f.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/Entity.cpp4
-rw-r--r--src/Entities/Floater.cpp24
2 files changed, 18 insertions, 10 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 438117650..f07eab415 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1198,8 +1198,8 @@ void cEntity::TickBurning(cChunk & a_Chunk)
m_TicksLeftBurning = 0;
}
- // Fire is extinguished by rain
- if (GetWorld()->IsWeatherWetAtXYZ(GetPosition().Floor()))
+ // Fire is extinguished by rain:
+ if (a_Chunk.IsWeatherWetAt(cChunkDef::AbsoluteToRelative(GetPosition().Floor(), a_Chunk.GetPos())))
{
m_TicksLeftBurning = 0;
}
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);
}