diff options
| author | daoge <3523206925@qq.com> | 2026-03-03 03:04:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 03:04:10 +0800 |
| commit | b3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch) | |
| tree | 267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/Mushroom.cpp | |
| parent | 84c31a2331f7a0ec85b9d438992e244f60e5020f (diff) | |
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict
* feat: TU19 (Dec 2014) Features & Content (#32)
* December 2014 files
* Working release build
* Fix compilation issues
* Add sound to Windows64Media
* Add DLC content and force Tutorial DLC
* Revert "Add DLC content and force Tutorial DLC"
This reverts commit 97a43994725008e35fceb984d5549df9c8cea470.
* Disable broken light packing
* Disable breakpoint during DLC texture map load
Allows DLC loading but the DLC textures are still broken
* Fix post build not working
* ...
* fix vs2022 build
* fix cmake build
---------
Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/Mushroom.cpp')
| -rw-r--r-- | Minecraft.World/Mushroom.cpp | 104 |
1 files changed, 49 insertions, 55 deletions
diff --git a/Minecraft.World/Mushroom.cpp b/Minecraft.World/Mushroom.cpp index 1056cdec..6b20e0d1 100644 --- a/Minecraft.World/Mushroom.cpp +++ b/Minecraft.World/Mushroom.cpp @@ -4,54 +4,53 @@ #include "net.minecraft.world.h" #include "Mushroom.h" -Mushroom::Mushroom(int id, const wstring &texture) : Bush(id) +Mushroom::Mushroom(int id) : Bush(id) { - this->updateDefaultShape(); - this->setTicking(true); - this->texture = texture; + this->updateDefaultShape(); + this->setTicking(true); } // 4J Added override void Mushroom::updateDefaultShape() { - float ss = 0.2f; - this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, ss * 2, 0.5f + ss); + float ss = 0.2f; + this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, ss * 2, 0.5f + ss); } void Mushroom::tick(Level *level, int x, int y, int z, Random *random) { - if (random->nextInt(25) == 0) + if (random->nextInt(25) == 0) { - int r = 4; - int max = 5; - for (int xx = x - r; xx <= x + r; xx++) - for (int zz = z - r; zz <= z + r; zz++) - for (int yy = y - 1; yy <= y + 1; yy++) + int r = 4; + int max = 5; + for (int xx = x - r; xx <= x + r; xx++) + for (int zz = z - r; zz <= z + r; zz++) + for (int yy = y - 1; yy <= y + 1; yy++) { - if (level->getTile(xx, yy, zz) == id && --max <= 0) return; - } + if (level->getTile(xx, yy, zz) == id && --max <= 0) return; + } - int x2 = x + random->nextInt(3) - 1; - int y2 = y + random->nextInt(2) - random->nextInt(2); - int z2 = z + random->nextInt(3) - 1; - for (int i = 0; i < 4; i++) - { - if (level->isEmptyTile(x2, y2, z2) && canSurvive(level, x2, y2, z2)) + int x2 = x + random->nextInt(3) - 1; + int y2 = y + random->nextInt(2) - random->nextInt(2); + int z2 = z + random->nextInt(3) - 1; + for (int i = 0; i < 4; i++) { - x = x2; - y = y2; - z = z2; - } - x2 = x + random->nextInt(3) - 1; - y2 = y + random->nextInt(2) - random->nextInt(2); - z2 = z + random->nextInt(3) - 1; - } + if (level->isEmptyTile(x2, y2, z2) && canSurvive(level, x2, y2, z2)) + { + x = x2; + y = y2; + z = z2; + } + x2 = x + random->nextInt(3) - 1; + y2 = y + random->nextInt(2) - random->nextInt(2); + z2 = z + random->nextInt(3) - 1; + } - if (level->isEmptyTile(x2, y2, z2) && canSurvive(level, x2, y2, z2)) - { - level->setTile(x2, y2, z2, id); - } - } + if (level->isEmptyTile(x2, y2, z2) && canSurvive(level, x2, y2, z2)) + { + level->setTileAndData(x2, y2, z2, id, 0, UPDATE_CLIENTS); + } + } } bool Mushroom::mayPlace(Level *level, int x, int y, int z) @@ -68,40 +67,35 @@ bool Mushroom::canSurvive(Level *level, int x, int y, int z) { if (y < 0 || y >= Level::maxBuildHeight) return false; - int below = level->getTile(x, y - 1, z); + int below = level->getTile(x, y - 1, z); - return below == Tile::mycel_Id || (level->getDaytimeRawBrightness(x, y, z) < 13 && mayPlaceOn(below)); + return below == Tile::mycel_Id || (level->getDaytimeRawBrightness(x, y, z) < 13 && mayPlaceOn(below)); } bool Mushroom::growTree(Level *level, int x, int y, int z, Random *random) { - int data = level->getData(x, y, z); + int data = level->getData(x, y, z); - level->setTileNoUpdate(x, y, z, 0); - Feature *f = NULL; + level->removeTile(x, y, z); + Feature *f = NULL; - if (id == Tile::mushroom1_Id) + if (id == Tile::mushroom_brown_Id) { - f = new HugeMushroomFeature(0); - } - else if (id == Tile::mushroom2_Id) + f = new HugeMushroomFeature(0); + } + else if (id == Tile::mushroom_red_Id) { - f = new HugeMushroomFeature(1); - } + f = new HugeMushroomFeature(1); + } - if (f == NULL || !f->place(level, random, x, y, z)) + if (f == NULL || !f->place(level, random, x, y, z)) { - level->setTileAndDataNoUpdate(x, y, z, this->id, data); + level->setTileAndData(x, y, z, id, data, Tile::UPDATE_ALL); if( f != NULL ) delete f; - return false; - } + return false; + } if( f != NULL ) delete f; - return true; -} - -void Mushroom::registerIcons(IconRegister *iconRegister) -{ - icon = iconRegister->registerIcon(texture); -} + return true; +}
\ No newline at end of file |
