aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/DesertWellFeature.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/DesertWellFeature.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/DesertWellFeature.cpp')
-rw-r--r--Minecraft.World/DesertWellFeature.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/Minecraft.World/DesertWellFeature.cpp b/Minecraft.World/DesertWellFeature.cpp
new file mode 100644
index 00000000..c89006bf
--- /dev/null
+++ b/Minecraft.World/DesertWellFeature.cpp
@@ -0,0 +1,90 @@
+#include "stdafx.h"
+#include "net.minecraft.world.level.h"
+#include "net.minecraft.world.level.tile.h"
+#include "DesertWellFeature.h"
+
+bool DesertWellFeature::place(Level *level, Random *random, int x, int y, int z)
+{
+ while (level->isEmptyTile(x, y, z) && y > 2)
+ y--;
+
+ int tile = level->getTile(x, y, z);
+ if (tile != Tile::sand_Id)
+ {
+ return false;
+ }
+
+ // the surrounding 5x5 area may not be lower than y-1
+ for (int ox = -2; ox <= 2; ox++)
+ {
+ for (int oz = -2; oz <= 2; oz++)
+ {
+ if (level->isEmptyTile(x + ox, y - 1, z + oz) && level->isEmptyTile(x + ox, y - 2, z + oz))
+ {
+ return false;
+ }
+ }
+ }
+
+ // place floor
+ for (int oy = -1; oy <= 0; oy++)
+ {
+ for (int ox = -2; ox <= 2; ox++)
+ {
+ for (int oz = -2; oz <= 2; oz++)
+ {
+ level->setTileNoUpdate(x + ox, y + oy, z + oz, Tile::sandStone_Id);
+ }
+ }
+ }
+
+ // place water cross
+ level->setTileNoUpdate(x, y, z, Tile::water_Id);
+ level->setTileNoUpdate(x - 1, y, z, Tile::water_Id);
+ level->setTileNoUpdate(x + 1, y, z, Tile::water_Id);
+ level->setTileNoUpdate(x, y, z - 1, Tile::water_Id);
+ level->setTileNoUpdate(x, y, z + 1, Tile::water_Id);
+
+ // place "fence"
+ for (int ox = -2; ox <= 2; ox++)
+ {
+ for (int oz = -2; oz <= 2; oz++)
+ {
+ if (ox == -2 || ox == 2 || oz == -2 || oz == 2)
+ {
+ level->setTileNoUpdate(x + ox, y + 1, z + oz, Tile::sandStone_Id);
+ }
+ }
+ }
+ level->setTileAndDataNoUpdate(x + 2, y + 1, z, Tile::stoneSlabHalf_Id, StoneSlabTile::SAND_SLAB);
+ level->setTileAndDataNoUpdate(x - 2, y + 1, z, Tile::stoneSlabHalf_Id, StoneSlabTile::SAND_SLAB);
+ level->setTileAndDataNoUpdate(x, y + 1, z + 2, Tile::stoneSlabHalf_Id, StoneSlabTile::SAND_SLAB);
+ level->setTileAndDataNoUpdate(x, y + 1, z - 2, Tile::stoneSlabHalf_Id, StoneSlabTile::SAND_SLAB);
+
+ // place roof
+ for (int ox = -1; ox <= 1; ox++)
+ {
+ for (int oz = -1; oz <= 1; oz++)
+ {
+ if (ox == 0 && oz == 0)
+ {
+ level->setTileNoUpdate(x + ox, y + 4, z + oz, Tile::sandStone_Id);
+ }
+ else
+ {
+ level->setTileAndDataNoUpdate(x + ox, y + 4, z + oz, Tile::stoneSlabHalf_Id, StoneSlabTile::SAND_SLAB);
+ }
+ }
+ }
+
+ // place pillars
+ for (int oy = 1; oy <= 3; oy++)
+ {
+ level->setTileNoUpdate(x - 1, y + oy, z - 1, Tile::sandStone_Id);
+ level->setTileNoUpdate(x - 1, y + oy, z + 1, Tile::sandStone_Id);
+ level->setTileNoUpdate(x + 1, y + oy, z - 1, Tile::sandStone_Id);
+ level->setTileNoUpdate(x + 1, y + oy, z + 1, Tile::sandStone_Id);
+ }
+
+ return true;
+} \ No newline at end of file