summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockIce.h
diff options
context:
space:
mode:
author12xx12 <44411062+12xx12@users.noreply.github.com>2020-09-24 14:53:49 +0200
committerGitHub <noreply@github.com>2020-09-24 14:53:49 +0200
commitb5410c718ece106a3b25fab4a5c37815715df275 (patch)
tree16db80242c18cc62999479b1f650da1d91c46248 /src/Blocks/BlockIce.h
parentTABS OUT OF BED! TABS IN THE CORRIDORS! (diff)
downloadcuberite-b5410c718ece106a3b25fab4a5c37815715df275.tar
cuberite-b5410c718ece106a3b25fab4a5c37815715df275.tar.gz
cuberite-b5410c718ece106a3b25fab4a5c37815715df275.tar.bz2
cuberite-b5410c718ece106a3b25fab4a5c37815715df275.tar.lz
cuberite-b5410c718ece106a3b25fab4a5c37815715df275.tar.xz
cuberite-b5410c718ece106a3b25fab4a5c37815715df275.tar.zst
cuberite-b5410c718ece106a3b25fab4a5c37815715df275.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockIce.h51
1 files changed, 49 insertions, 2 deletions
diff --git a/src/Blocks/BlockIce.h b/src/Blocks/BlockIce.h
index e20ce6daa..10cd71b8a 100644
--- a/src/Blocks/BlockIce.h
+++ b/src/Blocks/BlockIce.h
@@ -25,9 +25,56 @@ private:
{
return cItem(m_BlockType);
}
- else
+
+ return {};
+ }
+
+ virtual void OnUpdate(
+ cChunkInterface & a_ChunkInterface,
+ cWorldInterface & a_WorldInterface,
+ cBlockPluginInterface & a_PluginInterface,
+ cChunk & a_Chunk,
+ const Vector3i a_RelPos
+ ) const override
+ {
+ // Disappears instantly in nether:
+ if (a_WorldInterface.GetDimension() == dimNether)
+ {
+ a_Chunk.SetBlock(a_RelPos, E_BLOCK_AIR, 0);
+ return;
+ }
+
+ // Artificial light on any of the surrounding block > 11 leads to melting the ice.
+ static const std::array<Vector3i, 7> Adjacents
+ {
+ {
+ { 1, 0, 0 }, { -1, 0, 0 },
+ { 0, 1, 0 }, { 0, -1, 0 },
+ { 0, 0, 1 }, { 0, 0, -1 }
+ }
+ };
+
+ for (const auto Offset : Adjacents)
{
- return {};
+ auto Position = a_RelPos + Offset;
+ const auto Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(Position);
+
+ if ((Chunk == nullptr) || !Chunk->IsValid())
+ {
+ continue;
+ }
+
+ if (!Chunk->IsLightValid())
+ {
+ Chunk->GetWorld()->QueueLightChunk(Chunk->GetPosX(), Chunk->GetPosZ());
+ continue;
+ }
+
+ if (Chunk->GetBlockLight(Position) > 11)
+ {
+ a_Chunk.SetBlock(a_RelPos, E_BLOCK_STATIONARY_WATER, 0);
+ return;
+ }
}
}