#include "BlockChangedUpdate.h" #include #include "Globals.h" #include "Registries.h" BlockChangedUpdateType::BlockChangedUpdateType() : WorldUpdateType( ID ) {} void BlockChangedUpdateType::applyUpdate( Framework::StreamReader* zReader ) { int dimension = 0; zReader->lese( (char*)&dimension, 4 ); Framework::Vec3 pos; zReader->lese( (char*)&pos.x, 4 ); zReader->lese( (char*)&pos.y, 4 ); zReader->lese( (char*)&pos.z, 4 ); unsigned short id; zReader->lese( (char*)&id, 2 ); if( id ) { bool d = 1; zReader->lese( (char*)&d, 1 ); Block* b = currentGame->zBlockAt( pos, dimension ); if( !d ) { if( !b || b->zBlockType()->getId() != id ) { if( STATIC_REGISTRY( BlockType ).zElement( id )->needsInstance() ) { b = STATIC_REGISTRY( BlockType ).zElement( id )->createBlock( pos ); currentGame->zDimension( dimension )->setBlock( b ); } else if( b ) currentGame->zDimension( dimension )->removeBlock( b ); } } else { if( b ) STATIC_REGISTRY( BlockType ).zElement( id )->updateBlock( b, zReader ); else { b = STATIC_REGISTRY( BlockType ).zElement( id )->createBlock( pos ); STATIC_REGISTRY( BlockType ).zElement( id )->updateBlock( b, zReader ); currentGame->zDimension( dimension )->setBlock( b ); } } } }