// Runs Prefab read and returns the arrays needed to create the prefab
    private void PrefabRead(bool blockBased)
    {
        if (!current.active)
        {
            return;
        }

        Debug.Log(current.RealPos());

        // If first position is not set
        if (!this.prefabSetFlag)
        {
            Debug.Log("Maked First Position");

            if (blockBased)
            {
                this.prefabPos = current.Copy();
            }
            else
            {
                this.prefabPos = lastCoord.Copy();
            }
        }

        // If this is last position to be set
        else
        {
            CastCoord finalPos;
            ChunkPos  newPos;
            string    outBlock = "{";
            string    outHp    = "{";
            string    outState = "{";

            int xCount = 0;
            int zCount = 0;

            if (blockBased)
            {
                finalPos = current.Copy();
                finalPos = finalPos.Add(1, 1, 1);
            }
            else
            {
                finalPos = lastCoord.Copy();
                finalPos = finalPos.Add(1, 1, 1);
            }

            xCount = finalPos.chunkX - prefabPos.chunkX;
            zCount = finalPos.chunkZ - prefabPos.chunkZ;


            int x, y, z;
            int xEnd, zEnd;

            for (y = prefabPos.blockY; y < finalPos.blockY; y++)
            {
                for (int xChunk = 0; xChunk <= xCount; xChunk++)
                {
                    // X Spec
                    if (xChunk == 0 && xChunk == xCount)
                    {
                        x    = prefabPos.blockX;
                        xEnd = finalPos.blockX;
                    }
                    else if (xChunk == 0 && xChunk != xCount)
                    {
                        x    = prefabPos.blockX;
                        xEnd = Chunk.chunkWidth;
                    }
                    else if (xChunk != xCount)
                    {
                        x    = 0;
                        xEnd = Chunk.chunkWidth;
                    }
                    else
                    {
                        x    = 0;
                        xEnd = finalPos.blockX;
                    }

                    for (; x < xEnd; x++)
                    {
                        for (int zChunk = 0; zChunk <= zCount; zChunk++)
                        {
                            newPos = new ChunkPos(prefabPos.chunkX + xChunk, prefabPos.chunkZ + zChunk);

                            // Z Spec
                            if (zChunk == 0 && zChunk == zCount)
                            {
                                z    = prefabPos.blockZ;
                                zEnd = finalPos.blockZ;
                            }
                            else if (zChunk == 0 && zChunk != zCount)
                            {
                                z    = prefabPos.blockZ;
                                zEnd = Chunk.chunkWidth;
                            }
                            else if (zChunk != zCount)
                            {
                                z    = 0;
                                zEnd = Chunk.chunkWidth;
                            }
                            else
                            {
                                z    = 0;
                                zEnd = finalPos.blockZ;
                            }

                            for (; z < zEnd; z++)
                            {
                                outBlock += loader.chunks[newPos].data.GetCell(x, y, z).ToString();
                                outBlock += ",";

                                if (loader.chunks[newPos].metadata.IsUnassigned(x, y, z))
                                {
                                    outHp    += "null,";
                                    outState += "null,";
                                }
                                else
                                {
                                    if (loader.chunks[newPos].metadata.IsHPNull(x, y, z))
                                    {
                                        outHp += "null,";
                                    }
                                    else
                                    {
                                        outHp += loader.chunks[newPos].metadata.GetHP(x, y, z);
                                        outHp += ",";
                                    }

                                    if (loader.chunks[newPos].metadata.IsStateNull(x, y, z))
                                    {
                                        outState += "null,";
                                    }
                                    else
                                    {
                                        outState += loader.chunks[newPos].metadata.GetState(x, y, z);
                                        outState += ",";
                                    }
                                }
                            }
                        }
                    }
                }
            }

            int sizeX, sizeZ, sizeY;

            // Calculates Struct Size
            if (xCount >= 1)
            {
                sizeX = (Chunk.chunkWidth - prefabPos.blockX) + (xCount - 1) * Chunk.chunkWidth + finalPos.blockX;
            }
            else
            {
                sizeX = finalPos.blockX - prefabPos.blockX;
            }

            if (zCount >= 1)
            {
                sizeZ = (Chunk.chunkWidth - prefabPos.blockZ) + (zCount - 1) * Chunk.chunkWidth + finalPos.blockZ;
            }
            else
            {
                sizeZ = finalPos.blockZ - prefabPos.blockZ;
            }

            sizeY = finalPos.blockY - prefabPos.blockY;

            StreamWriter file = new StreamWriter("SavedStruct.txt", append: true);

            file.WriteLine("Blocks:\n");
            file.WriteLine(outBlock + "}");
            file.WriteLine("\n\nHP:\n");
            file.WriteLine(outHp + "}");
            file.WriteLine("\n\nState:\n");
            file.WriteLine(outState + "}");
            file.WriteLine("\nSizes: " + sizeX + " | " + sizeY + " | " + sizeZ + "		["+ sizeX * sizeY * sizeZ + "]\n\n\n\n");
            file.Close();
        }
    }