summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-07 13:57:51 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-07 13:57:51 +0200
commitc0a73ef89d13841fa98b8541ea801cfaa817eb35 (patch)
treecfa795d9082cae65d8a03758e753cea8c1ad41fc
parentGrass grows under vines (diff)
downloadcuberite-c0a73ef89d13841fa98b8541ea801cfaa817eb35.tar
cuberite-c0a73ef89d13841fa98b8541ea801cfaa817eb35.tar.gz
cuberite-c0a73ef89d13841fa98b8541ea801cfaa817eb35.tar.bz2
cuberite-c0a73ef89d13841fa98b8541ea801cfaa817eb35.tar.lz
cuberite-c0a73ef89d13841fa98b8541ea801cfaa817eb35.tar.xz
cuberite-c0a73ef89d13841fa98b8541ea801cfaa817eb35.tar.zst
cuberite-c0a73ef89d13841fa98b8541ea801cfaa817eb35.zip
-rw-r--r--source/LightingThread.h2
-rw-r--r--source/cChunk.cpp11
-rw-r--r--source/cChunk.h1
-rw-r--r--source/cChunkMap.cpp17
-rw-r--r--source/cChunkMap.h1
-rw-r--r--source/cClientHandle.cpp11
-rw-r--r--source/cWorld.cpp9
-rw-r--r--source/cWorld.h1
8 files changed, 49 insertions, 4 deletions
diff --git a/source/LightingThread.h b/source/LightingThread.h
index 0f8b59441..b1ff0d33f 100644
--- a/source/LightingThread.h
+++ b/source/LightingThread.h
@@ -157,7 +157,7 @@ protected:
{
if (a_Light[a_SrcIdx] <= a_Light[a_DstIdx] + g_BlockSpreadLightFalloff[m_BlockTypes[a_DstIdx]])
{
- // The dest block already has enough light than we're offerring
+ // We're not offering more light than the dest block already has
return;
}
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index 4eaa9d864..0cdebc503 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -1398,6 +1398,17 @@ BLOCKTYPE cChunk::GetBlock( int a_BlockIdx )
+void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
+{
+ int Idx = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ);
+ a_BlockType = cChunkDef::GetBlock (m_BlockTypes, a_RelX, a_RelY, a_RelZ);
+ a_BlockMeta = cChunkDef::GetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ);
+}
+
+
+
+
+
/*
// _X 2012_02_23: Loading in old format not supported anymore
/// Loads the chunk from the old-format disk file, erases the file afterwards. Returns true if successful
diff --git a/source/cChunk.h b/source/cChunk.h
index efd697b63..415205b33 100644
--- a/source/cChunk.h
+++ b/source/cChunk.h
@@ -122,6 +122,7 @@ public:
void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta ); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc.
BLOCKTYPE GetBlock( int a_X, int a_Y, int a_Z );
BLOCKTYPE GetBlock( int a_BlockIdx );
+ void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
EMCSBiome GetBiomeAt(int a_RelX, int a_RelZ) const {return cChunkDef::GetBiome(m_BiomeMap, a_RelX, a_RelZ); }
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
index 93bc8ded0..1db55485b 100644
--- a/source/cChunkMap.cpp
+++ b/source/cChunkMap.cpp
@@ -642,6 +642,23 @@ void cChunkMap::SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_B
+void cChunkMap::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
+{
+ int ChunkX, ChunkZ, X = a_BlockX, Y = a_BlockY, Z = a_BlockZ;
+ cChunkDef::AbsoluteToRelative( X, Y, Z, ChunkX, ChunkZ );
+
+ cCSLock Lock(m_CSLayers);
+ cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ );
+ if ((Chunk != NULL) && Chunk->IsValid())
+ {
+ Chunk->GetBlockTypeMeta(X, Y, Z, a_BlockType, a_BlockMeta);
+ }
+}
+
+
+
+
+
void cChunkMap::ReplaceBlocks(const sSetBlockVector & a_Blocks, BLOCKTYPE a_FilterBlockType)
{
cCSLock Lock(m_CSLayers);
diff --git a/source/cChunkMap.h b/source/cChunkMap.h
index f8155d5ae..659e5c17b 100644
--- a/source/cChunkMap.h
+++ b/source/cChunkMap.h
@@ -92,6 +92,7 @@ public:
BLOCKTYPE GetBlockSkyLight (int a_X, int a_Y, int a_Z);
void SetBlockMeta (int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockMeta);
void SetBlock (int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta);
+ void GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
/// Replaces world blocks with a_Blocks, if they are of type a_FilterBlockType
void ReplaceBlocks(const sSetBlockVector & a_Blocks, BLOCKTYPE a_FilterBlockType);
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 966270321..96ee3fcbd 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -939,14 +939,19 @@ void cClientHandle::HandleBlockPlace(cPacket_BlockPlace * a_Packet)
if (a_Packet->m_Direction >= 0)
{
- ENUM_BLOCK_ID BlockID = (ENUM_BLOCK_ID)m_Player->GetWorld()->GetBlock(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ);
- switch (BlockID)
+ cWorld * World = m_Player->GetWorld();
+ BLOCKTYPE BlockType = 0;
+ NIBBLETYPE BlockMeta;
+ World->GetBlockTypeMeta(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ, BlockType, BlockMeta);
+ switch (BlockType)
{
case E_BLOCK_REDSTONE_REPEATER_ON:
case E_BLOCK_REDSTONE_REPEATER_OFF:
{
// no need to update redstone current with a repeater
- // TODO: Find meta value of repeater and change it to one step more.
+ // Find meta value of repeater and change it to one step more:
+ World->FastSetBlock(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ, BlockType, ((BlockMeta + 0x04) & 0x0f));
+ bPlaceBlock = false;
break;
}
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index 5cb9c5f0d..7288dc303 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -938,6 +938,15 @@ char cWorld::GetBlockSkyLight( int a_X, int a_Y, int a_Z )
+void cWorld::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, char & a_BlockType, unsigned char & a_BlockMeta)
+{
+ m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, (BLOCKTYPE &)a_BlockType, (NIBBLETYPE &)a_BlockMeta);
+}
+
+
+
+
+
void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed)
{
MTRand r1;
diff --git a/source/cWorld.h b/source/cWorld.h
index c3a521d1b..0fca98771 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -206,6 +206,7 @@ public:
void SetBlockMeta( const Vector3i & a_Pos, char a_MetaData ) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData ); } //tolua_export
char GetBlockSkyLight( int a_X, int a_Y, int a_Z ); //tolua_export
// TODO: char GetBlockActualLight(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
+ void GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, char & a_BlockType, unsigned char & a_BlockMeta); // tolua_export
/// Spawns item pickups for each item in the list. May compress pickups if too many entities:
void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0);