diff --git a/source/World/Generator/Biome.cpp b/source/World/Generator/Biome.cpp index f5d8a4e..05f8533 100644 --- a/source/World/Generator/Biome.cpp +++ b/source/World/Generator/Biome.cpp @@ -24,7 +24,7 @@ Biome Biome* Biome::map[4096]; -Biome* Biome::_getBiome(float hum, float temp) +Biome* Biome::_getBiome(float temp, float hum) { if (temp < 0.1) return tundra; diff --git a/source/World/Generator/Feature.hpp b/source/World/Generator/Feature.hpp index fd03be3..a785d72 100644 --- a/source/World/Generator/Feature.hpp +++ b/source/World/Generator/Feature.hpp @@ -86,3 +86,9 @@ private: int m_count; }; +class ReedsFeature : public Feature +{ +public: + bool place(Level*, Random*, int x, int y, int z) override; +}; + diff --git a/source/World/Generator/RandomLevelSource.cpp b/source/World/Generator/RandomLevelSource.cpp index 7464f5b..9265990 100644 --- a/source/World/Generator/RandomLevelSource.cpp +++ b/source/World/Generator/RandomLevelSource.cpp @@ -486,6 +486,14 @@ void RandomLevelSource::postProcess(ChunkSource* src, int x, int z) FlowerFeature(Tile::mushroom2->m_ID).place(m_pLevel, &m_random, x16 + 8 + xo, yo, z16 + 8 + zo); } + for (int i = 0; i < 10; i++) + { + int xo = m_random.nextInt(16); + int yo = m_random.nextInt(128); + int zo = m_random.nextInt(16); + ReedsFeature().place(m_pLevel, &m_random, x16 + 8 + xo, yo, z16 + 8 + zo); + } + for (int i = 0; i < 50; i++) { int xo = m_random.nextInt(16); diff --git a/source/World/Generator/ReedsFeature.cpp b/source/World/Generator/ReedsFeature.cpp new file mode 100644 index 0000000..85c2a92 --- /dev/null +++ b/source/World/Generator/ReedsFeature.cpp @@ -0,0 +1,39 @@ +/******************************************************************** + Minecraft: Pocket Edition - Decompilation Project + Copyright (C) 2023 iProgramInCpp + + The following code is licensed under the BSD 1 clause license. + SPDX-License-Identifier: BSD-1-Clause + ********************************************************************/ + +#include "Feature.hpp" +#include "Level.hpp" + +bool ReedsFeature::place(Level* level, Random* random, int x, int y, int z) +{ + for (int i = 0; i < 20; i++) + { + int newX = (x + random->nextInt(4)) - random->nextInt(4); + int newZ = (z + random->nextInt(4)) - random->nextInt(4); + + if (!level->isEmptyTile(newX, y, newZ)) + continue; + + if (level->getMaterial(newX - 1, y - 1, newZ) == Material::water || + level->getMaterial(newX + 1, y - 1, newZ) == Material::water || + level->getMaterial(newX, y - 1, newZ - 1) == Material::water || + level->getMaterial(newX, y - 1, newZ + 1) == Material::water) + { + int height = random->nextInt(random->nextInt(3) + 1) + 2; + for (int y1 = 0; y1 < height; y1++) + { + if (Tile::reeds->canSurvive(level, newX, y + y1, newZ)) + { + level->setTileNoUpdate(newX, y + y1, newZ, Tile::reeds->m_ID); + } + } + } + } + + return true; +} diff --git a/windows_vs/minecraftcpp.vcxproj b/windows_vs/minecraftcpp.vcxproj index 4bb09b8..86ebb52 100644 --- a/windows_vs/minecraftcpp.vcxproj +++ b/windows_vs/minecraftcpp.vcxproj @@ -437,6 +437,7 @@ + diff --git a/windows_vs/minecraftcpp.vcxproj.filters b/windows_vs/minecraftcpp.vcxproj.filters index e41cd3a..8e40066 100644 --- a/windows_vs/minecraftcpp.vcxproj.filters +++ b/windows_vs/minecraftcpp.vcxproj.filters @@ -1089,6 +1089,9 @@ Source Files\Game Modes + + Source Files\World\Generator\Features +