Trees should only grow on grass (Thanks McBean56545)

This commit is contained in:
UnknownShadow200 2017-03-05 15:21:01 +11:00
parent a01589b88a
commit d45e32c8b4
3 changed files with 10 additions and 2 deletions

View File

@ -135,6 +135,7 @@ namespace ClassicalSharp.Gui.Widgets {
string line = lines[caretRow];
if (caretCol < line.Length) {
args.Text = new String(line[caretCol], 1);
args.UseShadow = true;
caretTex.Width = (short)drawer.MeasureSize(ref args).Width;
} else {
caretTex.Width = (short)caretWidth;

View File

@ -348,7 +348,11 @@ namespace ClassicalSharp.Generator {
int treeY = heightmap[treeZ * Width + treeX] + 1;
int treeHeight = 5 + rnd.Next(3);
if (CanGrowTree(treeX, treeY, treeZ, treeHeight)) {
int index = (treeY * Length + treeZ) * Width + treeX;
BlockID blockUnder = treeY > 0 ? blocks[index - oneY] : Block.Air;
if (blockUnder == Block.Grass && CanGrowTree(treeX, treeY, treeZ, treeHeight)) {
GrowTree(treeX, treeY, treeZ, treeHeight);
}
}

View File

@ -36,7 +36,10 @@ namespace ClassicalSharp.Singleplayer {
int x = index % map.Width;
int y = (index / map.Width) / map.Length;
int z = (index / map.Width) % map.Length;
GrowTree(x, y, z);
BlockID below = Block.Air;
if (y > 0) below = map.blocks[index - map.Width * map.Length];
if (below == Block.Grass) GrowTree(x, y, z);
}
void HandleDirt(int index, BlockID block) {