Add Trapdoor Functions to cWorld and fix Trapdoor Redstone Bugs
This commit is contained in:
parent
0274db0e14
commit
e4b2502896
@ -36,8 +36,10 @@ public:
|
||||
{
|
||||
// Flip the ON bit on/off using the XOR bitwise operation
|
||||
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x04);
|
||||
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
|
||||
|
||||
cWorld * World = (cWorld *) &a_WorldInterface;
|
||||
World->BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle());
|
||||
}
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
|
@ -937,17 +937,15 @@ void cIncrementalRedstoneSimulator::HandleTrapdoor(int a_BlockX, int a_BlockY, i
|
||||
{
|
||||
if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, true))
|
||||
{
|
||||
m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) | 0x4);
|
||||
m_World.BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0);
|
||||
m_World.SetTrapdoorOpen(a_BlockX, a_BlockY, a_BlockZ, true);
|
||||
SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!AreCoordsSimulated(a_BlockX, a_BlockY, a_BlockZ, false))
|
||||
{
|
||||
m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0xB); // Take into account that the fourth bit is needed for trapdoors too
|
||||
m_World.BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0);
|
||||
m_World.SetTrapdoorOpen(a_BlockX, a_BlockY, a_BlockZ, false);
|
||||
SetPlayerToggleableBlockAsSimulated(a_BlockX, a_BlockY, a_BlockZ, false);
|
||||
}
|
||||
}
|
||||
|
@ -2647,6 +2647,43 @@ bool cWorld::SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, co
|
||||
|
||||
|
||||
|
||||
bool cWorld::IsTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
if (GetBlock(a_BlockX, a_BlockY, a_BlockZ) != E_BLOCK_TRAPDOOR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
NIBBLETYPE Meta = GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
return (Meta & 0x4) > 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cWorld::SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open)
|
||||
{
|
||||
if (GetBlock(a_BlockX, a_BlockY, a_BlockZ) != E_BLOCK_TRAPDOOR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
NIBBLETYPE Meta = GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
bool IsOpen = (Meta & 0x4) > 0;
|
||||
if (a_Open != IsOpen)
|
||||
{
|
||||
SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta ^ 0x4);
|
||||
BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cWorld::RegenerateChunk(int a_ChunkX, int a_ChunkZ)
|
||||
{
|
||||
m_ChunkMap->MarkChunkRegenerating(a_ChunkX, a_ChunkZ);
|
||||
|
@ -342,6 +342,12 @@ public:
|
||||
/** Sets the command block command. Returns true if command changed. */
|
||||
bool SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Command); // tolua_export
|
||||
|
||||
/** Is the trapdoor open? */
|
||||
bool IsTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
|
||||
|
||||
/** Set the state of a trapdoor */
|
||||
bool SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open); // tolua_export
|
||||
|
||||
/** Regenerate the given chunk: */
|
||||
void RegenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user