diff --git a/ClassicalSharp/2D/Screens/BlockSelectScreen.cs b/ClassicalSharp/2D/Screens/BlockSelectScreen.cs index 3c0decccd..bfc87d59d 100644 --- a/ClassicalSharp/2D/Screens/BlockSelectScreen.cs +++ b/ClassicalSharp/2D/Screens/BlockSelectScreen.cs @@ -106,7 +106,11 @@ namespace ClassicalSharp { RecreateBlockInfoTexture(); } + static string[] normalNames = null; void UpdateBlockInfoString( Block block ) { + if( normalNames == null ) + MakeNormalNames(); + int index = 0; buffer.Clear(); buffer.Append( ref index, "&f" ); @@ -114,8 +118,8 @@ namespace ClassicalSharp { buffer.Append( ref index, "TNT" ); } else { string value = game.BlockInfo.Name[(byte)block]; - if( (byte)block < BlockInfo.CpeBlocksCount ) { - SplitUppercase( value, ref index ); + if( (byte)block < BlockInfo.CpeBlocksCount && value == "Invalid" ) { + buffer.Append( ref index, normalNames[(byte)block] ); } else { buffer.Append( ref index, value ); } @@ -127,6 +131,19 @@ namespace ClassicalSharp { buffer.Append( ref index, "&f)" ); } + void MakeNormalNames() { + normalNames = new string[BlockInfo.CpeBlocksCount]; + for( int i = 0; i < normalNames.Length; i++ ) { + string origName = Enum.GetName( typeof(Block), (byte)i ); + buffer.Clear(); + + int index = 0; + SplitUppercase( origName, ref index ); + normalNames[i] = buffer.ToString(); + Console.WriteLine( buffer.ToString() ); + } + } + void SplitUppercase( string value, ref int index ) { for( int i = 0; i < value.Length; i++ ) { char c = value[i]; diff --git a/ClassicalSharp/Blocks/BlockInfo.cs b/ClassicalSharp/Blocks/BlockInfo.cs index f7f6596cd..a5ff17b56 100644 --- a/ClassicalSharp/Blocks/BlockInfo.cs +++ b/ClassicalSharp/Blocks/BlockInfo.cs @@ -64,12 +64,8 @@ namespace ClassicalSharp { SpeedMultiplier[tile] = 1; CullWithNeighbours[tile] = true; } - for( int i = 0; i < CpeBlocksCount; i++ ) { - Name[i] = Enum.GetName( typeof( Block ), (byte)i ); - } - for( int i = CpeBlocksCount; i < BlocksCount; i++ ) { - Name[i] = "Invalid"; - } + for( int block = 0; block < BlocksCount; block++ ) + Name[block] = "Invalid"; FogDensity[(byte)Block.StillWater] = 0.1f; FogColour[(byte)Block.StillWater] = new FastColour( 5, 5, 51 ); diff --git a/ClassicalSharp/ClassicalSharp.csproj b/ClassicalSharp/ClassicalSharp.csproj index edf094f02..ecb063d20 100644 --- a/ClassicalSharp/ClassicalSharp.csproj +++ b/ClassicalSharp/ClassicalSharp.csproj @@ -35,6 +35,7 @@ DEBUG;TRACE; Project obj\ + wwwf ff 127.0.0.1 25565 ..\output\release\ diff --git a/ClassicalSharp/Generator/NotchyGenerator.cs b/ClassicalSharp/Generator/NotchyGenerator.cs index 0980fd7bd..c601d1bec 100644 --- a/ClassicalSharp/Generator/NotchyGenerator.cs +++ b/ClassicalSharp/Generator/NotchyGenerator.cs @@ -287,10 +287,9 @@ namespace ClassicalSharp.Generator { } } - bool CanGrowTree( int treeX, int treeY, int treeZ, int height ) { - return true; + bool CanGrowTree( int treeX, int treeY, int treeZ, int treeHeight ) { // check tree base - int baseHeight = height - 4; + int baseHeight = treeHeight - 4; for( int y = treeY; y < treeY + baseHeight; y++ ) for( int z = treeZ - 1; z <= treeZ + 1; z++ ) for( int x = treeX - 1; x <= treeX + 1; x++ ) @@ -298,18 +297,18 @@ namespace ClassicalSharp.Generator { if( x < 0 || y < 0 || z < 0 || x >= width || y >= height || z >= length ) return false; int index = (y * length + z) * width + x; - //if( blocks[index] != 0 ) return false; + if( blocks[index] != 0 ) return false; } // and also check canopy - for( int y = treeY + baseHeight; y < treeY + height; y++ ) + for( int y = treeY + baseHeight; y < treeY + treeHeight; y++ ) for( int z = treeZ - 2; z <= treeZ + 2; z++ ) for( int x = treeX - 2; x <= treeX + 2; x++ ) { if( x < 0 || y < 0 || z < 0 || x >= width || y >= height || z >= length ) return false; int index = (y * length + z) * width + x; - //if( blocks[index] != 0 ) return false; + if( blocks[index] != 0 ) return false; } return true; } @@ -325,7 +324,7 @@ namespace ClassicalSharp.Generator { { int x = xx + treeX, z = zz + treeZ; index = (y * length + z) * width + x; - if( !Check( x, y, z ) ) continue; // TODO: get rid of these once CanGrowTree is fixed. + if( Math.Abs( xx ) == 2 && Math.Abs( zz ) == 2 ) { if( rnd.NextDouble() >= 0.5 ) blocks[index] = (byte)Block.Leaves; @@ -342,7 +341,7 @@ namespace ClassicalSharp.Generator { { int x = xx + treeX, z = zz + treeZ; index = (y * length + z) * width + x; - if( !Check( x, y, z ) ) continue; + if( xx == 0 || zz == 0 ) { blocks[index] = (byte)Block.Leaves; } else if( y == bottomY && rnd.NextDouble() >= 0.5 ) { @@ -353,15 +352,9 @@ namespace ClassicalSharp.Generator { // then place trunk index = (treeY * length + treeZ ) * width + treeX; for( int y = 0; y < height - 1; y++ ) { - if( !Check( treeX, treeY + y, treeZ ) ) continue; blocks[index] = (byte)Block.Wood; index += oneY; } } - - bool Check( int x, int y, int z ) { - return x >= 0 && y >= 0 && z >= 0 - && x < width && y < height && z < length; - } } } \ No newline at end of file diff --git a/ClassicalSharp/Network/NetworkProcessor.CPE.cs b/ClassicalSharp/Network/NetworkProcessor.CPE.cs index c76e122fd..d3fe8f4f7 100644 --- a/ClassicalSharp/Network/NetworkProcessor.CPE.cs +++ b/ClassicalSharp/Network/NetworkProcessor.CPE.cs @@ -393,8 +393,10 @@ namespace ClassicalSharp { byte shape = reader.ReadUInt8(); if( shape == 2 ) { info.Height[block] = 8/16f; + info.MaxBB[block].Y = 8/16f; } else if( shape == 3 ) { info.Height[block] = 2/16f; + info.MaxBB[block].Y = 2/16f; } else if( shape == 4 ) { info.IsSprite[block] = true; }