From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.World/DesertWellFeature.cpp | 90 +++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Minecraft.World/DesertWellFeature.cpp (limited to 'Minecraft.World/DesertWellFeature.cpp') 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 -- cgit v1.2.3