diff --git a/ClassicalSharp/2D/IsometricBlockDrawer.cs b/ClassicalSharp/2D/IsometricBlockDrawer.cs index f8a710716..c7f2c652c 100644 --- a/ClassicalSharp/2D/IsometricBlockDrawer.cs +++ b/ClassicalSharp/2D/IsometricBlockDrawer.cs @@ -38,11 +38,12 @@ namespace ClassicalSharp { if( info.IsSprite[block] ) { minBB = Vector3.Zero; maxBB = Vector3.One; } + if( info.IsAir[block] ) return; index = 0; + // isometric coords size: cosY * -scale - sinY * scale // we need to divide by (2 * cosY), as the calling function expects size to be in pixels. - scale = size / (2 * cosY); - + scale = size / (2 * cosY); // screen to isometric coords (cos(-x) = cos(x), sin(-x) = -sin(x)) pos.X = x; pos.Y = y; pos.Z = 0; pos = Utils.RotateY( Utils.RotateX( pos, cosX, -sinX ), cosY, -sinY ); diff --git a/ClassicalSharp/2D/Screens/ChatScreen.cs b/ClassicalSharp/2D/Screens/ChatScreen.cs index cf02985e7..4fdfe78df 100644 --- a/ClassicalSharp/2D/Screens/ChatScreen.cs +++ b/ClassicalSharp/2D/Screens/ChatScreen.cs @@ -270,7 +270,7 @@ namespace ClassicalSharp { } else { textInput.HandlesKeyDown( key ); } - return true; + return key < Key.F1 || key > Key.F35; } if( key == game.Mapping( KeyBinding.OpenChat ) ) { diff --git a/ClassicalSharp/Blocks/BlockInfo.Culling.cs b/ClassicalSharp/Blocks/BlockInfo.Culling.cs index b499dca5e..319ea1f2e 100644 --- a/ClassicalSharp/Blocks/BlockInfo.Culling.cs +++ b/ClassicalSharp/Blocks/BlockInfo.Culling.cs @@ -9,6 +9,8 @@ namespace ClassicalSharp { bool[] hidden = new bool[BlocksCount * BlocksCount * TileSide.Sides]; public bool[] CanStretch = new bool[BlocksCount * TileSide.Sides]; + + public bool[] IsAir = new bool[BlocksCount]; internal void CheckOpaque() { for( int tile = 1; tile < BlocksCount; tile++ ) { @@ -20,6 +22,7 @@ namespace ClassicalSharp { } internal void SetupCullingCache() { + IsAir[0] = true; CheckOpaque(); for( int i = 0; i < CanStretch.Length; i++ ) CanStretch[i] = true; diff --git a/ClassicalSharp/Blocks/BlockInfo.cs b/ClassicalSharp/Blocks/BlockInfo.cs index 7509d67f0..a5a616759 100644 --- a/ClassicalSharp/Blocks/BlockInfo.cs +++ b/ClassicalSharp/Blocks/BlockInfo.cs @@ -172,6 +172,7 @@ namespace ClassicalSharp { BlocksLight[id] = true; FullBright[id] = false; CullWithNeighbours[id] = true; + IsAir[id] = false; Name[id] = "Invalid"; FogColour[id] = default( FastColour ); diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index 06a8dbdc4..f75243461 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -441,7 +441,8 @@ namespace ClassicalSharp { } internal bool CanPick( byte block ) { - if( block == 0 ) return false; + if( BlockInfo.CollideType[block] == BlockCollideType.WalkThrough ) + return false; if( !BlockInfo.IsLiquid[block] ) return true; return !LiquidsBreakable ? false : diff --git a/ClassicalSharp/Map/ChunkMeshBuilder.cs b/ClassicalSharp/Map/ChunkMeshBuilder.cs index 0808df556..2e8d19386 100644 --- a/ClassicalSharp/Map/ChunkMeshBuilder.cs +++ b/ClassicalSharp/Map/ChunkMeshBuilder.cs @@ -48,7 +48,7 @@ namespace ClassicalSharp { int chunkIndex = (yy + 1) * extChunkSize2 + (zz + 1) * extChunkSize + (0 + 1); for( int x = x1, xx = 0; x < xMax; x++, xx++ ) { tile = chunk[chunkIndex]; - if( tile != 0 ) + if( !info.IsAir[tile] ) RenderTile( chunkIndex, xx, yy, zz, x, y, z ); chunkIndex++; } @@ -59,12 +59,8 @@ namespace ClassicalSharp { unsafe bool ReadChunkData( int x1, int y1, int z1 ) { bool allAir = true, allSolid = true; - fixed( byte* chunkPtr = chunk, mapPtr = map.mapData ) { - - int* chunkIntPtr = (int*)chunkPtr; - for( int i = 0; i < extChunkSize3 / sizeof( int ); i++ ) { - *chunkIntPtr++ = 0; - } + fixed( byte* chunkPtr = chunk, mapPtr = map.mapData ) { + MemUtils.memset( (IntPtr)chunkPtr, 0, 0, extChunkSize3 ); for( int yy = -1; yy < 17; yy++ ) { int y = yy + y1; @@ -75,8 +71,8 @@ namespace ClassicalSharp { if( z < 0 ) continue; if( z > maxZ ) break; - int index = ( y * length + z ) * width + ( x1 - 1 - 1 ); - int chunkIndex = ( yy + 1 ) * extChunkSize2 + ( zz + 1 ) * extChunkSize + ( -1 + 1 ) - 1; + int index = (y * length + z) * width + (x1 - 1 - 1); + int chunkIndex = (yy + 1) * extChunkSize2 + (zz + 1) * extChunkSize + (-1 + 1) - 1; for( int xx = -1; xx < 17; xx++ ) { int x = xx + x1; @@ -160,10 +156,9 @@ namespace ClassicalSharp { DrawTopFace( topCount ); } - void Stretch( int x1, int y1, int z1 ) { - for( int i = 0; i < counts.Length; i++ ) { - counts[i] = 1; - } + unsafe void Stretch( int x1, int y1, int z1 ) { + fixed( byte* ptr = counts ) + MemUtils.memset( (IntPtr)ptr, 1, 0, chunkSize3 * TileSide.Sides ); int xMax = Math.Min( width, x1 + chunkSize ); int yMax = Math.Min( height, y1 + chunkSize ); @@ -187,7 +182,7 @@ namespace ClassicalSharp { for( int x = x1, xx = 0; x < xMax; x++, xx++ ) { chunkIndex++; byte tile = chunk[chunkIndex]; - if( tile == 0 ) continue; + if( info.IsAir[tile] ) continue; int countIndex = ((yy << 8) + (zz << 4) + xx) * TileSide.Sides; // Sprites only use one face to indicate stretching count, so we can take a shortcut here. diff --git a/ClassicalSharp/Model/BlockModel.cs b/ClassicalSharp/Model/BlockModel.cs index d70671944..c74baf184 100644 --- a/ClassicalSharp/Model/BlockModel.cs +++ b/ClassicalSharp/Model/BlockModel.cs @@ -42,7 +42,7 @@ namespace ClassicalSharp.Model { } public void CalcState( byte block ) { - if( block == 0 ) { + if( game.BlockInfo.IsAir[block] ) { bright = false; minBB = Vector3.Zero; maxBB = Vector3.One; @@ -71,7 +71,7 @@ namespace ClassicalSharp.Model { } CalcState( block ); - if( block == 0 ) + if( game.BlockInfo.IsAir[block] ) return; lastTexId = -1; atlas = game.TerrainAtlas1D; diff --git a/ClassicalSharp/Network/NetworkProcessor.CPE.cs b/ClassicalSharp/Network/NetworkProcessor.CPE.cs index 8d03079e9..4f3eb18cc 100644 --- a/ClassicalSharp/Network/NetworkProcessor.CPE.cs +++ b/ClassicalSharp/Network/NetworkProcessor.CPE.cs @@ -460,6 +460,9 @@ namespace ClassicalSharp { info.CullWithNeighbours[block] = false; } else if( blockDraw == 3 ) { info.IsTranslucent[block] = true; + } else if( blockDraw == 4 ) { + info.IsTransparent[block] = true; + info.IsAir[block] = true; } if( info.IsOpaque[block] ) info.IsOpaque[block] = blockDraw == 0;