Exemplo n.º 1
0
	void ColumnContainer::SetBlock (BlockID id, Block block) {
	
		//	Get offset within this column
		auto offset=id.GetOffset();
		
		//	Prepare a packet
		Packets::Play::Clientbound::BlockChange packet;
		packet.X=id.X;
		packet.Y=id.Y;
		packet.Z=id.Z;
		packet.Type=block.GetType();
		packet.Metadata=block.GetMetadata();
		
		lock.Execute([&] () {
		
			//	Assign block
			Blocks[offset]=block;
			
			//	Now dirty
			dirty=true;
			
			//	If we've sent this column to players,
			//	send a packet
			if (sent) for (auto & client : clients) const_cast<SmartPointer<Client> &>(client)->Send(packet);
		
		});
	
	}
Exemplo n.º 2
0
	static Byte get_add (const Block & b) noexcept {
	
		auto type=b.GetType();
		
		return (type>std::numeric_limits<Byte>::max()) ? 0 : static_cast<Byte>(type>>BitsPerByte());
	
	}
Exemplo n.º 3
0
ParamBlock* Block::GetParam(E_BlockType t, const char* name)
{
	for (size_t i = 0; i < m_childParams.size(); ++i)
	{
		Block* child = m_childParams[i];
		if (child->GetType() == t && child->GetName() == name)
			return (ParamBlock*)child;
	}
	
	return NULL;
}
Exemplo n.º 4
0
//When a config or param is specified, then not only will this include content specific to that platform or config, but also all generic platform or config data
void Block::GetParams(ParamVector* result, E_BlockType t, const char* platformName, const char* configName, bool recurseChildParams) const
{
	std::vector<Block*> childrenToProcess;
	
	for (size_t i = 0; i < m_childParams.size(); ++i)
	{
		Block* child = m_childParams[i];
				
		E_BlockType childType = child->GetType();
		
		if (t != E_BlockType_Unknown && childType != t)
			continue;
		
		if (childType == E_BlockType_PlatformParam)
		{
			if (platformName)
			{
				//If we've specified that we want to include only the given platform, and the name of this platform
				//block does not match this then skip this node.
				if (child->GetName() != platformName)
					continue;
			}
			else
			{
				//Specifying null indicates we want all blocks. To exclude platform specific blocks, pass in "" as the platform
			}
		}

		if (childType == E_BlockType_ConfigParam)
		{
			if (configName)
			{
				//If we've specified that we want to include only the given config, and the name of this config
				//block does not match this then skip this node.
				if (child->GetName() != configName)
					continue;
			}
			else
			{
				//Specifying null indicates we want all blocks. To exclude config specific blocks, pass in "" as the config
			}
		}
		
		if (platformName)
		{
			const char* childPlatform = child->GetParentPlatform();
			assert(!childPlatform || strcmp(platformName, childPlatform) == 0);
		}
		if (configName)
		{
			const char* childConfig = child->GetParentConfig();
			assert(!childConfig || strcmp(configName, childConfig) == 0);
		}

		childrenToProcess.push_back(child);
		result->push_back((ParamBlock*)child);
	}
	
	if (recurseChildParams)
	{
		for (size_t i = 0; i < childrenToProcess.size(); ++i)
		{
			Block* child = childrenToProcess[i];
			child->GetParams(result, t, platformName, configName, recurseChildParams);
		}
	}
}