private void PullTransparencyCacheFromAdjacentBlock(ChunkSubspacePosition position, int xOffset, int yOffset, int zOffset) { ChunkSubspacePosition checkPosition; checkPosition = position; checkPosition.x += xOffset; checkPosition.y += yOffset; checkPosition.z += zOffset; if (checkPosition.x >= 0 && checkPosition.x < SIZE && checkPosition.y >= 0 && checkPosition.y < SIZE && checkPosition.z >= 0 && checkPosition.z < SIZE) { SetAdjacentBlockTransparentFlag(position, xOffset, yOffset, zOffset, GetBlock(checkPosition).IsTransparent()); } else { BlockSpacePosition blockPosition = checkPosition.GetBlockSpacePosition(this); Chunk otherChunk = ChunkRepository.GetChunkAtPosition(blockPosition); if (otherChunk != null) { ChunkSubspacePosition otherChunkPosition = blockPosition.GetChunkSubspacePosition(otherChunk); SetAdjacentBlockTransparentFlag(position, xOffset, yOffset, zOffset, otherChunk.GetBlock(otherChunkPosition).IsTransparent()); } } }
private void PushTransparencyCacheToAdjacentBlock(ChunkSubspacePosition position, int xOffset, int yOffset, int zOffset, bool transparent) { position.x += xOffset; position.y += yOffset; position.z += zOffset; if (position.x >= 0 && position.x < SIZE && position.y >= 0 && position.y < SIZE && position.z >= 0 && position.z < SIZE) { SetAdjacentBlockTransparentFlag(position, -xOffset, -yOffset, -zOffset, transparent); } else { BlockSpacePosition blockPosition = position.GetBlockSpacePosition(this); Chunk otherChunk = ChunkRepository.GetChunkAtPosition(blockPosition); if (otherChunk != null) { ChunkSubspacePosition otherChunkPosition = blockPosition.GetChunkSubspacePosition(otherChunk); otherChunk.SetAdjacentBlockTransparentFlag(otherChunkPosition, -xOffset, -yOffset, -zOffset, transparent); } } }
public void RemoveBlockAtPosition(BlockSpacePosition position, RemoveBlockCallback callback) { ChunkSubspacePosition subspacePosition = position.GetChunkSubspacePosition(this); if (subspacePosition.x < 0 || subspacePosition.y < 0 || subspacePosition.z < 0 || subspacePosition.x >= SIZE || subspacePosition.y >= SIZE || subspacePosition.z >= SIZE) { return; } Block block = GetBlock(subspacePosition); if (block.IsBedrock()) { // Bedrock is a special case - it can't be removed return; } if (callback != null) { callback(position, block); } SetBlock(subspacePosition, BlockType.Air, true); }
public ChunkBlockPair GetBlockAtPosition(BlockSpacePosition position, Chunk hintChunk) { if (hintChunk == null) { return(GetBlockAtPosition(position)); } ChunkSubspacePosition subspacePosition = position.GetChunkSubspacePosition(hintChunk); if (subspacePosition.x < 0 || subspacePosition.y < 0 || subspacePosition.z < 0 || subspacePosition.x >= Chunk.SIZE || subspacePosition.y >= Chunk.SIZE || subspacePosition.z >= Chunk.SIZE) { return(GetBlockAtPosition(position)); } ChunkBlockPair returnPair; returnPair.block = hintChunk.GetBlock(subspacePosition); returnPair.chunk = hintChunk; return(returnPair); }
public void SetBlockAtPosition(BlockSpacePosition position, BlockType type, bool triggerLightingUpdate) { if (type == BlockType.Air) { throw new Exception("Can not use SetBlockAtPosition to set a block to air. Rather, use " + "RemoveBlockAtPosition for this purpose."); } ChunkSubspacePosition subspacePosition = position.GetChunkSubspacePosition(this); SetBlock(subspacePosition, type, triggerLightingUpdate); }
public Block GetBlockAtPosition(BlockSpacePosition position) { ChunkSubspacePosition subspacePosition = position.GetChunkSubspacePosition(this); return(GetBlock(subspacePosition)); }