Fix .cw files saving/loading custom blocks with max fog density when fog density is supposed to be none.

This commit is contained in:
UnknownShadow200 2016-07-27 19:57:50 +10:00
parent 4ffa029fa9
commit d097af1cb0
2 changed files with 4 additions and 1 deletions

View File

@ -173,7 +173,8 @@ namespace ClassicalSharp.Map {
FastColour col = info.FogColour[id];
nbt.Write( NbtTagType.Int8Array );
nbt.Write( "Fog" ); nbt.WriteInt32( 4 );
nbt.WriteUInt8( (byte)(128 * info.FogDensity[id] - 1) );
byte fog = (byte)(128 * info.FogDensity[id] - 1);
nbt.WriteUInt8( info.FogDensity[id] == 0 ? (byte)0 : fog );
nbt.WriteUInt8( col.R ); nbt.WriteUInt8( col.G ); nbt.WriteUInt8( col.B );
Vector3 min = info.MinBB[id], max = info.MaxBB[id];

View File

@ -155,6 +155,8 @@ namespace ClassicalSharp.Map {
data = (byte[])compound["Fog"].Value;
info.FogDensity[id] = (data[0] + 1) / 128f;
// Fix for older ClassicalSharp versions which saved wrong fog density value
if( data[0] == 0xFF ) info.FogDensity[id] = 0;
info.FogColour[id] = new FastColour( data[1], data[2], data[3] );
data = (byte[])compound["Coords"].Value;