mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-25 14:14:46 -04:00
Trees should only grow on grass (Thanks McBean56545)
This commit is contained in:
parent
a01589b88a
commit
d45e32c8b4
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user