Redstone simulator: adding a block now checks if the neighbors are redstone-related; if not, the block is ignored.
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1247 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
a2925ee6c8
commit
4e8fd2c084
@ -7,6 +7,7 @@
|
|||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "../BlockID.h"
|
#include "../BlockID.h"
|
||||||
#include "../Torch.h"
|
#include "../Torch.h"
|
||||||
|
#include "../Chunk.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -30,8 +31,44 @@ cRedstoneSimulator::~cRedstoneSimulator()
|
|||||||
|
|
||||||
|
|
||||||
void cRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
|
void cRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk)
|
||||||
|
{
|
||||||
|
if (a_Chunk == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
|
||||||
|
int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
|
||||||
|
|
||||||
|
// Check if any close neighbor is redstone-related:
|
||||||
|
int MinY = (a_BlockY > 0) ? -1 : 0;
|
||||||
|
int MaxY = (a_BlockY < cChunkDef::Height - 1) ? 1 : 0;
|
||||||
|
for (int y = MinY; y <= MaxY; y++) for (int x = -1; x < 2; x++) for (int z = -1; z < 2; z++)
|
||||||
|
{
|
||||||
|
BLOCKTYPE BlockType;
|
||||||
|
NIBBLETYPE BlockMeta;
|
||||||
|
if (!a_Chunk->UnboundedRelGetBlock(RelX + x, a_BlockY + y, RelZ + z, BlockType, BlockMeta))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch (BlockType)
|
||||||
|
{
|
||||||
|
case E_BLOCK_REDSTONE_LAMP_OFF:
|
||||||
|
case E_BLOCK_REDSTONE_LAMP_ON:
|
||||||
|
case E_BLOCK_REDSTONE_REPEATER_OFF:
|
||||||
|
case E_BLOCK_REDSTONE_REPEATER_ON:
|
||||||
|
case E_BLOCK_REDSTONE_TORCH_OFF:
|
||||||
|
case E_BLOCK_REDSTONE_TORCH_ON:
|
||||||
|
case E_BLOCK_REDSTONE_WIRE:
|
||||||
|
case E_BLOCK_LEVER:
|
||||||
|
case E_BLOCK_STONE_BUTTON:
|
||||||
|
case E_BLOCK_WOODEN_BUTTON:
|
||||||
|
case E_BLOCK_TRIPWIRE_HOOK:
|
||||||
{
|
{
|
||||||
m_Blocks.push_back(Vector3i(a_BlockX, a_BlockY, a_BlockZ));
|
m_Blocks.push_back(Vector3i(a_BlockX, a_BlockY, a_BlockZ));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} // switch (BlockType)
|
||||||
|
} // for y, x, z - neighbors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user