summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradmin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-11-07 20:15:27 +0100
committeradmin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-11-07 20:15:27 +0100
commit9812c38ae2c4b1e0bb9f333d3459418fb5d78e7b (patch)
tree5621b00c8beec9b394bb36246c9f6eecf501afd1
parentAdded Sebi's changes to pistons and item drops. (diff)
downloadcuberite-9812c38ae2c4b1e0bb9f333d3459418fb5d78e7b.tar
cuberite-9812c38ae2c4b1e0bb9f333d3459418fb5d78e7b.tar.gz
cuberite-9812c38ae2c4b1e0bb9f333d3459418fb5d78e7b.tar.bz2
cuberite-9812c38ae2c4b1e0bb9f333d3459418fb5d78e7b.tar.lz
cuberite-9812c38ae2c4b1e0bb9f333d3459418fb5d78e7b.tar.xz
cuberite-9812c38ae2c4b1e0bb9f333d3459418fb5d78e7b.tar.zst
cuberite-9812c38ae2c4b1e0bb9f333d3459418fb5d78e7b.zip
Diffstat (limited to '')
-rw-r--r--source/cPiston.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/source/cPiston.cpp b/source/cPiston.cpp
index 16df55089..8d05be87f 100644
--- a/source/cPiston.cpp
+++ b/source/cPiston.cpp
@@ -4,6 +4,7 @@
#include "cBlockToPickup.h"
#include "cItem.h"
#include "cRoot.h"
+#include "cClientHandle.h"
#include "cWorld.h"
#include "BlockID.h"
#include "packets/cPacket_BlockAction.h"
@@ -14,6 +15,7 @@ extern bool g_BlockPistonBreakable[];
#define AddDir( x, y, z, dir, amount ) switch(dir) { case 0: (y)-=(amount); break; case 1: (y)+=(amount); break;\
case 2: (z)-=(amount); break; case 3: (z)+=(amount); break;\
case 4: (x)-=(amount); break; case 5: (x)+=(amount); break; }
+#define FAST_FLOOR( x ) ( (x) < 0 ? ((int)x)-1 : ((int)x) )
cPiston::cPiston( cWorld* a_World )
:m_World ( a_World )
@@ -71,7 +73,8 @@ void cPiston::ExtendPiston( int pistx, int pisty, int pistz ) {
Action.m_PosZ = (int)pistz;
Action.m_Byte1 = 0;
Action.m_Byte2 = pistonMeta;
- cRoot::Get()->GetServer()->Broadcast( Action );
+ cChunk* Chunk = m_World->GetChunk( FAST_FLOOR(pistx/16), FAST_FLOOR(pisty/16), FAST_FLOOR(pistz/16) );
+ Chunk->Broadcast( Action );
m_World->FastSetBlock( pistx, pisty, pistz, pistonBlock, pistonMeta | 8 );
int extx = pistx;
@@ -94,7 +97,8 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz ) {
Action.m_PosZ = (int)pistz;
Action.m_Byte1 = 1;
Action.m_Byte1 = pistonMeta & ~(8);
- cRoot::Get()->GetServer()->Broadcast( Action );
+ cChunk* Chunk = m_World->GetChunk( FAST_FLOOR(pistx/16), FAST_FLOOR(pisty/16), FAST_FLOOR(pistz/16) );
+ Chunk->Broadcast( Action );
m_World->FastSetBlock( pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8) );
AddDir( pistx, pisty, pistz, pistonMeta & 7, 1 )