Exemple #1
0
        private static List <Block> GetBlocks(RawSchematic rawSchematic)
        {
            //Sorted by height (bottom to top) then length then width -- the index of the block at X,Y,Z is (Y×length + Z)×width + X.
            List <Block> blocks = new List <Block>();

            for (int Y = 0; Y < rawSchematic.Heigth; Y++)
            {
                for (int Z = 0; Z < rawSchematic.Length; Z++)
                {
                    for (int X = 0; X < rawSchematic.Width; X++)
                    {
                        int   index = (Y * rawSchematic.Length + Z) * rawSchematic.Width + X;
                        Block block = new Block();
                        block.BlockID = rawSchematic.Blocks[index];
                        block.Data    = rawSchematic.Data[index];
                        block.X       = X;
                        block.Y       = Y;
                        block.Z       = Z;
                        //TileEntities (Schilder, Hopper..) werden woanders geladen
                        if (block.BlockID != 0)
                        {
                            blocks.Add(block);
                        }
                    }
                }
            }
            return(blocks);
        }
Exemple #2
0
        private static Schematic LoadSchematic(NbtFile nbtFile)
        {
            RawSchematic raw       = LoadRaw(nbtFile);
            List <Block> blocks    = GetBlocks(raw);
            string       name      = Path.GetFileNameWithoutExtension(nbtFile.FileName);
            Schematic    schematic = new Schematic(name, raw.Width, raw.Heigth, raw.Length, blocks, raw.TileEntities);

            return(schematic);
        }
Exemple #3
0
        private static RawSchematic LoadRaw(NbtFile nbtFile)
        {
            RawSchematic raw     = new RawSchematic();
            var          rootTag = nbtFile.RootTag;

            foreach (NbtTag tag in rootTag.Tags)
            {
                switch (tag.Name)
                {
                case "Width":     //Short
                    raw.Width = tag.ShortValue;
                    break;

                case "Height":     //Short
                    raw.Heigth = tag.ShortValue;
                    break;

                case "Length":     //Short
                    raw.Length = tag.ShortValue;
                    break;

                case "Materials":     //String
                    raw.Materials = tag.StringValue;
                    break;

                case "Blocks":     //ByteArray
                    raw.Blocks = tag.ByteArrayValue;
                    break;

                case "Data":     //ByteArray
                    raw.Data = tag.ByteArrayValue;
                    break;

                case "Entities":     //List
                    break;           //Ignore

                case "TileEntities": //List
                    raw.TileEntities = GetTileEntities(tag);
                    break;

                case "Icon":              //Compound
                    break;                //Ignore

                case "SchematicaMapping": //Compound
                    tag.ToString();
                    break;                //Ignore

                default:
                    break;
                }
            }
            return(raw);
        }