summaryrefslogtreecommitdiffstats
path: root/source/cPiston.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-06 22:18:50 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-06 22:18:50 +0200
commit1cca9b13b3d320ff767cfc552413265b2ef6e0d6 (patch)
treec1227f3f4141dbf2f85767a65cb9d2102a9d4010 /source/cPiston.cpp
parentBlockIDs, ItemIDs and Metas updated, courtesy of Taugeshtu (diff)
downloadcuberite-1cca9b13b3d320ff767cfc552413265b2ef6e0d6.tar
cuberite-1cca9b13b3d320ff767cfc552413265b2ef6e0d6.tar.gz
cuberite-1cca9b13b3d320ff767cfc552413265b2ef6e0d6.tar.bz2
cuberite-1cca9b13b3d320ff767cfc552413265b2ef6e0d6.tar.lz
cuberite-1cca9b13b3d320ff767cfc552413265b2ef6e0d6.tar.xz
cuberite-1cca9b13b3d320ff767cfc552413265b2ef6e0d6.tar.zst
cuberite-1cca9b13b3d320ff767cfc552413265b2ef6e0d6.zip
Diffstat (limited to '')
-rw-r--r--source/cPiston.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/source/cPiston.cpp b/source/cPiston.cpp
index f97a80b8c..c89fb5077 100644
--- a/source/cPiston.cpp
+++ b/source/cPiston.cpp
@@ -51,7 +51,8 @@ unsigned short cPiston::FirstPassthroughBlock( int pistonX, int pistonY, int pis
-void cPiston::ExtendPiston( int pistx, int pisty, int pistz ) {
+void cPiston::ExtendPiston( int pistx, int pisty, int pistz )
+{
char pistonBlock = m_World->GetBlock( pistx, pisty, pistz );
char pistonMeta = m_World->GetBlockMeta( pistx, pisty, pistz );
char isSticky = (char)(pistonBlock == E_BLOCK_STICKY_PISTON) * 8;
@@ -59,21 +60,22 @@ void cPiston::ExtendPiston( int pistx, int pisty, int pistz ) {
if ( (pistonMeta & 0x8) == 0x0 ) // only extend if piston is not already extended
{
unsigned short dist = FirstPassthroughBlock(pistx, pisty, pistz, pistonMeta);
- if(dist>9000) return; // too many blocks
+ if (dist > 9000) return; // too many blocks
AddDir( pistx, pisty, pistz, pistonMeta & 7, dist+1 )
- char currBlock = m_World->GetBlock( pistx, pisty, pistz );
- if( currBlock != E_BLOCK_AIR ) {
- cItem PickupItem;
- PickupItem.m_ItemID = cBlockToPickup::ToPickup( (ENUM_BLOCK_ID) currBlock, E_ITEM_EMPTY );
- PickupItem.m_ItemCount = 1;
- cPickup* Pickup = new cPickup( pistx*32 + 16, pisty*32 + 16, pistz*32 + 16, PickupItem );
- Pickup->Initialize( m_World );
+ BLOCKTYPE currBlock = m_World->GetBlock (pistx, pisty, pistz);
+ NIBBLETYPE currMeta = m_World->GetBlockMeta(pistx, pisty, pistz);
+ if (currBlock != E_BLOCK_AIR)
+ {
+ cItems PickupItems;
+ cBlockToPickup::ToPickup(currBlock, currMeta, E_ITEM_EMPTY, PickupItems);
+ m_World->SpawnItemPickups(PickupItems, pistx, pisty, pistz);
recalc = true;
}
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 );