mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Fix being kicked by MCDzienny servers for 'out of date WoM version', fixed textures that aren't 64x32 or 64x64 crashing the client. (Thanks Cheesse)
This commit is contained in:
parent
44617d1a26
commit
f497f6b623
@ -111,15 +111,26 @@ namespace ClassicalSharp {
|
||||
if( item != null && item.Bmp != null ) {
|
||||
Bitmap bmp = item.Bmp;
|
||||
Window.Graphics.DeleteTexture( ref renderer.PlayerTextureId );
|
||||
|
||||
try {
|
||||
SkinType = Utils.GetSkinType( bmp );
|
||||
renderer.PlayerTextureId = Window.Graphics.LoadTexture( bmp );
|
||||
// Custom mob textures.
|
||||
renderer.MobTextureId = -1;
|
||||
|
||||
// Custom mob textures.
|
||||
if( Utils.IsUrl( item.Url ) && item.TimeAdded > lastModelChange ) {
|
||||
renderer.MobTextureId = renderer.PlayerTextureId;
|
||||
}
|
||||
SkinType = Utils.GetSkinType( bmp );
|
||||
} catch( NotSupportedException ) {
|
||||
string formatString = "Skin {0} has unsupported dimensions({1}, {2}), reverting to default.";
|
||||
Utils.LogWarning( formatString, SkinName, bmp.Width, bmp.Height );
|
||||
renderer.MobTextureId = -1;
|
||||
renderer.PlayerTextureId = -1;
|
||||
SkinType = Window.DefaultPlayerSkinType;
|
||||
}
|
||||
bmp.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DateTime lastModelChange = new DateTime( 1, 1, 1 );
|
||||
|
@ -347,7 +347,7 @@ namespace ClassicalSharp {
|
||||
map = null;
|
||||
gzipStream.Close();
|
||||
if( sendWomId && !sentWomId ) {
|
||||
SendChat( "/womid WoMClient-2.0.6" );
|
||||
SendChat( "/womid WoMClient-2.0.7" );
|
||||
sentWomId = true;
|
||||
}
|
||||
gzipStream = null;
|
||||
|
@ -212,13 +212,18 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
public static SkinType GetSkinType( Bitmap bmp ) {
|
||||
if( bmp.Width == 64 && bmp.Height == 32 ) {
|
||||
if( bmp.Width == bmp.Height * 2 ) {
|
||||
return SkinType.Type64x32;
|
||||
} else if( bmp.Width == 64 && bmp.Height == 64 ) {
|
||||
} else if( bmp.Width == bmp.Height ) {
|
||||
// Minecraft alex skins have this particular pixel with alpha of 0.
|
||||
if( bmp.Width >= 64 ) {
|
||||
bool isNormal = bmp.GetPixel( 54, 20 ).A >= 127;
|
||||
return isNormal ? SkinType.Type64x64 : SkinType.Type64x64Slim;
|
||||
} else {
|
||||
throw new NotSupportedException( "unsupported skin: " + bmp.Width + ", " + bmp.Height );
|
||||
return SkinType.Type64x64;
|
||||
}
|
||||
} else {
|
||||
throw new NotSupportedException( "unsupported skin dimensions: " + bmp.Width + ", " + bmp.Height );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user