コード例 #1
0
        public void ReadFlatOption()
        {
            if (!string.IsNullOrEmpty(this.FlatOptionsString))
            {
                try
                {
                    this.flatOption = new FlatOptions();
                    string[] args = this.FlatOptionsString.Split(';');
                    if (args.Length > 1)
                    {
                        this.flatOption.version = int.Parse(args[0]);

                        string[]    layerData = args[1].Split(',');//support format <2*1:0> or <minecraft:stone:1>
                        BlockLayers layers    = this.flatOption.blockLayers = new BlockLayers();
                        for (int i = 0; i < layerData.Length; ++i)
                        {
                            string[] blockData = layerData[i].Split('*');
                            if (blockData.Length == 2)
                            {
                                int        layerCount = int.Parse(blockData[0]);
                                BlockLayer layer      = new BlockLayer();
                                layer.block  = Block.Get(blockData[1]);
                                layer.height = layerCount;
                                layers.layers.Add(layer);
                            }
                            else if (blockData.Length == 1)
                            {
                                BlockLayer layer = new BlockLayer();
                                layer.block  = Block.Get(blockData[0]);
                                layer.height = 1;
                                layers.layers.Add(layer);
                            }
                            else
                            {
                                continue;
                            }
                        }

                        if (layers.layers.Count == 0)
                        {
                            Logger.Notice("FlatOptions Error");
                            this.flatOption = null;
                        }
                    }
                    else
                    {
                        Logger.Notice("FlatOptions Error");
                        this.flatOption = null;
                    }
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                    Logger.Notice("FlatOptions Error");
                    this.flatOption = null;
                }
            }
        }
コード例 #2
0
ファイル: FlatGenerator.cs プロジェクト: MineCoreDev/MineNET
        public override void GenerationBasicTerrain(Chunk chunk)
        {
            if (this.flatOption != null)
            {
                BlockLayers layers = this.flatOption.blockLayers;
                for (int i = 0; i < 16; ++i)     //X
                {
                    for (int j = 0; j < 16; ++j) //Z
                    {
                        int y = 0;
                        for (int c = 0; c < layers.layers.Count; ++c)
                        {
                            BlockLayer layer = layers.layers[c];
                            for (int k = 0; k < layer.height; ++k)//Y
                            {
                                if (World.MAX_HEIGHT == y)
                                {
                                    Logger.Warn("World MaxHeight 256");
                                    break;
                                }
                                chunk.SetBlock(i, y, j, (byte)layer.block.ID);
                                chunk.SetMetadata(i, y, j, (byte)layer.block.Damage);
                                chunk.SetBiome(i, j, BiomeIDs.Plains);
                                y++;
                            }
                        }
                    }
                }
            }
            else
            {
                SubChunk flat = new SubChunk();
                for (int i = 0; i < 16; ++i)         //X
                {
                    for (int j = 0; j < 16; ++j)     //Z
                    {
                        for (int k = 0; k < 16; ++k) //Y
                        {
                            if (k == 0)
                            {
                                flat.SetBlock(i, k, j, 7);
                            }
                            else if (k == 1 || k == 2)
                            {
                                flat.SetBlock(i, k, j, 3);
                            }
                            else if (k == 3)
                            {
                                flat.SetBlock(i, k, j, 2);
                            }
                        }
                    }
                }

                chunk.SubChunks[0] = flat;
            }
        }
コード例 #3
0
ファイル: World.cs プロジェクト: JDrocks450/KrabbyQuestEmu
 /// <summary>
 /// Gets the <see cref="LevelDataBlock"/> at the specified TilePosition in the World, if <see cref="VerifyTilePosition(int, int)"/> returns true
 /// </summary>
 /// <param name="Layer">The layer to get blocks from</param>
 /// <param name="X">The X Position</param>
 /// <param name="Y">The Y Position</param>
 /// <param name="BlockInfo">The Block data if found</param>
 /// <returns></returns>
 public bool TryGetBlockAt(BlockLayers Layer, int X, int Y, out LevelDataBlock BlockInfo)
 {
     BlockInfo = null;
     if (VerifyTilePosition(X, Y))
     {
         BlockInfo = GetBlockAt(Layer, X, Y);
         return(true);
     }
     return(false);
 }
コード例 #4
0
ファイル: BlockSoil.cs プロジェクト: bitcynth/vssurvivalmod
 private BlockLayers getBlockLayers(IWorldAccessor world)
 {
     if (world.Api.ObjectCache.ContainsKey(blockLayersCacheKey))
     {
         return(world.Api.ObjectCache[blockLayersCacheKey] as BlockLayers);
     }
     else
     {
         BlockLayers blockLayers = new BlockLayers(world, growthBlockLayer);
         world.Api.ObjectCache[blockLayersCacheKey] = blockLayers;
         return(blockLayers);
     }
 }
コード例 #5
0
ファイル: BlockSoil.cs プロジェクト: bitcynth/vssurvivalmod
        private bool isAppropriateClimateToGrow(IWorldAccessor world, BlockPos pos, AssetLocation blockCode, ClimateCondition climate)
        {
            ICoreServerAPI api       = (ICoreServerAPI)world.Api;
            int            mapheight = api.WorldManager.MapSizeY;

            BlockLayers layers = getBlockLayers(world);
            BlockLayer  bl     = layers.GetBlockLayerForNextGrowthStage(world, blockCode);

            //Check climate conditions to see whether the soil can grow to the next stage
            return(
                climate.Temperature >= bl.MinTemp && climate.Temperature <= bl.MaxTemp &&
                climate.Rainfall >= bl.MinRain && climate.Rainfall <= bl.MaxRain &&
                climate.Fertility >= bl.MinFertility && climate.Fertility <= bl.MaxFertility &&
                (float)pos.Y / mapheight <= bl.MaxY
                );
        }
コード例 #6
0
ファイル: World.cs プロジェクト: JDrocks450/KrabbyQuestEmu
 /// <summary>
 /// Gets the <see cref="LevelDataBlock"/> at the specified TilePosition in the World.
 /// </summary>
 /// <param name="Layer">The layer to get blocks from</param>
 /// <param name="X">The X Position</param>
 /// <param name="Y">The Y Position</param>
 /// <returns></returns>
 public LevelDataBlock GetBlockAt(BlockLayers Layer, int X, int Y) => (Layer == BlockLayers.Integral ? Level.IntegralData : Level.DecorationData)[Y * Level.Columns + X];