diff --git a/2D/Screens/BlockSelectScreen.cs b/2D/Screens/BlockSelectScreen.cs index 8af953f53..5aea35f12 100644 --- a/2D/Screens/BlockSelectScreen.cs +++ b/2D/Screens/BlockSelectScreen.cs @@ -122,7 +122,7 @@ namespace ClassicalSharp { void RecreateBlockTextures() { int blocksCount = 0; - for( int i = 0; i < Window.CanPlace.Length; i++ ) { + for( int i = 0; i < BlockInfo.BlocksCount; i++ ) { if( Window.CanPlace[i] || Window.CanDelete[i] ) { blocksCount++; } @@ -135,7 +135,7 @@ namespace ClassicalSharp { blocksTable = new BlockDrawInfo[blocksCount]; int tableIndex = 0; - for( int i = 0; i < Window.CanPlace.Length; i++ ) { + for( int i = 0; i < BlockInfo.BlocksCount; i++ ) { if( Window.CanPlace[i] || Window.CanDelete[i] ) { Block block = (Block)i; int texId = Window.BlockInfo.GetOptimTextureLoc( (byte)block, TileSide.Left ); diff --git a/Blocks/BlockInfo.Culling.cs b/Blocks/BlockInfo.Culling.cs index cbd921abc..43296f48d 100644 --- a/Blocks/BlockInfo.Culling.cs +++ b/Blocks/BlockInfo.Culling.cs @@ -4,11 +4,11 @@ namespace ClassicalSharp { public partial class BlockInfo { - bool[] hidden = new bool[blocksCount * blocksCount * 6]; + bool[] hidden = new bool[BlocksCount * BlocksCount * 6]; void SetupCullingCache() { - for( byte tile = 1; tile < blocksCount; tile++ ) { - for( byte neighbour = 1; neighbour < blocksCount; neighbour++ ) { + for( byte tile = 1; tile < BlocksCount; tile++ ) { + for( byte neighbour = 1; neighbour < BlocksCount; neighbour++ ) { bool hidden = IsHidden( tile, neighbour ); if( hidden ) { SetHidden( tile, neighbour, TileSide.Left, true ); @@ -29,11 +29,11 @@ namespace ClassicalSharp { } void SetHidden( byte tile, byte block, int tileSide, bool value ) { - hidden[( tile * blocksCount + block ) * 6 + tileSide] = value; + hidden[( tile * BlocksCount + block ) * 6 + tileSide] = value; } public bool IsFaceHidden( byte tile, byte block, int tileSide ) { - return hidden[( tile * blocksCount + block ) * 6 + tileSide]; + return hidden[( tile * BlocksCount + block ) * 6 + tileSide]; } } } \ No newline at end of file diff --git a/Blocks/BlockInfo.Optimised.cs b/Blocks/BlockInfo.Optimised.cs index 8e20192c5..4d3a7356d 100644 --- a/Blocks/BlockInfo.Optimised.cs +++ b/Blocks/BlockInfo.Optimised.cs @@ -7,7 +7,7 @@ namespace ClassicalSharp { // The designation used is as follows: // 0 - left 1 - right 2 - front // 3 - back 4 - bottom 5 - top - int[] optimTextures = new int[blocksCount * 6]; + int[] optimTextures = new int[BlocksCount * 6]; const int Row1 = 0, Row2 = 16, Row3 = 32, Row4 = 48, Row5 = 64, Row6 = 80, Row7 = 96, Row8 = 112, Row9 = 128; diff --git a/Blocks/BlockInfo.cs b/Blocks/BlockInfo.cs index b002e9d24..e0783a1bc 100644 --- a/Blocks/BlockInfo.cs +++ b/Blocks/BlockInfo.cs @@ -4,17 +4,18 @@ namespace ClassicalSharp { public partial class BlockInfo { - bool[] isTransparent = new bool[blocksCount]; - bool[] isTranslucent = new bool[blocksCount]; - bool[] isOpaque = new bool[blocksCount]; - bool[] isSprite = new bool[blocksCount]; - bool[] isLiquid = new bool[blocksCount]; - float[] heights = new float[blocksCount]; - bool[] blocksLight = new bool[blocksCount]; - const byte blocksCount = (byte)Block.StoneBrick + 1; + bool[] isTransparent = new bool[BlocksCount]; + bool[] isTranslucent = new bool[BlocksCount]; + bool[] isOpaque = new bool[BlocksCount]; + bool[] isSprite = new bool[BlocksCount]; + bool[] isLiquid = new bool[BlocksCount]; + float[] heights = new float[BlocksCount]; + bool[] blocksLight = new bool[BlocksCount]; + public const byte MaxDefinedBlock = (byte)Block.StoneBrick; + public const byte BlocksCount = MaxDefinedBlock + 1; public void Init() { - for( int tile = 1; tile < blocksCount; tile++ ) { + for( int tile = 1; tile < BlocksCount; tile++ ) { heights[tile] = 1f; blocksLight[tile] = true; isOpaque[tile] = true;