Ejemplo n.º 1
0
// Sets a block and its data. Returns true if the block was not changed.
func (chunk *Chunk) setBlock(blockLoc *BlockXyz, subLoc *SubChunkXyz, index BlockIndex, blockType BlockId, blockData byte) {

	// Invalidate cached packet.
	chunk.cachedPacket = nil

	index.SetBlockId(chunk.blocks, blockType)
	index.SetBlockData(chunk.blockData, blockData)

	chunk.blockExtra[index] = nil, false

	// Tell players that the block changed.
	packet := new(bytes.Buffer)
	proto.WriteBlockChange(packet, blockLoc, blockType, blockData)
	chunk.reqMulticastPlayers(-1, packet.Bytes())

	return
}
Ejemplo n.º 2
0
// Sets a block and its data. Returns true if the block was not changed.
func (chunk *Chunk) setBlock(blockLoc *BlockXyz, subLoc *SubChunkXyz, index BlockIndex, blockType BlockId, blockData byte) {

	// Invalidate cached packet.
	chunk.cachedPacket = nil

	// Invalidate currently stored chunk data.
	chunk.storeDirty = true

	index.SetBlockId(chunk.blocks, blockType)
	index.SetBlockData(chunk.blockData, blockData)

	delete(chunk.tileEntities, index)

	// Tell players that the block changed.
	packet := new(bytes.Buffer)
	proto.WriteBlockChange(packet, blockLoc, blockType, blockData)
	chunk.reqMulticastPlayers(-1, packet.Bytes())

	return
}