예제 #1
0
        private static void loadLayers()
        {
            AlphaBlockCollection blk = null;
            int x, z, cx, cz, mx, mz, id;

            if (needSave)
            {
                saveLayers();
            }

            reg = ((AnvilRegion)
                   lvl.GetRegionManager().GetRegion(region[0], region[1]));
            mnuStatus.Text = "Loading Block Data";

            needSave = false;
            y        = mnuHeight.SelectedIndex;

            for (cx = 0; cx < cxd; cx++)
            {
                for (cz = 0; cz < czd; cz++)
                {
                    if (reg.ChunkExists(cx, cz))
                    {
                        blk = reg.GetChunkRef(cx, cz).Blocks;
                    }

                    else
                    {
                        blk = null;
                    }

                    for (x = 0; x < xd; x++)
                    {
                        for (z = 0; z < zd; z++)
                        {
                            mx = cx * xd + x;
                            mz = cz * zd + z;
                            if (blk != null)
                            {
                                id = Tools.Tool.Map[mx][mz].ID = blk.GetID(x, y, z);
                                Tools.Tool.Map[mx][mz].Data = blk.GetData(x, y, z);
                                Tools.Tool.Map[mx][mz].ent  = blk.GetTileEntity(x, y, z);
                            }

                            else
                            {
                                id = Tools.Tool.Map[mx][mz].ID = -1;
                            }
                            Tools.Tool.Clr[mx][mz] = BlockColor.getBlockColor(id);
                        }
                    }

                    mnuLoad.Increment(xd * zd);
                }
            }
            mnuLoad.Increment(-hgt * wid);

            loadImage();
        }
예제 #2
0
 // *** If there is no tile entity, Substrate can throw an exception.  This utility function just handles that gracefully
 /// <summary>
 ///     Get the tile entity for a block, without throwing an exception if none exists
 /// </summary>
 /// <remarks>
 ///     Substrate's library throws an exception if you try to retrieve a tile entity that does not exist.  This utility function handles this, swallowing the error and merely returning null instead of crashing.
 /// </remarks>
 /// <param name="Blocks">
 ///     The block collection to get the tile entity from
 /// </param>
 /// <param name="X">
 ///     The X position of the block to get the tile entity for
 /// </param>
 /// <param name="Y">
 ///     The Y position of the block to get the tile entity for
 /// </param>
 /// <param name="Z">
 ///     The Z position of the block to get the tile entity for
 /// </param>
 /// <returns>
 ///     The tile entity for the block, or <see langword="null"/>
 /// </returns>
 /// <seealso cref=" Substrate.TileEntity"/>
 public static TileEntity SafeGetTileEntity(this AlphaBlockCollection Blocks, int X, int Y, int Z)
 {
     try
     {
         return Blocks.GetTileEntity(X, Y, Z);
     }
     catch
     {
         return null;
     }
 }
예제 #3
0
 public static TileEntity GetTileEntity(this AlphaBlockCollection blocks, LocalBlockPosition position)
 {
     return(blocks.GetTileEntity(position.X, position.Y, position.Z));
 }