summaryrefslogtreecommitdiffstats
path: root/source/cPiston.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-19 21:42:32 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-19 21:42:32 +0200
commit427e582d5fcbd5025a81a4e89ccada47877ccc64 (patch)
tree1196585a1a6fdc39c6a05aa117cfa2766f7dca2f /source/cPiston.cpp
parentAndroid: Do not create an input thread for Android (diff)
downloadcuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.tar
cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.tar.gz
cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.tar.bz2
cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.tar.lz
cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.tar.xz
cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.tar.zst
cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.zip
Diffstat (limited to 'source/cPiston.cpp')
-rw-r--r--source/cPiston.cpp48
1 files changed, 17 insertions, 31 deletions
diff --git a/source/cPiston.cpp b/source/cPiston.cpp
index be8b0dff3..b314cffe1 100644
--- a/source/cPiston.cpp
+++ b/source/cPiston.cpp
@@ -77,38 +77,32 @@ void cPiston::ExtendPiston( int pistx, int pisty, int pistz )
}
int oldx = pistx, oldy = pisty, oldz = pistz;
char currBlockMeta;
- for (int i = dist+1; i>0; i--)
+ for (int i = dist + 1; i>0; i--)
{
- AddDir( pistx, pisty, pistz, pistonMeta & 7, -1 )
- currBlock = m_World->GetBlock( pistx, pisty, pistz );
- currBlockMeta = m_World->GetBlockMeta( pistx, pisty, pistz );
- m_World->SetBlock( oldx, oldy, oldz, currBlock, currBlockMeta );
+ AddDir(pistx, pisty, pistz, pistonMeta & 7, -1)
+ currBlock = m_World->GetBlock(pistx, pisty, pistz);
+ currBlockMeta = m_World->GetBlockMeta(pistx, pisty, pistz);
+ m_World->SetBlock( oldx, oldy, oldz, currBlock, currBlockMeta);
oldx = pistx;
oldy = pisty;
oldz = pistz;
}
- cPacket_BlockAction Action;
- Action.m_PosX = (int)pistx;
- Action.m_PosY = (short)pisty;
- Action.m_PosZ = (int)pistz;
- Action.m_Byte1 = 0;
- Action.m_Byte2 = pistonMeta;
-
- m_World->BroadcastToChunkOfBlock(pistx, pisty, pistz, &Action);
+ m_World->BroadcastBlockAction(pistx, pisty, pistz, 0, pistonMeta);
m_World->FastSetBlock( pistx, pisty, pistz, pistonBlock, pistonMeta | 0x8 );
int extx = pistx;
int exty = pisty;
int extz = pistz;
- AddDir( extx, exty, extz, pistonMeta&7, 1 )
+ AddDir(extx, exty, extz, pistonMeta & 7, 1)
- m_World->SetBlock( extx, exty, extz, E_BLOCK_PISTON_EXTENSION, isSticky+pistonMeta&7 );
+ m_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, isSticky + pistonMeta & 7);
- if (recalc) {
+ if (recalc)
+ {
cRedstone Redstone(m_World);
- Redstone.ChangeRedstone( extx, exty, extz, false ); //recalculate redstone around current device.
- Redstone.ChangeRedstone( pistx, pisty, pistz, false ); //recalculate redstone around current device.
+ Redstone.ChangeRedstone(extx, exty, extz, false); // recalculate redstone around current device
+ Redstone.ChangeRedstone(pistx, pisty, pistz, false); // recalculate redstone around current device
}
}
}
@@ -125,21 +119,13 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz )
{
return;
}
+ m_World->BroadcastBlockAction(pistx, pisty, pistz, 1, pistonMeta & ~(8));
+ m_World->FastSetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8));
- //send blockaction packet
- cPacket_BlockAction Action;
- Action.m_PosX = (int)pistx;
- Action.m_PosY = (short)pisty;
- Action.m_PosZ = (int)pistz;
- Action.m_Byte1 = 1;
- Action.m_Byte2 = pistonMeta & ~(8);
- m_World->BroadcastToChunkOfBlock(pistx, pisty, pistz, &Action );
- m_World->FastSetBlock( pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8) );
-
- AddDir( pistx, pisty, pistz, pistonMeta & 7, 1 )
- if ( m_World->GetBlock( pistx, pisty, pistz ) == E_BLOCK_PISTON_EXTENSION )
+ AddDir(pistx, pisty, pistz, pistonMeta & 7, 1)
+ if (m_World->GetBlock(pistx, pisty, pistz) == E_BLOCK_PISTON_EXTENSION)
{
- if ( pistonBlock == E_BLOCK_STICKY_PISTON )
+ if (pistonBlock == E_BLOCK_STICKY_PISTON)
{
int tempx = pistx, tempy = pisty, tempz = pistz;
AddDir( tempx, tempy, tempz, pistonMeta & 7, 1 )