aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/GroundBushFeature.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/GroundBushFeature.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/GroundBushFeature.cpp')
-rw-r--r--Minecraft.World/GroundBushFeature.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/Minecraft.World/GroundBushFeature.cpp b/Minecraft.World/GroundBushFeature.cpp
new file mode 100644
index 00000000..df7561f3
--- /dev/null
+++ b/Minecraft.World/GroundBushFeature.cpp
@@ -0,0 +1,43 @@
+#include "stdafx.h"
+#include "net.minecraft.world.level.h"
+#include "net.minecraft.world.level.tile.h"
+#include "GroundBushFeature.h"
+
+GroundBushFeature::GroundBushFeature(int trunkType, int leafType)
+{
+ this->trunkTileType = trunkType;
+ this->leafTileType = leafType;
+}
+
+bool GroundBushFeature::place(Level *level, Random *random, int x, int y, int z)
+{
+ PIXBeginNamedEvent(0,"Placing GroundBushFeature");
+ int t = 0;
+ while (((t = level->getTile(x, y, z)) == 0 || t == Tile::leaves_Id) && y > 0)
+ y--;
+
+ int tile = level->getTile(x, y, z);
+ if (tile == Tile::dirt_Id || tile == Tile::grass_Id)
+ {
+ y++;
+ placeBlock(level, x, y, z, Tile::treeTrunk_Id, trunkTileType);
+
+ for (int yy = y; yy <= y + 2; yy++)
+ {
+ int yo = yy - y;
+ int offs = 2 - yo;
+ for (int xx = x - offs; xx <= x + offs; xx++)
+ {
+ int xo = xx - (x);
+ for (int zz = z - offs; zz <= z + offs; zz++)
+ {
+ int zo = zz - (z);
+ if (abs(xo) == offs && abs(zo) == offs && random->nextInt(2) == 0) continue;
+ if (!Tile::solid[level->getTile(xx, yy, zz)]) placeBlock(level, xx, yy, zz, Tile::leaves_Id, leafTileType);
+ }
+ }
+ }
+ }
+ PIXEndNamedEvent();
+ return true;
+} \ No newline at end of file