summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-08-19 23:43:08 +0200
committermadmaxoft <github@xoft.cz>2013-08-19 23:43:08 +0200
commit2e5de0c13d10a54beb33370b5364b8d8cc4c1550 (patch)
treeb50cb4c72e4b525f44a2067f1e6c060a97e21b7d /source
parentDebuggers: Added continuous hunger reporting. (diff)
parentAdditional piston corrections (diff)
downloadcuberite-2e5de0c13d10a54beb33370b5364b8d8cc4c1550.tar
cuberite-2e5de0c13d10a54beb33370b5364b8d8cc4c1550.tar.gz
cuberite-2e5de0c13d10a54beb33370b5364b8d8cc4c1550.tar.bz2
cuberite-2e5de0c13d10a54beb33370b5364b8d8cc4c1550.tar.lz
cuberite-2e5de0c13d10a54beb33370b5364b8d8cc4c1550.tar.xz
cuberite-2e5de0c13d10a54beb33370b5364b8d8cc4c1550.tar.zst
cuberite-2e5de0c13d10a54beb33370b5364b8d8cc4c1550.zip
Diffstat (limited to 'source')
-rw-r--r--source/Chunk.h2
-rw-r--r--source/Piston.cpp24
2 files changed, 17 insertions, 9 deletions
diff --git a/source/Chunk.h b/source/Chunk.h
index 6e8fe5cbf..c979b7928 100644
--- a/source/Chunk.h
+++ b/source/Chunk.h
@@ -330,7 +330,7 @@ private:
Int64 m_Tick;
sSetBlockQueueItem(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick) :
- m_RelX(a_RelX), m_RelY(a_RelY), m_RelZ(a_RelZ)
+ m_RelX(a_RelX), m_RelY(a_RelY), m_RelZ(a_RelZ), m_BlockType(a_BlockType), m_BlockMeta(a_BlockMeta), m_Tick(a_Tick)
{
}
} ;
diff --git a/source/Piston.cpp b/source/Piston.cpp
index d6ea01803..2431bdac2 100644
--- a/source/Piston.cpp
+++ b/source/Piston.cpp
@@ -20,6 +20,13 @@ extern bool g_BlockPistonBreakable[];
+/// Number of ticks that the piston extending / retracting waits before setting the block
+const int PISTON_TICK_DELAY = 5;
+
+
+
+
+
cPiston::cPiston(cWorld * a_World)
: m_World(a_World)
{
@@ -98,7 +105,7 @@ void cPiston::ExtendPiston(int pistx, int pisty, int pistz)
{
AddDir(pistx, pisty, pistz, pistonMeta, -1);
m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currBlockMeta);
- m_World->SetBlock( oldx, oldy, oldz, currBlock, currBlockMeta);
+ m_World->QueueSetBlock( oldx, oldy, oldz, currBlock, currBlockMeta, PISTON_TICK_DELAY);
oldx = pistx;
oldy = pisty;
oldz = pistz;
@@ -113,14 +120,14 @@ void cPiston::ExtendPiston(int pistx, int pisty, int pistz)
m_World->BroadcastBlockAction(pistx, pisty, pistz, 0, pistonMeta, pistonBlock);
m_World->BroadcastSoundEffect("tile.piston.out", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f);
m_World->FastSetBlock( pistx, pisty, pistz, pistonBlock, pistonMeta | 0x8 );
- m_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0));
+ m_World->QueueSetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0), PISTON_TICK_DELAY);
}
-void cPiston::RetractPiston( int pistx, int pisty, int pistz )
+void cPiston::RetractPiston(int pistx, int pisty, int pistz)
{
BLOCKTYPE pistonBlock;
NIBBLETYPE pistonMeta;
@@ -133,7 +140,7 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz )
m_World->BroadcastBlockAction(pistx, pisty, pistz, 1, pistonMeta & ~(8), pistonBlock);
m_World->BroadcastSoundEffect("tile.piston.in", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f);
- m_World->SetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8));
+ m_World->QueueSetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8), PISTON_TICK_DELAY);
// Check the extension:
@@ -155,18 +162,18 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz )
if (CanPull(tempBlock, tempMeta))
{
// Pull the block
- m_World->SetBlock(pistx, pisty, pistz, tempBlock, tempMeta);
- m_World->SetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0);
+ m_World->QueueSetBlock(pistx, pisty, pistz, tempBlock, tempMeta, PISTON_TICK_DELAY);
+ m_World->QueueSetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY);
}
else
{
// Retract without pulling
- m_World->SetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0);
+ m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY);
}
}
else
{
- m_World->SetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0);
+ m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY);
}
}
@@ -228,6 +235,7 @@ bool cPiston::CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
return false;
}
+ case E_BLOCK_STICKY_PISTON:
case E_BLOCK_PISTON:
{
// A piston can only be pushed if retracted: