当前位置: 首页>>代码示例>>C#>>正文


C# Map.RemoveUnknownBlocktypes方法代码示例

本文整理汇总了C#中Map.RemoveUnknownBlocktypes方法的典型用法代码示例。如果您正苦于以下问题:C# Map.RemoveUnknownBlocktypes方法的具体用法?C# Map.RemoveUnknownBlocktypes怎么用?C# Map.RemoveUnknownBlocktypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Map的用法示例。


在下文中一共展示了Map.RemoveUnknownBlocktypes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

        public Map Load( [NotNull] string fileName )
        {
            if( fileName == null ) throw new ArgumentNullException( "fileName" );
            using( FileStream mapStream = File.OpenRead( fileName ) ) {
                GZipStream gs = new GZipStream( mapStream, CompressionMode.Decompress, true );
                NBTag tag = NBTag.ReadStream( gs );

                NBTag mapTag = tag["Map"];
                // ReSharper disable UseObjectOrCollectionInitializer
                Map map = new Map( null,
                                   mapTag["Width"].GetShort(),
                                   mapTag["Length"].GetShort(),
                                   mapTag["Height"].GetShort(),
                                   false );
                map.Spawn = new Position {
                    X = mapTag["Spawn"][0].GetShort(),
                    Z = mapTag["Spawn"][1].GetShort(),
                    Y = mapTag["Spawn"][2].GetShort(),
                    R = 0,
                    L = 0
                };
                // ReSharper restore UseObjectOrCollectionInitializer

                if( !map.ValidateHeader() ) {
                    throw new MapFormatException( "One or more of the map dimensions are invalid." );
                }

                map.Blocks = mapTag["Blocks"].GetBytes();
                map.RemoveUnknownBlocktypes();

                return map;
            }
        }
开发者ID:GMathioud,项目名称:MyCraft,代码行数:33,代码来源:MapNBT.cs

示例2: Load

        public Map Load( string fileName ) {
            if( fileName == null ) throw new ArgumentNullException( "fileName" );
            NbtFile file = new NbtFile( fileName );
            if( file.RootTag == null ) throw new MapFormatException( "No root tag" );

            NbtCompound mapTag = file.RootTag.Get<NbtCompound>( "Map" );
            if( mapTag == null ) throw new MapFormatException( "No Map tag" );

            // ReSharper disable UseObjectOrCollectionInitializer
            Map map = new Map( null,
                               mapTag["Width"].ShortValue,
                               mapTag["Length"].ShortValue,
                               mapTag["Height"].ShortValue,
                               false );
            map.Spawn = new Position {
                X = mapTag["Spawn"][0].ShortValue,
                Z = mapTag["Spawn"][1].ShortValue,
                Y = mapTag["Spawn"][2].ShortValue
            };
            // ReSharper restore UseObjectOrCollectionInitializer

            map.Blocks = mapTag["Blocks"].ByteArrayValue;
            map.RemoveUnknownBlocktypes();

            return map;
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:26,代码来源:MapIndev.cs

示例3: Load

        public Map Load( string fileName ) {
            using( FileStream mapStream = File.OpenRead( fileName ) ) {
                GZipStream gs = new GZipStream( mapStream, CompressionMode.Decompress, true );
                NBTag tag = NBTag.ReadStream( gs );


                NBTag mapTag = tag["Map"];
                Map map = new Map( null,
                                   mapTag["Width"].GetShort(),
                                   mapTag["Length"].GetShort(),
                                   mapTag["Height"].GetShort(),
                                   false );
                map.Spawn = new Position {
                    X = mapTag["Spawn"][0].GetShort(),
                    H = mapTag["Spawn"][1].GetShort(),
                    Y = mapTag["Spawn"][2].GetShort(),
                    R = 0,
                    L = 0
                };

                if( !map.ValidateHeader() ) {
                    throw new MapFormatException( "One or more of the map dimensions are invalid." );
                }

                map.Blocks = mapTag["Blocks"].GetBytes();
                map.RemoveUnknownBlocktypes( false );

                return map;
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:30,代码来源:MapNBT.cs

示例4: Load

        public Map Load( string fileName ) {
            if( fileName == null ) throw new ArgumentNullException( "fileName" );
            using( FileStream mapStream = File.OpenRead( fileName ) ) {
                GZipStream gs = new GZipStream( mapStream, CompressionMode.Decompress, true );
                NBTag tag = NBTag.ReadStream( gs );

                NBTag mapTag = tag["Map"];
                // ReSharper disable UseObjectOrCollectionInitializer
                Map map = new Map( null,
                                   mapTag["Width"].GetShort(),
                                   mapTag["Length"].GetShort(),
                                   mapTag["Height"].GetShort(),
                                   false );
                // ReSharper restore UseObjectOrCollectionInitializer
                map.Spawn = new Position( mapTag["Spawn"][0].GetShort(),
                                          mapTag["Spawn"][2].GetShort(),
                                          mapTag["Spawn"][1].GetShort() );

                map.Blocks = mapTag["Blocks"].GetBytes();
                map.RemoveUnknownBlocktypes();

                return map;
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:24,代码来源:MapIndev.cs

示例5: LoadBlocks

        static void LoadBlocks( Map map, Stream mapStream ) {
            mapStream.Seek( 0, SeekOrigin.Begin );

            // Setup a GZipStream to decompress and read the map file
            GZipStream gs = new GZipStream( mapStream, CompressionMode.Decompress, true );
            BinaryReader bs = new BinaryReader( gs );

            int blockCount = IPAddress.HostToNetworkOrder( bs.ReadInt32() );
            if( blockCount != map.WidthY * map.WidthX * map.Height ) {
                throw new Exception( "Map dimensions in the metadata do not match dimensions of the block array." );
            }

            map.Blocks = new byte[blockCount];
            bs.Read( map.Blocks, 0, map.Blocks.Length );
            map.RemoveUnknownBlocktypes( false );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:16,代码来源:MapMyne.cs

示例6: ReadLayer

        static void ReadLayer( DataLayer layer, DeflateStream stream, Map map ) {
            if( layer == null ) throw new ArgumentNullException( "layer" );
            if( stream == null ) throw new ArgumentNullException( "stream" );
            switch( layer.Type ) {
                case DataLayerType.Blocks:
                    map.Blocks = new byte[layer.ElementCount];
                    stream.Read( map.Blocks, 0, map.Blocks.Length );
                    map.RemoveUnknownBlocktypes( false );
                    break;

                default:
                    Logger.Log( "Map.ReadLayer: Skipping unknown layer ({0})", LogType.Warning, layer.Type );
                    stream.BaseStream.Seek( layer.CompressedLength, SeekOrigin.Current );
                    break;
            }
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:16,代码来源:MapFCMv3.cs


注:本文中的Map.RemoveUnknownBlocktypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。