Browse Source

fixed block positioning bug

Kolja Strohm 3 years ago
parent
commit
210ca76960
2 changed files with 3 additions and 3 deletions
  1. 1 1
      FactoryCraft/BlockChangedUpdate.cpp
  2. 2 2
      FactoryCraft/Chunk.cpp

+ 1 - 1
FactoryCraft/BlockChangedUpdate.cpp

@@ -25,7 +25,7 @@ void BlockChangedUpdate::write( Framework::StreamWriter* zWriter )
     zWriter->schreibe( (char*)&pos.x, 4 );
     zWriter->schreibe( (char*)&pos.y, 4 );
     zWriter->schreibe( (char*)&pos.z, 4 );
-    auto b = Game::INSTANCE->zBlockAt( getMinAffectedPoint(), getAffectedDimension() );
+    auto b = Game::INSTANCE->zBlockAt( pos, getAffectedDimension() );
     unsigned short blockType = b.isA() ? (unsigned short)b.getA()->zBlockType()->getId() : (unsigned short)b.getB();
     zWriter->schreibe( (char*)&blockType, 2 );
     if( b.isA() )

+ 2 - 2
FactoryCraft/Chunk.cpp

@@ -86,7 +86,7 @@ void Chunk::instantiateBlock( Framework::Vec3<int> location )
         generateBlock( location );
     b = zBlockAt( location );
     if( b.isB() )
-        putBlockAt( location, StaticRegistry<BlockType>::INSTANCE.zElement( b.getB() )->createBlockAt( location, 0 ) );
+        putBlockAt( location, StaticRegistry<BlockType>::INSTANCE.zElement( b.getB() )->createBlockAt( { location.x + this->location.x - CHUNK_SIZE / 2, location.y + this->location.y - CHUNK_SIZE / 2, location.z }, 0 ) );
 }
 
 void Chunk::generateBlock( Framework::Vec3<int> location )
@@ -94,7 +94,7 @@ void Chunk::generateBlock( Framework::Vec3<int> location )
     int index = (location.x * CHUNK_SIZE + location.y) * WORLD_HEIGHT + location.z;
     if( blockIds[ index ] )
         return;
-    auto generated = Game::INSTANCE->zGenerator()->generateSingleBlock( location, dimensionId );
+    auto generated = Game::INSTANCE->zGenerator()->generateSingleBlock( { location.x + this->location.x - CHUNK_SIZE / 2, location.y + this->location.y - CHUNK_SIZE / 2, location.z }, dimensionId );
     if( generated.isA() )
         putBlockAt( location, generated );
     else