2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BlockHandler.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-05 06:27:14 -04:00
|
|
|
class cBlockIceHandler final :
|
2013-07-29 07:13:03 -04:00
|
|
|
public cBlockHandler
|
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cBlockHandler;
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
public:
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
using Super::Super;
|
|
|
|
|
|
|
|
private:
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-09-23 11:06:27 -04:00
|
|
|
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2019-10-16 04:06:34 -04:00
|
|
|
// Only drop self when using silk-touch:
|
|
|
|
if (ToolHasSilkTouch(a_Tool))
|
|
|
|
{
|
|
|
|
return cItem(m_BlockType);
|
|
|
|
}
|
2020-09-24 08:53:49 -04:00
|
|
|
|
|
|
|
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 }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-10-05 06:27:14 -04:00
|
|
|
for (const auto & Offset : Adjacents)
|
2019-10-16 04:06:34 -04:00
|
|
|
{
|
2020-09-24 08:53:49 -04:00
|
|
|
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;
|
|
|
|
}
|
2019-10-16 04:06:34 -04:00
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
virtual void OnBroken(
|
|
|
|
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
|
|
|
|
Vector3i a_BlockPos,
|
2020-10-08 15:13:44 -04:00
|
|
|
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta,
|
|
|
|
const cEntity * a_Digger
|
2020-09-20 09:50:52 -04:00
|
|
|
) const override
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2019-10-16 04:06:34 -04:00
|
|
|
// If there's a solid block or a liquid underneath, convert to water, rather than air
|
|
|
|
if (a_BlockPos.y <= 0)
|
2014-07-31 12:41:48 -04:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2020-08-01 06:25:06 -04:00
|
|
|
|
|
|
|
const auto Below = a_ChunkInterface.GetBlock(a_BlockPos.addedY(-1));
|
|
|
|
if (cBlockInfo::FullyOccupiesVoxel(Below) || IsBlockLiquid(Below))
|
2014-07-31 12:41:48 -04:00
|
|
|
{
|
2019-10-16 04:06:34 -04:00
|
|
|
a_ChunkInterface.SetBlock(a_BlockPos, E_BLOCK_WATER, 0);
|
2014-07-31 12:41:48 -04:00
|
|
|
}
|
2014-07-17 16:50:58 -04:00
|
|
|
}
|
2015-06-30 10:50:15 -04:00
|
|
|
|
2020-10-08 15:13:44 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
|
2015-06-30 10:50:15 -04:00
|
|
|
{
|
|
|
|
UNUSED(a_Meta);
|
|
|
|
return 5;
|
|
|
|
}
|
2014-08-19 10:47:33 -04:00
|
|
|
} ;
|