Fix ice behaviour in world (#4927)
+ Added proper ice melting under light influence Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
This commit is contained in:
parent
3edcafdf8b
commit
b5410c718e
@ -59,6 +59,7 @@
|
|||||||
#include "BlockNetherWart.h"
|
#include "BlockNetherWart.h"
|
||||||
#include "BlockObserver.h"
|
#include "BlockObserver.h"
|
||||||
#include "BlockOre.h"
|
#include "BlockOre.h"
|
||||||
|
#include "BlockPackedIce.h"
|
||||||
#include "BlockPiston.h"
|
#include "BlockPiston.h"
|
||||||
#include "BlockPlanks.h"
|
#include "BlockPlanks.h"
|
||||||
#include "BlockPortal.h"
|
#include "BlockPortal.h"
|
||||||
@ -354,7 +355,7 @@ namespace
|
|||||||
constexpr cBlockHandler BlockObsidianHandler (E_BLOCK_OBSIDIAN);
|
constexpr cBlockHandler BlockObsidianHandler (E_BLOCK_OBSIDIAN);
|
||||||
constexpr cBlockGlazedTerracottaHandler BlockOrangeGlazedTerracottaHandler(E_BLOCK_ORANGE_GLAZED_TERRACOTTA);
|
constexpr cBlockGlazedTerracottaHandler BlockOrangeGlazedTerracottaHandler(E_BLOCK_ORANGE_GLAZED_TERRACOTTA);
|
||||||
constexpr cBlockHandler BlockOrangeShulkerBoxHandler (E_BLOCK_ORANGE_SHULKER_BOX);
|
constexpr cBlockHandler BlockOrangeShulkerBoxHandler (E_BLOCK_ORANGE_SHULKER_BOX);
|
||||||
constexpr cBlockIceHandler BlockPackedIceHandler (E_BLOCK_PACKED_ICE);
|
constexpr cBlockPackedIceHandler BlockPackedIceHandler (E_BLOCK_PACKED_ICE);
|
||||||
constexpr cBlockGlazedTerracottaHandler BlockPinkGlazedTerracottaHandler (E_BLOCK_PINK_GLAZED_TERRACOTTA);
|
constexpr cBlockGlazedTerracottaHandler BlockPinkGlazedTerracottaHandler (E_BLOCK_PINK_GLAZED_TERRACOTTA);
|
||||||
constexpr cBlockHandler BlockPinkShulkerBoxHandler (E_BLOCK_PINK_SHULKER_BOX);
|
constexpr cBlockHandler BlockPinkShulkerBoxHandler (E_BLOCK_PINK_SHULKER_BOX);
|
||||||
constexpr cBlockPistonHandler BlockPistonHandler (E_BLOCK_PISTON);
|
constexpr cBlockPistonHandler BlockPistonHandler (E_BLOCK_PISTON);
|
||||||
|
@ -25,9 +25,56 @@ private:
|
|||||||
{
|
{
|
||||||
return cItem(m_BlockType);
|
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)
|
||||||
{
|
{
|
||||||
return {};
|
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)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
src/Blocks/BlockPackedIce.h
Normal file
37
src/Blocks/BlockPackedIce.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "BlockHandler.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cBlockPackedIceHandler :
|
||||||
|
public cBlockHandler
|
||||||
|
{
|
||||||
|
using Super = cBlockHandler;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
using Super::Super;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override
|
||||||
|
{
|
||||||
|
// Only drop self when using silk-touch:
|
||||||
|
if (ToolHasSilkTouch(a_Tool))
|
||||||
|
{
|
||||||
|
return cItem(m_BlockType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
|
||||||
|
{
|
||||||
|
UNUSED(a_Meta);
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
} ;
|
@ -61,6 +61,7 @@ target_sources(
|
|||||||
BlockNetherWart.h
|
BlockNetherWart.h
|
||||||
BlockObserver.h
|
BlockObserver.h
|
||||||
BlockOre.h
|
BlockOre.h
|
||||||
|
BlockPackedIce.h
|
||||||
BlockPiston.h
|
BlockPiston.h
|
||||||
BlockPlanks.h
|
BlockPlanks.h
|
||||||
BlockPlant.h
|
BlockPlant.h
|
||||||
|
Loading…
Reference in New Issue
Block a user