diff --git a/MCGalaxy/Commands/CPE/CmdEnvironment.cs b/MCGalaxy/Commands/CPE/CmdEnvironment.cs index 010d2578e..a6071a229 100644 --- a/MCGalaxy/Commands/CPE/CmdEnvironment.cs +++ b/MCGalaxy/Commands/CPE/CmdEnvironment.cs @@ -18,6 +18,7 @@ using System; using System.IO; using MCGalaxy.Commands.Building; +using MCGalaxy.Network; namespace MCGalaxy.Commands.CPE { public sealed class CmdEnvironment : Command { @@ -90,6 +91,12 @@ namespace MCGalaxy.Commands.CPE { } else if (opt == "expfog") { LevelEnv.SetBool(p, value, EnvProp.ExpFog, "exp fog", false, ref lvl.Config.ExpFog); + } else if (opt == "skyboxhorspeed" || opt == "skyboxhor") { + LevelEnv.SetFloat(p, value, EnvProp.SkyboxHorSpeed, 1024, "skybox horizontal speed", + 0, ref lvl.Config.SkyboxHorSpeed, -32767, 32767); + } else if (opt == "skyboxverspeed" || opt == "skyboxver") { + LevelEnv.SetFloat(p, value, EnvProp.SkyboxVerSpeed, 1024, "skybox vertical speed", + 0, ref lvl.Config.SkyboxVerSpeed, -32767, 32767); } else { return false; } @@ -99,20 +106,32 @@ namespace MCGalaxy.Commands.CPE { static void ResetEnv(Player p) { Level lvl = p.level; + LevelConfig cfg = lvl.Config; SetPreset(p, "normal"); - LevelEnv.SetWeather(p, lvl, "normal"); - - LevelEnv.SetBlock(p, "normal", EnvProp.EdgeBlock, - "edge block", Block.Water, ref lvl.Config.HorizonBlock); - LevelEnv.SetBlock(p, "normal", EnvProp.SidesBlock, - "sides block", Block.Bedrock, ref lvl.Config.EdgeBlock); - - LevelEnv.SetShort(p, "normal", EnvProp.EdgeLevel, - "water level", (short)(lvl.Height / 2), ref lvl.Config.EdgeLevel); - LevelEnv.SetShort(p, "normal", EnvProp.SidesOffset, - "bedrock offset", -2, ref lvl.Config.SidesOffset); - LevelEnv.SetShort(p, "normal", EnvProp.CloudsLevel, - "clouds height", (short)(lvl.Height + 2), ref lvl.Config.CloudsHeight); + cfg.Weather = 0; + cfg.CloudsHeight = (short)(lvl.Height + 2); + cfg.EdgeLevel = (short)(lvl.Height / 2); + cfg.SidesOffset = -2; + cfg.MaxFogDistance = 0; + cfg.CloudsSpeed = 256; + cfg.WeatherSpeed = 256; + cfg.WeatherFade = 128; + cfg.EdgeBlock = Block.Bedrock; + cfg.HorizonBlock = Block.Water; + cfg.ExpFog = false; + cfg.SkyboxHorSpeed = 0; + cfg.SkyboxVerSpeed = 0; + + Player[] players = PlayerInfo.Online.Items; + foreach (Player pl in players) { + if (pl.level != lvl) continue; + pl.SendCurrentMapAppearance(); + + if (pl.Supports(CpeExt.EnvWeatherType)) { + pl.Send(Packet.EnvWeatherType(0)); + } + } + Level.SaveSettings(lvl); } static bool SetPreset(Player p, string value) { @@ -181,9 +200,10 @@ namespace MCGalaxy.Commands.CPE { public override void Help(Player p) { Player.Message(p, "%T/Environment [variable] [value]"); - Player.Message(p, "%HVariables: fog, cloud, sky, sun, shadow, weather, level"); - Player.Message(p, "%H horizon, border, preset, maxfog, cloudsheight"); - Player.Message(p, "%H cloudspeed, weatherspeed, weatherfade, expfog, sidesoffset"); + Player.Message(p, "%HVariables: fog, cloud, sky, sun, shadow, weather, level,"); + Player.Message(p, "%H horizon, border, preset, maxfog, cloudsheight, cloudspeed,"); + Player.Message(p, "%H weatherspeed, weatherfade, expfog, sidesoffset,"); + Player.Message(p, "%H skyboxhorspeed, skyboxverspeed"); Player.Message(p, "%HUsing 'normal' as a value will reset the variable"); Player.Message(p, "%T/Environment normal %H- resets all variables"); } diff --git a/MCGalaxy/Levels/LevelConfig.cs b/MCGalaxy/Levels/LevelConfig.cs index 70dc2020d..ebd144146 100644 --- a/MCGalaxy/Levels/LevelConfig.cs +++ b/MCGalaxy/Levels/LevelConfig.cs @@ -94,6 +94,13 @@ namespace MCGalaxy { /// Weather fade, in units of 256ths. Default is 256 (1 speed). [ConfigInt("weather-fade", "Env", 128, short.MinValue, short.MaxValue)] public int WeatherFade = 128; + /// Skybox horizontal speed, in units of 1024ths. Default is 0 (0 speed). + [ConfigInt("skybox-hor-speed", "Env", 0, short.MinValue, short.MaxValue)] + public int SkyboxHorSpeed = 0; + /// Skybox vertical speed, in units of 1024ths. Default is 0 (0 speed). + [ConfigInt("skybox-ver-speed", "Env", 0, short.MinValue, short.MaxValue)] + public int SkyboxVerSpeed = 0; + /// The block which will be displayed on the horizon. [ConfigByte("HorizonBlock", "Env", Block.Water)] public byte HorizonBlock = Block.Water; diff --git a/MCGalaxy/Levels/LevelEnv.cs b/MCGalaxy/Levels/LevelEnv.cs index ffa5b614f..80db5b481 100644 --- a/MCGalaxy/Levels/LevelEnv.cs +++ b/MCGalaxy/Levels/LevelEnv.cs @@ -146,11 +146,11 @@ namespace MCGalaxy { return false; } else if (value < min || value > max) { Player.Message(p, "Env: \"{0}\" must be between {1} and {2}.", - value, min.ToString("F2"), max.ToString("F2")); + value, min.ToString("F4"), max.ToString("F4")); return false; } else { modify = (int)(value * scale); - Player.Message(p, "Set {0} for {1} %Sto {2}", variable, p.level.ColoredName, value.ToString("F2")); + Player.Message(p, "Set {0} for {1} %Sto {2}", variable, p.level.ColoredName, value.ToString("F4")); return true; } } diff --git a/MCGalaxy/Player/Player.CPE.cs b/MCGalaxy/Player/Player.CPE.cs index 04d856080..92bf5e7e2 100644 --- a/MCGalaxy/Player/Player.CPE.cs +++ b/MCGalaxy/Player/Player.CPE.cs @@ -239,7 +239,7 @@ namespace MCGalaxy { SidesBlock = 0, EdgeBlock = 1, EdgeLevel = 2, CloudsLevel = 3, MaxFog = 4, CloudsSpeed = 5, WeatherSpeed = 6, WeatherFade = 7, ExpFog = 8, - SidesOffset = 9, + SidesOffset = 9, SkyboxHorSpeed = 10, SkyboxVerSpeed = 11, } public enum EntityProp : byte {