diff --git a/ClassicalSharp/Events/WorldEvents.cs b/ClassicalSharp/Events/WorldEvents.cs index 07989fb6c..5da8ed7f8 100644 --- a/ClassicalSharp/Events/WorldEvents.cs +++ b/ClassicalSharp/Events/WorldEvents.cs @@ -54,6 +54,6 @@ namespace ClassicalSharp.Events { WeatherSpeed, WeatherFade, ExpFog, - SidesLevel, + SidesOffset, } } diff --git a/ClassicalSharp/Map/World.cs b/ClassicalSharp/Map/World.cs index 166782db7..fc72a157d 100644 --- a/ClassicalSharp/Map/World.cs +++ b/ClassicalSharp/Map/World.cs @@ -60,7 +60,6 @@ namespace ClassicalSharp.Map { throw new InvalidOperationException("Blocks array length does not match volume of map."); if (Env.EdgeHeight == -1) Env.EdgeHeight = height / 2; - if (Env.SidesHeight == -1) Env.SidesHeight = Env.EdgeHeight - 2; if (Env.CloudHeight == -1) Env.CloudHeight = height + 2; } diff --git a/ClassicalSharp/Map/WorldEnv.cs b/ClassicalSharp/Map/WorldEnv.cs index 3b1c8615a..3937b8316 100644 --- a/ClassicalSharp/Map/WorldEnv.cs +++ b/ClassicalSharp/Map/WorldEnv.cs @@ -64,7 +64,10 @@ namespace ClassicalSharp.Map { public BlockID SidesBlock = Block.Bedrock; /// Maximum height of the various parts of the map sides, in world space. - public int SidesHeight; + public int SidesHeight { get { return EdgeHeight + SidesOffset; } } + + /// Offset of height of map sides from height of map edge. + public int SidesOffset = -2; /// Whether exponential fog mode is used by default. public bool ExpFog; @@ -77,7 +80,7 @@ namespace ClassicalSharp.Map { /// Resets all of the environment properties to their defaults. public void Reset() { - EdgeHeight = -1; SidesHeight = -1; CloudHeight = -1; + EdgeHeight = -1; SidesOffset = -2; CloudHeight = -1; EdgeBlock = Block.StillWater; SidesBlock = Block.Bedrock; CloudsSpeed = 1; WeatherSpeed = 1; WeatherFade = 1; @@ -143,11 +146,11 @@ namespace ClassicalSharp.Map { /// Sets height of the map edges in world space, and raises /// EnvVariableChanged event with variable 'EdgeLevel'. - public void SetEdgeLevel(int level) { SidesHeight = level - 2; Set(level, ref EdgeHeight, EnvVar.EdgeLevel); } + public void SetEdgeLevel(int level) { Set(level, ref EdgeHeight, EnvVar.EdgeLevel); } - /// Sets height of the map sides in world space, and raises + /// Sets offset of the height of the map sides from map edges in world space, and raises /// EnvVariableChanged event with variable 'SidesLevel'. - public void SetSidesLevel(int level) { Set(level, ref SidesHeight, EnvVar.SidesLevel); } + public void SetSidesOffset(int level) { Set(level, ref SidesOffset, EnvVar.SidesOffset); } /// Sets whether exponential fog is used, and raises /// EnvVariableChanged event with variable 'ExpFog'. diff --git a/ClassicalSharp/Network/Protocols/CPE.cs b/ClassicalSharp/Network/Protocols/CPE.cs index 0cc8c31af..921004347 100644 --- a/ClassicalSharp/Network/Protocols/CPE.cs +++ b/ClassicalSharp/Network/Protocols/CPE.cs @@ -360,7 +360,7 @@ namespace ClassicalSharp.Network.Protocols { case 8: env.SetExpFog(value != 0); break; case 9: - env.SetSidesLevel(value); break; + env.SetSidesOffset(value); break; } } diff --git a/ClassicalSharp/Rendering/ChunkUpdater.cs b/ClassicalSharp/Rendering/ChunkUpdater.cs index c31bc64eb..9977f1d53 100644 --- a/ClassicalSharp/Rendering/ChunkUpdater.cs +++ b/ClassicalSharp/Rendering/ChunkUpdater.cs @@ -89,7 +89,7 @@ namespace ClassicalSharp.Renderers { void EnvVariableChanged(object sender, EnvVarEventArgs e) { if (e.Var == EnvVar.SunlightColour || e.Var == EnvVar.ShadowlightColour) { Refresh(); - } else if (e.Var == EnvVar.EdgeLevel || e.Var == EnvVar.SidesLevel) { + } else if (e.Var == EnvVar.EdgeLevel || e.Var == EnvVar.SidesOffset) { int oldClip = builder.edgeLevel; builder.sidesLevel = Math.Max(0, game.World.Env.SidesHeight); builder.edgeLevel = Math.Max(0, game.World.Env.EdgeHeight); diff --git a/ClassicalSharp/Rendering/Env/MapBordersRenderer.cs b/ClassicalSharp/Rendering/Env/MapBordersRenderer.cs index 28df10409..cc0427ae2 100644 --- a/ClassicalSharp/Rendering/Env/MapBordersRenderer.cs +++ b/ClassicalSharp/Rendering/Env/MapBordersRenderer.cs @@ -114,7 +114,7 @@ namespace ClassicalSharp.Renderers { MakeTexture(ref sideTexId, ref lastSideTexLoc, map.Env.SidesBlock); if (game.BlockInfo.BlocksLight[map.Env.SidesBlock] != fullColSides) ResetSidesAndEdges(null, null); - } else if (e.Var == EnvVar.EdgeLevel || e.Var == EnvVar.SidesLevel) { + } else if (e.Var == EnvVar.EdgeLevel || e.Var == EnvVar.SidesOffset) { ResetSidesAndEdges(null, null); } else if (e.Var == EnvVar.SunlightColour) { ResetEdges();