From 6309c6a97fdbabfde978358f5f9a0f61ab74f91f Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 26 Dec 2017 21:25:57 +0000 Subject: improve rain simulation (#4017) * Uses vanilla logic to decide which blocks rain falls through. * Rain falls infinitely above the world, and stops at y=0. * Entities will now be extinguished if they are under rain-blocking blocks, and fire will now be extinguished by rain similarly. * Create IsWeatherWetAtXYZ to identify wetness at a particular location. * Use new code for enderman rain detection. * Fixes issue #916 * Disable warnings for global constructors in the fire simulator. --- src/World.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 4dd9cbc86..4cf25aee3 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -542,6 +542,34 @@ void cWorld::ChangeWeather(void) +bool cWorld::IsWeatherWetAtXYZ(Vector3i a_Pos) +{ + if ((a_Pos.y < 0) || !IsWeatherWetAt(a_Pos.x, a_Pos.z)) + { + return false; + } + + if (a_Pos.y >= cChunkDef::Height) + { + return true; + } + + for (int y = GetHeight(a_Pos.x, a_Pos.z); y >= a_Pos.y; y--) + { + auto BlockType = GetBlock({a_Pos.x, y, a_Pos.z}); + if (cBlockInfo::IsRainBlocker(BlockType)) + { + return false; + } + } + + return true; +} + + + + + void cWorld::SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ) { return m_ChunkMap->SetNextBlockTick(a_BlockX, a_BlockY, a_BlockZ); -- cgit v1.2.3