summaryrefslogtreecommitdiffstats
path: root/source/cRedstone.cpp
diff options
context:
space:
mode:
authoradmin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-11-09 04:04:56 +0100
committeradmin@omencraft.com <admin@omencraft.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-11-09 04:04:56 +0100
commit9e77db8e3d4f8e046c1db26d9889f440e761dc38 (patch)
tree3c4bf05ff03d0d93bd3b98cabbd7e1e0ac8a5913 /source/cRedstone.cpp
parentRedstone clocks now work. even one clocks. torches don't update themselves when placed yet, but redstone wire updates the torch. Fixed a bug with piston animations. (diff)
downloadcuberite-9e77db8e3d4f8e046c1db26d9889f440e761dc38.tar
cuberite-9e77db8e3d4f8e046c1db26d9889f440e761dc38.tar.gz
cuberite-9e77db8e3d4f8e046c1db26d9889f440e761dc38.tar.bz2
cuberite-9e77db8e3d4f8e046c1db26d9889f440e761dc38.tar.lz
cuberite-9e77db8e3d4f8e046c1db26d9889f440e761dc38.tar.xz
cuberite-9e77db8e3d4f8e046c1db26d9889f440e761dc38.tar.zst
cuberite-9e77db8e3d4f8e046c1db26d9889f440e761dc38.zip
Diffstat (limited to 'source/cRedstone.cpp')
-rw-r--r--source/cRedstone.cpp49
1 files changed, 38 insertions, 11 deletions
diff --git a/source/cRedstone.cpp b/source/cRedstone.cpp
index 1a981e654..21b1eb416 100644
--- a/source/cRedstone.cpp
+++ b/source/cRedstone.cpp
@@ -63,6 +63,7 @@ char before;
m_Metadata = 0;
m_Direction = 3;
CalculatetRedstone( fillx, filly, fillz-1 );
+ m_Direction = 4;
break;
}
case E_BLOCK_REDSTONE_WIRE: //special case for redstone wire.
@@ -75,6 +76,18 @@ char before;
CalculatetRedstone( fillx, filly, fillz+1 );
m_Direction = 3;
CalculatetRedstone( fillx, filly, fillz-1 );
+
+ m_Direction = 4;
+ CalculatetRedstone( fillx+1, filly+1, fillz );
+ CalculatetRedstone( fillx-1, filly+1, fillz );
+ CalculatetRedstone( fillx, filly+1, fillz+1 );
+ CalculatetRedstone( fillx, filly+1, fillz-1 );
+
+ m_Direction = 4;
+ CalculatetRedstone( fillx+1, filly-1, fillz );
+ CalculatetRedstone( fillx-1, filly-1, fillz );
+ CalculatetRedstone( fillx, filly-1, fillz+1 );
+ CalculatetRedstone( fillx, filly-1, fillz-1 );
break;
}
}
@@ -206,6 +219,18 @@ void cRedstone::CalculatetRedstone( int fillx, int filly, int fillz)
CalculatetRedstone( fillx, filly, fillz+1 );
m_Direction = 3;
CalculatetRedstone( fillx, filly, fillz-1 );
+
+ m_Direction = 4;
+ CalculatetRedstone( fillx+1, filly+1, fillz );
+ CalculatetRedstone( fillx-1, filly+1, fillz );
+ CalculatetRedstone( fillx, filly+1, fillz+1 );
+ CalculatetRedstone( fillx, filly+1, fillz-1 );
+
+ m_Direction = 5;
+ CalculatetRedstone( fillx+1, filly-1, fillz );
+ CalculatetRedstone( fillx-1, filly-1, fillz );
+ CalculatetRedstone( fillx, filly-1, fillz+1 );
+ CalculatetRedstone( fillx, filly-1, fillz-1 );
}
} else { //default, check item for torch attached to it. If meta > 0 then turn that torch off, otherwise turn it on. This change needs to be passed to the next world tick.
@@ -215,40 +240,40 @@ void cRedstone::CalculatetRedstone( int fillx, int filly, int fillz)
//check for torch to north with meta 4 //turn off
//check for torch above with meta 5 //turn off
if ( (int)m_World->GetBlock( fillx, filly, fillz ) != E_BLOCK_AIR ) {
-
+ if (m_Direction < 4) { //redstone wire can only power blocks on the same plane or directly below
if ( (int)m_Metadata > 0 ) { //wire powered
//printf("bird: %i dog: %i \n",(int)m_World->GetBlock( fillx, filly+1, fillz ),(int)m_World->GetBlockMeta( fillx, filly+1, fillz));
if ( ( (int)m_World->GetBlock( fillx+1, filly, fillz ) == E_BLOCK_REDSTONE_TORCH_ON) && ( (int)m_World->GetBlockMeta( fillx+1, filly, fillz) == 1 ) ) { //east
- m_World->FastSetBlock( fillx+1, filly, fillz, E_BLOCK_REDSTONE_TORCH_OFF, m_World->GetBlockMeta( fillx+1, filly, fillz) );
+ //m_World->FastSetBlock( fillx+1, filly, fillz, E_BLOCK_REDSTONE_TORCH_OFF, m_World->GetBlockMeta( fillx+1, filly, fillz) );
m_World->m_RSList.push_back(fillx+1);
m_World->m_RSList.push_back(filly);
m_World->m_RSList.push_back(fillz);
m_World->m_RSList.push_back(00000);
}
if ( ( (int)m_World->GetBlock( fillx-1, filly, fillz ) == E_BLOCK_REDSTONE_TORCH_ON) && ( (int)m_World->GetBlockMeta( fillx-1, filly, fillz) == 2 ) ) { //west
- m_World->FastSetBlock( fillx-1, filly, fillz, E_BLOCK_REDSTONE_TORCH_OFF, m_World->GetBlockMeta( fillx-1, filly, fillz) );
+ //m_World->FastSetBlock( fillx-1, filly, fillz, E_BLOCK_REDSTONE_TORCH_OFF, m_World->GetBlockMeta( fillx-1, filly, fillz) );
m_World->m_RSList.push_back(fillx-1);
m_World->m_RSList.push_back(filly);
m_World->m_RSList.push_back(fillz);
m_World->m_RSList.push_back(00000);
}
if ( ( (int)m_World->GetBlock( fillx, filly, fillz+1 ) == E_BLOCK_REDSTONE_TORCH_ON) && ( (int)m_World->GetBlockMeta( fillx, filly, fillz+1) == 3 ) ) { //south
- m_World->FastSetBlock( fillx, filly, fillz+1, E_BLOCK_REDSTONE_TORCH_OFF, m_World->GetBlockMeta( fillx, filly, fillz+1) );
+ //m_World->FastSetBlock( fillx, filly, fillz+1, E_BLOCK_REDSTONE_TORCH_OFF, m_World->GetBlockMeta( fillx, filly, fillz+1) );
m_World->m_RSList.push_back(fillx);
m_World->m_RSList.push_back(filly);
m_World->m_RSList.push_back(fillz+1);
m_World->m_RSList.push_back(00000);
}
if ( ( (int)m_World->GetBlock( fillx, filly, fillz-1 ) == E_BLOCK_REDSTONE_TORCH_ON) && ( (int)m_World->GetBlockMeta( fillx, filly, fillz-1) == 4 ) ) { //north
- m_World->FastSetBlock( fillx, filly, fillz-1, E_BLOCK_REDSTONE_TORCH_OFF, m_World->GetBlockMeta( fillx, filly, fillz-1) );
+ //m_World->FastSetBlock( fillx, filly, fillz-1, E_BLOCK_REDSTONE_TORCH_OFF, m_World->GetBlockMeta( fillx, filly, fillz-1) );
m_World->m_RSList.push_back(fillx);
m_World->m_RSList.push_back(filly);
m_World->m_RSList.push_back(fillz-1);
m_World->m_RSList.push_back(00000);
}
if ( ( (int)m_World->GetBlock( fillx, filly+1, fillz ) == E_BLOCK_REDSTONE_TORCH_ON) && ( (int)m_World->GetBlockMeta( fillx, filly+1, fillz) == 5 ) ) { //top
- m_World->FastSetBlock( fillx, filly+1, fillz, E_BLOCK_REDSTONE_TORCH_OFF, m_World->GetBlockMeta( fillx, filly+1, fillz) );
+ //m_World->FastSetBlock( fillx, filly+1, fillz, E_BLOCK_REDSTONE_TORCH_OFF, m_World->GetBlockMeta( fillx, filly+1, fillz) );
m_World->m_RSList.push_back(fillx);
m_World->m_RSList.push_back(filly+1);
m_World->m_RSList.push_back(fillz);
@@ -262,35 +287,35 @@ void cRedstone::CalculatetRedstone( int fillx, int filly, int fillz)
//printf("echo: %i cruiser: %i \n",(int)m_World->GetBlock( fillx, filly+1, fillz ),(int)m_World->GetBlockMeta( fillx, filly+1, fillz));
if ( ( (int)m_World->GetBlock( fillx+1, filly, fillz ) == E_BLOCK_REDSTONE_TORCH_OFF) && ( (int)m_World->GetBlockMeta( fillx+1, filly, fillz) == 1 ) ) { //east
- m_World->FastSetBlock( fillx+1, filly, fillz, E_BLOCK_REDSTONE_TORCH_ON, m_World->GetBlockMeta( fillx+1, filly, fillz) );
+ //m_World->FastSetBlock( fillx+1, filly, fillz, E_BLOCK_REDSTONE_TORCH_ON, m_World->GetBlockMeta( fillx+1, filly, fillz) );
m_World->m_RSList.push_back(fillx+1);
m_World->m_RSList.push_back(filly);
m_World->m_RSList.push_back(fillz);
m_World->m_RSList.push_back(11111);
}
if ( ( (int)m_World->GetBlock( fillx-1, filly, fillz ) == E_BLOCK_REDSTONE_TORCH_OFF) && ( (int)m_World->GetBlockMeta( fillx-1, filly, fillz) == 2 ) ) { //west
- m_World->FastSetBlock( fillx-1, filly, fillz, E_BLOCK_REDSTONE_TORCH_ON, m_World->GetBlockMeta( fillx-1, filly, fillz) );
+ //m_World->FastSetBlock( fillx-1, filly, fillz, E_BLOCK_REDSTONE_TORCH_ON, m_World->GetBlockMeta( fillx-1, filly, fillz) );
m_World->m_RSList.push_back(fillx-1);
m_World->m_RSList.push_back(filly);
m_World->m_RSList.push_back(fillz);
m_World->m_RSList.push_back(11111);
}
if ( ( (int)m_World->GetBlock( fillx, filly, fillz+1 ) == E_BLOCK_REDSTONE_TORCH_OFF) && ( (int)m_World->GetBlockMeta( fillx, filly, fillz+1) == 3 ) ) { //south
- m_World->FastSetBlock( fillx, filly, fillz+1, E_BLOCK_REDSTONE_TORCH_ON, m_World->GetBlockMeta( fillx, filly, fillz+1) );
+ //m_World->FastSetBlock( fillx, filly, fillz+1, E_BLOCK_REDSTONE_TORCH_ON, m_World->GetBlockMeta( fillx, filly, fillz+1) );
m_World->m_RSList.push_back(fillx);
m_World->m_RSList.push_back(filly);
m_World->m_RSList.push_back(fillz+1);
m_World->m_RSList.push_back(11111);;
}
if ( ( (int)m_World->GetBlock( fillx, filly, fillz-1 ) == E_BLOCK_REDSTONE_TORCH_OFF) && ( (int)m_World->GetBlockMeta( fillx, filly, fillz-1) == 4 ) ) { //north
- m_World->FastSetBlock( fillx, filly, fillz-1, E_BLOCK_REDSTONE_TORCH_ON, m_World->GetBlockMeta( fillx, filly, fillz-1) );
+ //m_World->FastSetBlock( fillx, filly, fillz-1, E_BLOCK_REDSTONE_TORCH_ON, m_World->GetBlockMeta( fillx, filly, fillz-1) );
m_World->m_RSList.push_back(fillx);
m_World->m_RSList.push_back(filly);
m_World->m_RSList.push_back(fillz-1);
m_World->m_RSList.push_back(11111);
}
if ( ( (int)m_World->GetBlock( fillx, filly+1, fillz ) == E_BLOCK_REDSTONE_TORCH_OFF) && ( (int)m_World->GetBlockMeta( fillx, filly+1, fillz) == 5 ) ) { //top
- m_World->FastSetBlock( fillx, filly+1, fillz, E_BLOCK_REDSTONE_TORCH_ON, m_World->GetBlockMeta( fillx, filly+1, fillz) );
+ //m_World->FastSetBlock( fillx, filly+1, fillz, E_BLOCK_REDSTONE_TORCH_ON, m_World->GetBlockMeta( fillx, filly+1, fillz) );
m_World->m_RSList.push_back(fillx);
m_World->m_RSList.push_back(filly+1);
m_World->m_RSList.push_back(fillz);
@@ -301,6 +326,8 @@ void cRedstone::CalculatetRedstone( int fillx, int filly, int fillz)
}
+ }
+
}
}