mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -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();
|
RecreateBlockInfoTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string[] normalNames = null;
|
||||||
void UpdateBlockInfoString( Block block ) {
|
void UpdateBlockInfoString( Block block ) {
|
||||||
|
if( normalNames == null )
|
||||||
|
MakeNormalNames();
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
buffer.Clear();
|
buffer.Clear();
|
||||||
buffer.Append( ref index, "&f" );
|
buffer.Append( ref index, "&f" );
|
||||||
@ -114,8 +118,8 @@ namespace ClassicalSharp {
|
|||||||
buffer.Append( ref index, "TNT" );
|
buffer.Append( ref index, "TNT" );
|
||||||
} else {
|
} else {
|
||||||
string value = game.BlockInfo.Name[(byte)block];
|
string value = game.BlockInfo.Name[(byte)block];
|
||||||
if( (byte)block < BlockInfo.CpeBlocksCount ) {
|
if( (byte)block < BlockInfo.CpeBlocksCount && value == "Invalid" ) {
|
||||||
SplitUppercase( value, ref index );
|
buffer.Append( ref index, normalNames[(byte)block] );
|
||||||
} else {
|
} else {
|
||||||
buffer.Append( ref index, value );
|
buffer.Append( ref index, value );
|
||||||
}
|
}
|
||||||
@ -127,6 +131,19 @@ namespace ClassicalSharp {
|
|||||||
buffer.Append( ref index, "&f)" );
|
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 ) {
|
void SplitUppercase( string value, ref int index ) {
|
||||||
for( int i = 0; i < value.Length; i++ ) {
|
for( int i = 0; i < value.Length; i++ ) {
|
||||||
char c = value[i];
|
char c = value[i];
|
||||||
|
@ -64,12 +64,8 @@ namespace ClassicalSharp {
|
|||||||
SpeedMultiplier[tile] = 1;
|
SpeedMultiplier[tile] = 1;
|
||||||
CullWithNeighbours[tile] = true;
|
CullWithNeighbours[tile] = true;
|
||||||
}
|
}
|
||||||
for( int i = 0; i < CpeBlocksCount; i++ ) {
|
for( int block = 0; block < BlocksCount; block++ )
|
||||||
Name[i] = Enum.GetName( typeof( Block ), (byte)i );
|
Name[block] = "Invalid";
|
||||||
}
|
|
||||||
for( int i = CpeBlocksCount; i < BlocksCount; i++ ) {
|
|
||||||
Name[i] = "Invalid";
|
|
||||||
}
|
|
||||||
|
|
||||||
FogDensity[(byte)Block.StillWater] = 0.1f;
|
FogDensity[(byte)Block.StillWater] = 0.1f;
|
||||||
FogColour[(byte)Block.StillWater] = new FastColour( 5, 5, 51 );
|
FogColour[(byte)Block.StillWater] = new FastColour( 5, 5, 51 );
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
<DefineConstants>DEBUG;TRACE;</DefineConstants>
|
<DefineConstants>DEBUG;TRACE;</DefineConstants>
|
||||||
<StartAction>Project</StartAction>
|
<StartAction>Project</StartAction>
|
||||||
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
|
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
|
||||||
|
<StartArguments>wwwf ff 127.0.0.1 25565</StartArguments>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
<OutputPath>..\output\release\</OutputPath>
|
<OutputPath>..\output\release\</OutputPath>
|
||||||
|
@ -287,10 +287,9 @@ namespace ClassicalSharp.Generator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CanGrowTree( int treeX, int treeY, int treeZ, int height ) {
|
bool CanGrowTree( int treeX, int treeY, int treeZ, int treeHeight ) {
|
||||||
return true;
|
|
||||||
// check tree base
|
// check tree base
|
||||||
int baseHeight = height - 4;
|
int baseHeight = treeHeight - 4;
|
||||||
for( int y = treeY; y < treeY + baseHeight; y++ )
|
for( int y = treeY; y < treeY + baseHeight; y++ )
|
||||||
for( int z = treeZ - 1; z <= treeZ + 1; z++ )
|
for( int z = treeZ - 1; z <= treeZ + 1; z++ )
|
||||||
for( int x = treeX - 1; x <= treeX + 1; x++ )
|
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 )
|
if( x < 0 || y < 0 || z < 0 || x >= width || y >= height || z >= length )
|
||||||
return false;
|
return false;
|
||||||
int index = (y * length + z) * width + x;
|
int index = (y * length + z) * width + x;
|
||||||
//if( blocks[index] != 0 ) return false;
|
if( blocks[index] != 0 ) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// and also check canopy
|
// 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 z = treeZ - 2; z <= treeZ + 2; z++ )
|
||||||
for( int x = treeX - 2; x <= treeX + 2; x++ )
|
for( int x = treeX - 2; x <= treeX + 2; x++ )
|
||||||
{
|
{
|
||||||
if( x < 0 || y < 0 || z < 0 || x >= width || y >= height || z >= length )
|
if( x < 0 || y < 0 || z < 0 || x >= width || y >= height || z >= length )
|
||||||
return false;
|
return false;
|
||||||
int index = (y * length + z) * width + x;
|
int index = (y * length + z) * width + x;
|
||||||
//if( blocks[index] != 0 ) return false;
|
if( blocks[index] != 0 ) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -325,7 +324,7 @@ namespace ClassicalSharp.Generator {
|
|||||||
{
|
{
|
||||||
int x = xx + treeX, z = zz + treeZ;
|
int x = xx + treeX, z = zz + treeZ;
|
||||||
index = (y * length + z) * width + x;
|
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( Math.Abs( xx ) == 2 && Math.Abs( zz ) == 2 ) {
|
||||||
if( rnd.NextDouble() >= 0.5 )
|
if( rnd.NextDouble() >= 0.5 )
|
||||||
blocks[index] = (byte)Block.Leaves;
|
blocks[index] = (byte)Block.Leaves;
|
||||||
@ -342,7 +341,7 @@ namespace ClassicalSharp.Generator {
|
|||||||
{
|
{
|
||||||
int x = xx + treeX, z = zz + treeZ;
|
int x = xx + treeX, z = zz + treeZ;
|
||||||
index = (y * length + z) * width + x;
|
index = (y * length + z) * width + x;
|
||||||
if( !Check( x, y, z ) ) continue;
|
|
||||||
if( xx == 0 || zz == 0 ) {
|
if( xx == 0 || zz == 0 ) {
|
||||||
blocks[index] = (byte)Block.Leaves;
|
blocks[index] = (byte)Block.Leaves;
|
||||||
} else if( y == bottomY && rnd.NextDouble() >= 0.5 ) {
|
} else if( y == bottomY && rnd.NextDouble() >= 0.5 ) {
|
||||||
@ -353,15 +352,9 @@ namespace ClassicalSharp.Generator {
|
|||||||
// then place trunk
|
// then place trunk
|
||||||
index = (treeY * length + treeZ ) * width + treeX;
|
index = (treeY * length + treeZ ) * width + treeX;
|
||||||
for( int y = 0; y < height - 1; y++ ) {
|
for( int y = 0; y < height - 1; y++ ) {
|
||||||
if( !Check( treeX, treeY + y, treeZ ) ) continue;
|
|
||||||
blocks[index] = (byte)Block.Wood;
|
blocks[index] = (byte)Block.Wood;
|
||||||
index += oneY;
|
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();
|
byte shape = reader.ReadUInt8();
|
||||||
if( shape == 2 ) {
|
if( shape == 2 ) {
|
||||||
info.Height[block] = 8/16f;
|
info.Height[block] = 8/16f;
|
||||||
|
info.MaxBB[block].Y = 8/16f;
|
||||||
} else if( shape == 3 ) {
|
} else if( shape == 3 ) {
|
||||||
info.Height[block] = 2/16f;
|
info.Height[block] = 2/16f;
|
||||||
|
info.MaxBB[block].Y = 2/16f;
|
||||||
} else if( shape == 4 ) {
|
} else if( shape == 4 ) {
|
||||||
info.IsSprite[block] = true;
|
info.IsSprite[block] = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user