mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Fix trees not being generated in singleplayer (Thanks Jerralish), fix some issues with selection bounds not being calculated correctly for BlockDefinitions blocks.
This commit is contained in:
parent
55db094c0b
commit
0e331ce01a
@ -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];
|
||||
|
@ -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 );
|
||||
|
@ -35,6 +35,7 @@
|
||||
<DefineConstants>DEBUG;TRACE;</DefineConstants>
|
||||
<StartAction>Project</StartAction>
|
||||
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
|
||||
<StartArguments>wwwf ff 127.0.0.1 25565</StartArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<OutputPath>..\output\release\</OutputPath>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user