diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp index 984b6e37..413e7e17 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp @@ -82,7 +82,7 @@ void IUIScene_CreativeMenu::staticCtor() ITEM(Tile::obsidian_Id) ITEM(Tile::clay) ITEM(Tile::ice_Id) - ITEM(Tile::packed_ice_Id) + ITEM(Tile::packedIce_Id) ITEM(Tile::snow_Id) ITEM(Tile::netherRack_Id) ITEM(Tile::soulsand_Id) diff --git a/Minecraft.World/Biome.cpp b/Minecraft.World/Biome.cpp index 311aba55..781607ea 100644 --- a/Minecraft.World/Biome.cpp +++ b/Minecraft.World/Biome.cpp @@ -47,35 +47,39 @@ Biome *Biome::birchForestHillsM = nullptr; Biome *Biome::birchForestM = nullptr; Biome *Biome::deepOcean = nullptr; Biome *Biome::roofedForestM = nullptr; +Biome *Biome::sunflowersPlains = nullptr; +Biome *Biome::iceSpikes = nullptr; void Biome::staticCtor() { Biome::ocean = (new OceanBiome(0))->setColor(0x000070)->setName(L"Ocean")->setDepthAndScale(-1, 0.4f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Ocean, eMinecraftColour_Foliage_Ocean, eMinecraftColour_Water_Ocean,eMinecraftColour_Sky_Ocean); - Biome::plains = (new PlainsBiome(1))->setColor(0x8db360)->setName(L"Plains")->setTemperatureAndDownfall(0.8f, 0.4f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Plains, eMinecraftColour_Foliage_Plains, eMinecraftColour_Water_Plains,eMinecraftColour_Sky_Plains); + Biome::plains = (new PlainsBiome(1,false))->setColor(0x8db360)->setName(L"Plains")->setTemperatureAndDownfall(0.8f, 0.4f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Plains, eMinecraftColour_Foliage_Plains, eMinecraftColour_Water_Plains,eMinecraftColour_Sky_Plains); + Biome::sunflowersPlains = (new PlainsBiome(129,true))->setColor(0x8db360)->setName(L"Sunflowers Plains")->setTemperatureAndDownfall(0.8f, 0.4f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Plains, eMinecraftColour_Foliage_Plains, eMinecraftColour_Water_Plains,eMinecraftColour_Sky_Plains); Biome::desert = (new DesertBiome(2))->setColor(0xFA9418)->setName(L"Desert")->setNoRain()->setTemperatureAndDownfall(2, 0)->setDepthAndScale(0.1f, 0.2f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Desert, eMinecraftColour_Foliage_Desert, eMinecraftColour_Water_Desert,eMinecraftColour_Sky_Desert); Biome::extremeHills = (new ExtremeHillsBiome(3))->setColor(0x606060)->setName(L"Extreme Hills")->setDepthAndScale(0.3f, 1.5f)->setTemperatureAndDownfall(0.2f, 0.3f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_ExtremeHills, eMinecraftColour_Foliage_ExtremeHills, eMinecraftColour_Water_ExtremeHills,eMinecraftColour_Sky_ExtremeHills); // Foreste Base Biome::forest = (new ForestBiome(4,0))->setColor(0x056621)->setName(L"Forest")->setLeafColor(0x4EBA31)->setTemperatureAndDownfall(0.7f, 0.8f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Forest, eMinecraftColour_Foliage_Forest, eMinecraftColour_Water_Forest,eMinecraftColour_Sky_Forest); - Biome::forestHills = (new ForestBiome(18,0))->setColor(0x22551c)->setName(L"ForestHills")->setLeafColor(0x4EBA31)->setTemperatureAndDownfall(0.7f, 0.8f)->setDepthAndScale(0.3f, 0.7f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_ForestHills, eMinecraftColour_Foliage_ForestHills, eMinecraftColour_Water_ForestHills,eMinecraftColour_Sky_ForestHills); + Biome::forestHills = (new ForestBiome(18,0))->setColor(0x22551c)->setName(L"Forest Hills")->setLeafColor(0x4EBA31)->setTemperatureAndDownfall(0.7f, 0.8f)->setDepthAndScale(0.3f, 0.7f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_ForestHills, eMinecraftColour_Foliage_ForestHills, eMinecraftColour_Water_ForestHills,eMinecraftColour_Sky_ForestHills); Biome::taiga = (new TaigaBiome(5))->setColor(0x0b6659)->setName(L"Taiga")->setLeafColor(0x4EBA31)->setSnowCovered()->setTemperatureAndDownfall(0.05f, 0.8f)->setDepthAndScale(0.1f, 0.4f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Taiga, eMinecraftColour_Foliage_Taiga, eMinecraftColour_Water_Taiga,eMinecraftColour_Sky_Taiga); Biome::swampland = (new SwampBiome(6))->setColor(0x07F9B2)->setName(L"Swampland")->setLeafColor(0x8BAF48)->setDepthAndScale(-0.2f, 0.1f)->setTemperatureAndDownfall(0.8f, 0.9f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Swampland, eMinecraftColour_Foliage_Swampland, eMinecraftColour_Water_Swampland,eMinecraftColour_Sky_Swampland); Biome::river = (new RiverBiome(7))->setColor(0x0000ff)->setName(L"River")->setDepthAndScale(-0.5f, 0)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_River, eMinecraftColour_Foliage_River, eMinecraftColour_Water_River,eMinecraftColour_Sky_River); Biome::hell = (new HellBiome(8))->setColor(0xff0000)->setName(L"Hell")->setNoRain()->setTemperatureAndDownfall(2, 0)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Hell, eMinecraftColour_Foliage_Hell, eMinecraftColour_Water_Hell,eMinecraftColour_Sky_Hell); Biome::sky = (new TheEndBiome(9))->setColor(0x8080ff)->setName(L"Sky")->setNoRain()->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Sky, eMinecraftColour_Foliage_Sky, eMinecraftColour_Water_Sky,eMinecraftColour_Sky_Sky); - Biome::frozenOcean = (new OceanBiome(10))->setColor(0x9090a0)->setName(L"FrozenOcean")->setSnowCovered()->setDepthAndScale(-1, 0.5f)->setTemperatureAndDownfall(0, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_FrozenOcean, eMinecraftColour_Foliage_FrozenOcean, eMinecraftColour_Water_FrozenOcean,eMinecraftColour_Sky_FrozenOcean); - Biome::frozenRiver = (new RiverBiome(11))->setColor(0xa0a0ff)->setName(L"FrozenRiver")->setSnowCovered()->setDepthAndScale(-0.5f, 0)->setTemperatureAndDownfall(0, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_FrozenRiver, eMinecraftColour_Foliage_FrozenRiver, eMinecraftColour_Water_FrozenRiver,eMinecraftColour_Sky_FrozenRiver); + Biome::frozenOcean = (new OceanBiome(10))->setColor(0x9090a0)->setName(L"Frozen Ocean")->setSnowCovered()->setDepthAndScale(-1, 0.5f)->setTemperatureAndDownfall(0, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_FrozenOcean, eMinecraftColour_Foliage_FrozenOcean, eMinecraftColour_Water_FrozenOcean,eMinecraftColour_Sky_FrozenOcean); + Biome::frozenRiver = (new RiverBiome(11))->setColor(0xa0a0ff)->setName(L"Frozen River")->setSnowCovered()->setDepthAndScale(-0.5f, 0)->setTemperatureAndDownfall(0, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_FrozenRiver, eMinecraftColour_Foliage_FrozenRiver, eMinecraftColour_Water_FrozenRiver,eMinecraftColour_Sky_FrozenRiver); Biome::iceFlats = (new IceBiome(12))->setColor(0xffffff)->setName(L"Ice Plains")->setSnowCovered()->setTemperatureAndDownfall(0, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_IcePlains, eMinecraftColour_Foliage_IcePlains, eMinecraftColour_Water_IcePlains,eMinecraftColour_Sky_IcePlains); + Biome::iceSpikes = (new IceBiome(12,true))->setColor(0xffffff)->setName(L"Ice Spikes")->setSnowCovered()->setTemperatureAndDownfall(0, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_IcePlains, eMinecraftColour_Foliage_IcePlains, eMinecraftColour_Water_IcePlains,eMinecraftColour_Sky_IcePlains); Biome::iceMountains = (new IceBiome(13))->setColor(0xa0a0a0)->setName(L"Ice Mountains")->setSnowCovered()->setDepthAndScale(0.3f, 1.3f)->setTemperatureAndDownfall(0, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_IceMountains, eMinecraftColour_Foliage_IceMountains, eMinecraftColour_Water_IceMountains,eMinecraftColour_Sky_IceMountains); - Biome::mushroomIsland = (new MushroomIslandBiome(14))->setColor(0xff00ff)->setName(L"MushroomIsland")->setTemperatureAndDownfall(0.9f, 1.0f)->setDepthAndScale(0.2f, 1.0f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_MushroomIsland, eMinecraftColour_Foliage_MushroomIsland, eMinecraftColour_Water_MushroomIsland,eMinecraftColour_Sky_MushroomIsland); - Biome::mushroomIslandShore = (new MushroomIslandBiome(15))->setColor(0xa000ff)->setName(L"MushroomIslandShore")->setTemperatureAndDownfall(0.9f, 1.0f)->setDepthAndScale(-1, 0.1f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_MushroomIslandShore, eMinecraftColour_Foliage_MushroomIslandShore, eMinecraftColour_Water_MushroomIslandShore,eMinecraftColour_Sky_MushroomIslandShore); + Biome::mushroomIsland = (new MushroomIslandBiome(14))->setColor(0xff00ff)->setName(L"Mushroom Island")->setTemperatureAndDownfall(0.9f, 1.0f)->setDepthAndScale(0.2f, 1.0f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_MushroomIsland, eMinecraftColour_Foliage_MushroomIsland, eMinecraftColour_Water_MushroomIsland,eMinecraftColour_Sky_MushroomIsland); + Biome::mushroomIslandShore = (new MushroomIslandBiome(15))->setColor(0xa000ff)->setName(L"Mushroom Island Shore")->setTemperatureAndDownfall(0.9f, 1.0f)->setDepthAndScale(-1, 0.1f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_MushroomIslandShore, eMinecraftColour_Foliage_MushroomIslandShore, eMinecraftColour_Water_MushroomIslandShore,eMinecraftColour_Sky_MushroomIslandShore); Biome::beaches = (new BeachBiome(16))->setColor(0xfade55)->setName(L"Beach")->setTemperatureAndDownfall(0.8f, 0.4f)->setDepthAndScale(0.0f, 0.1f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Beach, eMinecraftColour_Foliage_Beach, eMinecraftColour_Water_Beach,eMinecraftColour_Sky_Beach); - Biome::desertHills = (new DesertBiome(17))->setColor(0xd25f12)->setName(L"DesertHills")->setNoRain()->setTemperatureAndDownfall(2, 0)->setDepthAndScale(0.3f, 0.8f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_DesertHills, eMinecraftColour_Foliage_DesertHills, eMinecraftColour_Water_DesertHills,eMinecraftColour_Sky_DesertHills); - Biome::taigaHills = (new TaigaBiome(19))->setColor(0x163933)->setName(L"TaigaHills")->setSnowCovered()->setLeafColor(0x4EBA31)->setTemperatureAndDownfall(0.05f, 0.8f)->setDepthAndScale(0.3f, 0.8f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_TaigaHills, eMinecraftColour_Foliage_TaigaHills, eMinecraftColour_Water_TaigaHills,eMinecraftColour_Sky_TaigaHills); + Biome::desertHills = (new DesertBiome(17))->setColor(0xd25f12)->setName(L"Desert Hills")->setNoRain()->setTemperatureAndDownfall(2, 0)->setDepthAndScale(0.3f, 0.8f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_DesertHills, eMinecraftColour_Foliage_DesertHills, eMinecraftColour_Water_DesertHills,eMinecraftColour_Sky_DesertHills); + Biome::taigaHills = (new TaigaBiome(19))->setColor(0x163933)->setName(L"Taiga Hills")->setSnowCovered()->setLeafColor(0x4EBA31)->setTemperatureAndDownfall(0.05f, 0.8f)->setDepthAndScale(0.3f, 0.8f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_TaigaHills, eMinecraftColour_Foliage_TaigaHills, eMinecraftColour_Water_TaigaHills,eMinecraftColour_Sky_TaigaHills); Biome::smallerExtremeHills = (new ExtremeHillsBiome(20))->setColor(0x72789a)->setName(L"Extreme Hills Edge")->setDepthAndScale(0.2f, 0.8f)->setTemperatureAndDownfall(0.2f, 0.3f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_ExtremeHillsEdge, eMinecraftColour_Foliage_ExtremeHillsEdge, eMinecraftColour_Water_ExtremeHillsEdge,eMinecraftColour_Sky_ExtremeHillsEdge); - Biome::jungle = (new JungleBiome(21))->setColor(0x537b09)->setName(L"Jungle")->setLeafColor(0x537b09)->setTemperatureAndDownfall(1.2f, 0.9f)->setDepthAndScale(0.2f, 0.4f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Jungle, eMinecraftColour_Foliage_Jungle, eMinecraftColour_Water_Jungle,eMinecraftColour_Sky_Jungle); - Biome::jungleHills = (new JungleBiome(22))->setColor(0x2c4205)->setName(L"JungleHills")->setLeafColor(0x537b09)->setTemperatureAndDownfall(1.2f, 0.9f)->setDepthAndScale(1.8f, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_JungleHills, eMinecraftColour_Foliage_JungleHills, eMinecraftColour_Water_JungleHills,eMinecraftColour_Sky_JungleHills); + Biome::jungle = (new JungleBiome(21, false))->setColor(0x537b09)->setName(L"Jungle")->setLeafColor(0x537b09)->setTemperatureAndDownfall(1.2f, 0.9f)->setDepthAndScale(0.2f, 0.4f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Jungle, eMinecraftColour_Foliage_Jungle, eMinecraftColour_Water_Jungle,eMinecraftColour_Sky_Jungle); + Biome::jungleHills = (new JungleBiome(22, false))->setColor(0x2c4205)->setName(L"Jungle Hills")->setLeafColor(0x537b09)->setTemperatureAndDownfall(1.2f, 0.9f)->setDepthAndScale(1.8f, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_JungleHills, eMinecraftColour_Foliage_JungleHills, eMinecraftColour_Water_JungleHills,eMinecraftColour_Sky_JungleHills); Biome::savanna = (new SavannaBiome(35))->setColor(0xbda235)->setName(L"Savanna")->setNoRain()->setTemperatureAndDownfall(1.2f, 0.0f) ->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Savanna, eMinecraftColour_Foliage_Savanna, eMinecraftColour_Sky_Desert, eMinecraftColour_Sky_Desert); Biome::deepOcean= (new OceanBiome(24))->setName(L"Deep Ocean")->setDepthAndScale(-1.8,0.1f)->setColor(0x000070)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Ocean, eMinecraftColour_Foliage_Ocean, eMinecraftColour_Water_Ocean,eMinecraftColour_Sky_Ocean);; // Foreste Avanzate e Speciali @@ -104,7 +108,8 @@ Biome::Biome(int id) : id(id) downfall = 0.5f; decorator = nullptr; m_temperatureNoise = nullptr; - + GRASS_COLOR_NOISE = new PerlinNoise(new Random(2345L), 1); + DOUBLE_PLANT_GENERATOR = new DoublePlantFeature(false); m_grassColor = eMinecraftColour_NOT_SET; m_foliageColor = eMinecraftColour_NOT_SET; m_waterColor = eMinecraftColour_NOT_SET; @@ -136,6 +141,7 @@ Biome::Biome(int id) : id(id) Biome::~Biome() { if(decorator != nullptr) delete decorator; + if(DOUBLE_PLANT_GENERATOR != nullptr) delete DOUBLE_PLANT_GENERATOR; } BiomeDecorator *Biome::createDecorator() diff --git a/Minecraft.World/Biome.h b/Minecraft.World/Biome.h index 67dfa175..591ec253 100644 --- a/Minecraft.World/Biome.h +++ b/Minecraft.World/Biome.h @@ -6,6 +6,7 @@ using namespace std; #include "WeighedRandom.h" #include "BlockPos.h" #include "ChunkPrimer.h" +#include "DoublePlantFeature.h" class Feature; @@ -65,6 +66,8 @@ public: static Biome *Biome::roofedForestM; static Biome *Biome::deepOcean; + static Biome *Biome::sunflowersPlains; + static Biome *Biome::iceSpikes; static const int BIOME_COUNT = 256 ; @@ -79,8 +82,11 @@ public: float temperature; float downfall; + BiomeDecorator *decorator; PerlinNoise *m_temperatureNoise; + PerlinNoise *GRASS_COLOR_NOISE; + DoublePlantFeature *DOUBLE_PLANT_GENERATOR; const int id; diff --git a/Minecraft.World/BiomeDecorator.cpp b/Minecraft.World/BiomeDecorator.cpp index 78cddb96..ab37d97f 100644 --- a/Minecraft.World/BiomeDecorator.cpp +++ b/Minecraft.World/BiomeDecorator.cpp @@ -76,6 +76,7 @@ void BiomeDecorator::_init() doublePlantFeature = new DoublePlantFeature(false); + doublePlantCount = 0; waterlilyCount = 0; treeCount = 0; flowerCount = 2; @@ -213,24 +214,24 @@ void BiomeDecorator::decorate() } } - // 2blockstall - int doublePlantsToGen = (grassCount + flowerCount) / 2; - if (doublePlantsToGen > 0 && random->nextInt(3) == 0) - { - for (int i = 0; i < doublePlantsToGen; i++) - { - int x = xo + random->nextInt(16) + 8; - int y = random->nextInt(Level::genDepth); - int z = zo + random->nextInt(16) + 8; - - - int plantType = biome->getRandomDoublePlantType(random); - - DoublePlantFeature* dpf = static_cast(doublePlantFeature); - dpf->setPlantType(plantType); - dpf->place(level, random, x, y, z); - } - } + //int doublePlantsToGen = doublePlantCount; // <-- Usa una variabile specifica per bioma! + + //for (int i = 0; i < doublePlantsToGen; i++) + //{ + // // Genera il punto centrale del cluster + // int x = xo + random->nextInt(16) + 8; + // int z = zo + random->nextInt(16) + 8; + // int y = random->nextInt(Level::genDepth); + // + // int plantType = biome->getRandomDoublePlantType(random); + // + // DoublePlantFeature* dpf = static_cast(doublePlantFeature); + // dpf->setPlantType(plantType); + // + // // La chiamata place() ora genererà il grappolo grazie al ciclo da 64 inserito nel Passo 1 + // dpf->place(level, random, x, y, z); + //} + PIXEndNamedEvent(); PIXBeginNamedEvent(0,"Decorate bush/waterlily/mushroom/reeds/pumpkins/cactuses"); diff --git a/Minecraft.World/BiomeDecorator.h b/Minecraft.World/BiomeDecorator.h index 236fb0f7..dd70a2d1 100644 --- a/Minecraft.World/BiomeDecorator.h +++ b/Minecraft.World/BiomeDecorator.h @@ -59,6 +59,7 @@ public: Feature *tulipPinkFeature; Feature *doublePlantFeature; + int doublePlantCount; int waterlilyCount; int treeCount; int flowerCount; diff --git a/Minecraft.World/BiomeInitLayer.cpp b/Minecraft.World/BiomeInitLayer.cpp index d3c88588..a08b72b8 100644 --- a/Minecraft.World/BiomeInitLayer.cpp +++ b/Minecraft.World/BiomeInitLayer.cpp @@ -21,7 +21,7 @@ BiomeInitLayer::BiomeInitLayer(int64_t seed, shared_ptrparent, LevelType } else { - startBiomes = BiomeArray(16); + startBiomes = BiomeArray(18); startBiomes[0] = Biome::desert; startBiomes[1] = Biome::forest; startBiomes[2] = Biome::extremeHills; @@ -38,6 +38,8 @@ BiomeInitLayer::BiomeInitLayer(int64_t seed, shared_ptrparent, LevelType startBiomes[13] = Biome::birchForestHillsM; startBiomes[14] = Biome::roofedForestM; startBiomes[15] = Biome::deepOcean; + startBiomes[16] = Biome::sunflowersPlains; + startBiomes[17] = Biome::iceSpikes; } } diff --git a/Minecraft.World/BiomeSource.cpp b/Minecraft.World/BiomeSource.cpp index d0e220c8..2d8d825c 100644 --- a/Minecraft.World/BiomeSource.cpp +++ b/Minecraft.World/BiomeSource.cpp @@ -27,6 +27,8 @@ void BiomeSource::_init() playerSpawnBiomes.push_back(Biome::savanna); playerSpawnBiomes.push_back(Biome::roofedForest); playerSpawnBiomes.push_back(Biome::flowerForest); + playerSpawnBiomes.push_back(Biome::sunflowersPlains); + playerSpawnBiomes.push_back(Biome::iceSpikes); } void BiomeSource::_init(int64_t seed, LevelType *generator) diff --git a/Minecraft.World/CMakeLists.txt b/Minecraft.World/CMakeLists.txt index e397bf29..e73e38a8 100644 --- a/Minecraft.World/CMakeLists.txt +++ b/Minecraft.World/CMakeLists.txt @@ -11,7 +11,7 @@ set(MINECRAFT_WORLD_SOURCES ${SOURCES_COMMON} ) -add_library(Minecraft.World STATIC ${MINECRAFT_WORLD_SOURCES}) +add_library(Minecraft.World STATIC ${MINECRAFT_WORLD_SOURCES} "IceSpikeFeature.cpp" "IceSpikeFeature.h") target_include_directories(Minecraft.World PRIVATE diff --git a/Minecraft.World/DoublePlantFeature.cpp b/Minecraft.World/DoublePlantFeature.cpp index 265dc604..7c5a9f6f 100644 --- a/Minecraft.World/DoublePlantFeature.cpp +++ b/Minecraft.World/DoublePlantFeature.cpp @@ -11,7 +11,7 @@ DoublePlantFeature::DoublePlantFeature(bool doUpdate) void DoublePlantFeature::setPlantType(int plantType) { - m_plantType = (plantType < 1) ? 1 : plantType; + m_plantType = plantType; } bool DoublePlantFeature::place(Level* level, Random* rand, int x, int y, int z) @@ -24,8 +24,7 @@ bool DoublePlantFeature::place(Level* level, Random* rand, int x, int y, int z) int by = y + rand->nextInt(4) - rand->nextInt(4); int bz = z + rand->nextInt(8) - rand->nextInt(8); - if (by >= Level::maxBuildHeight - 1) continue; - if (by < 1) continue; + if (by >= Level::maxBuildHeight - 1 || by < 1) continue; if (level->getTile(bx, by, bz) != 0) continue; if (level->getTile(bx, by + 1, bz) != 0) continue; @@ -33,8 +32,9 @@ bool DoublePlantFeature::place(Level* level, Random* rand, int x, int y, int z) if (!static_cast(Tile::tiles[Tile::tallgrass2_Id])->mayPlace(level, bx, by, bz)) continue; - level->setTileAndData(bx, by, bz, Tile::tallgrass2_Id, m_plantType, Tile::UPDATE_ALL); - level->setTileAndData(bx, by + 1, bz, Tile::tallgrass2_Id, m_plantType | TallGrass2::UPPER_BIT, Tile::UPDATE_ALL); + + level->setTileAndData(bx, by, bz, Tile::tallgrass2_Id, m_plantType, 0); + level->setTileAndData(bx, by + 1, bz, Tile::tallgrass2_Id, TallGrass2::UPPER_BIT | m_plantType, 0); placed = true; } diff --git a/Minecraft.World/ExtremeHillsBiome.cpp b/Minecraft.World/ExtremeHillsBiome.cpp index 26d97dd4..658da319 100644 --- a/Minecraft.World/ExtremeHillsBiome.cpp +++ b/Minecraft.World/ExtremeHillsBiome.cpp @@ -3,16 +3,37 @@ #include "net.minecraft.world.level.tile.h" #include "net.minecraft.world.level.levelgen.feature.h" #include "ExtremeHillsBiome.h" +#include "BiomeDecorator.h" -ExtremeHillsBiome::ExtremeHillsBiome(int id) : Biome(id) +#include "SpruceFeature.h" +#include "TreeFeature.h" + +ExtremeHillsBiome::ExtremeHillsBiome(int id, bool extraTrees) : Biome(id) { silverfishFeature = new OreFeature(Tile::monsterStoneEgg_Id, 8); + taigaFeature = new SpruceFeature(false); friendlies.clear(); + type = 0; + if (extraTrees) + { + decorator->treeCount = 3; + type = 1; + } } ExtremeHillsBiome::~ExtremeHillsBiome() { delete silverfishFeature; + delete taigaFeature; +} + +Feature *ExtremeHillsBiome::getTreeFeature(Random *random) +{ + if (random->nextInt(3) > 0) + { + return new SpruceFeature(false); + } + return Biome::getTreeFeature(random); } void ExtremeHillsBiome::decorate(Level *level, Random *random, int xo, int zo) { @@ -37,8 +58,37 @@ void ExtremeHillsBiome::decorate(Level *level, Random *random, int xo, int zo) { for (int i = 0; i < 7; i++) { int x = xo + random->nextInt(16); - int y = random->nextInt(Level::genDepth / 2); + int y = random->nextInt(64); int z = zo + random->nextInt(16); silverfishFeature->place(level, random, x, y, z); } } + +void ExtremeHillsBiome::buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlocks, int x, int z, double noiseVal) +{ + topMaterial = static_cast(Tile::grass_Id); + material = static_cast(Tile::dirt_Id); + + if ((noiseVal < -1.0 || noiseVal > 2.0) && type == 2) + { + topMaterial = static_cast(Tile::gravel_Id); + material = static_cast(Tile::gravel_Id); + } + else if (noiseVal > 1.0 && type != 1) + { + topMaterial = static_cast(Tile::stone_Id); + material = static_cast(Tile::stone_Id); + } + + Biome::buildSurfaceAtDefault(level, random, chunkBlocks, x, z, noiseVal); +} + +Biome* ExtremeHillsBiome::mutateHills(Biome* baseBiome) +{ + this->type = 2; // Mutated type + this->setColor(baseBiome->color, true); + this->setName(baseBiome->m_name + L" M"); + this->setDepthAndScale(baseBiome->depth, baseBiome->scale); + this->setTemperatureAndDownfall(baseBiome->temperature, baseBiome->downfall); + return this; +} diff --git a/Minecraft.World/ExtremeHillsBiome.h b/Minecraft.World/ExtremeHillsBiome.h index cf9edabc..3fd57d12 100644 --- a/Minecraft.World/ExtremeHillsBiome.h +++ b/Minecraft.World/ExtremeHillsBiome.h @@ -8,11 +8,16 @@ class ExtremeHillsBiome : public Biome private: static const bool GENERATE_EMERALD_ORE = true; Feature *silverfishFeature; + int type; + Feature *taigaFeature; protected: - ExtremeHillsBiome(int id); + ExtremeHillsBiome(int id, bool extraTrees = false); ~ExtremeHillsBiome(); public: - void decorate(Level *level, Random *random, int xo, int zo); + virtual void decorate(Level *level, Random *random, int xo, int zo) override; + virtual void buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlocks, int x, int z, double noiseVal) override; + virtual Feature *getTreeFeature(Random *random) override; + Biome* mutateHills(Biome* baseBiome); }; \ No newline at end of file diff --git a/Minecraft.World/FixedBiomeSource.cpp b/Minecraft.World/FixedBiomeSource.cpp index 2657bdb4..b5a04f8a 100644 --- a/Minecraft.World/FixedBiomeSource.cpp +++ b/Minecraft.World/FixedBiomeSource.cpp @@ -45,7 +45,11 @@ floatArray FixedBiomeSource::getTemperatureBlock(int x, int z, int w, int h) con // 4J - note that caller is responsible for deleting returned array. temperatures array is for output only. void FixedBiomeSource::getTemperatureBlock(doubleArray& temperatures, int x, int z, int w, int h) const { - temperatures = doubleArray(w * h); + if (temperatures.data == nullptr || temperatures.length < w * h) + { + if(temperatures.data != nullptr) delete [] temperatures.data; + temperatures = doubleArray(w * h); + } Arrays::fill(temperatures, 0, w * h, (double)temperature); } @@ -86,7 +90,11 @@ void FixedBiomeSource::getDownfallBlock(doubleArray downfalls, int x, int z, int void FixedBiomeSource::getBiomeBlock(BiomeArray& biomes, int x, int z, int w, int h, bool useCache) const { MemSect(36); - biomes = BiomeArray(w * h); + if (biomes.data == nullptr || biomes.length < w * h) + { + if(biomes.data != nullptr) delete [] biomes.data; + biomes = BiomeArray(w * h); + } MemSect(0); Arrays::fill(biomes, 0, w * h, biome); @@ -96,7 +104,11 @@ void FixedBiomeSource::getBiomeBlock(BiomeArray& biomes, int x, int z, int w, in void FixedBiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z, int w, int h, bool useCache) const { MemSect(36); - biomeIndices = byteArray(w * h); + if (biomeIndices.data == nullptr || biomeIndices.length < w * h) + { + if(biomeIndices.data != nullptr) delete [] biomeIndices.data; + biomeIndices = byteArray(w * h); + } MemSect(0); int biomeIndex = biome->id; Arrays::fill(biomeIndices, 0, w * h, biomeIndex); @@ -107,7 +119,11 @@ void FixedBiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z, void FixedBiomeSource::getRawBiomeBlock(BiomeArray& biomes,int x, int z, int w, int h) const { MemSect(36); - biomes = BiomeArray(w * h); + if (biomes.data == nullptr || biomes.length < w * h) + { + if(biomes.data != nullptr) delete [] biomes.data; + biomes = BiomeArray(w * h); + } MemSect(0); Arrays::fill(biomes, 0, w * h, biome); diff --git a/Minecraft.World/ForestBiome.cpp b/Minecraft.World/ForestBiome.cpp index 8694ffb7..f7d9b2a5 100644 --- a/Minecraft.World/ForestBiome.cpp +++ b/Minecraft.World/ForestBiome.cpp @@ -9,6 +9,7 @@ #include "Rose.h" #include "HugeMushroomFeature.h" #include "DoublePlantFeature.h" +#include "TallGrass2.h" #include "../Minecraft.Client/Minecraft.h" #include "../Minecraft.Client/Common/Colours/ColourTable.h" #include "Level.h" @@ -175,10 +176,13 @@ void ForestBiome::decorate(Level* level, Random* rand, int xo, int zo) { do { - int plantType = rand->nextInt(3); + int l1 = rand->nextInt(3); DoublePlantFeature plantFeature; + if (l1 == 0) plantFeature.setPlantType(TallGrass2::LILAC); + else if (l1 == 1) plantFeature.setPlantType(TallGrass2::ROSE_BUSH); + else if (l1 == 2) plantFeature.setPlantType(TallGrass2::PEONY); - for (int attempts = 2; attempts >= 0; --attempts) + for (int attempts = 0; attempts < 5; ++attempts) { int dx = rand->nextInt(16) + 8; int dz = rand->nextInt(16) + 8; diff --git a/Minecraft.World/IceBiome.cpp b/Minecraft.World/IceBiome.cpp index 3156d869..6996e0b9 100644 --- a/Minecraft.World/IceBiome.cpp +++ b/Minecraft.World/IceBiome.cpp @@ -1,6 +1,39 @@ #include "stdafx.h" #include "IceBiome.h" +#include "net.minecraft.world.level.tile.h" +#include "IceSpikeFeature.h" +#include "SpruceFeature.h" +#include "Level.h" +#include "Random.h" -IceBiome::IceBiome(int id) : Biome(id) +IceBiome::IceBiome(int id, bool isSpikes) : Biome(id) { -}; \ No newline at end of file + this->isSpikes = isSpikes; + if (isSpikes) + { + topMaterial = static_cast(Tile::snow_Id); + } + friendlies.clear(); +} + +void IceBiome::decorate(Level *level, Random *random, int xo, int zo) +{ + if (this->isSpikes) + { + IceSpikeFeature iceSpikeFeature; + for (int i = 0; i < 3; ++i) + { + int j = random->nextInt(16) + 8; + int k = random->nextInt(16) + 8; + int y = level->getHeightmap(xo + j, zo + k); + + iceSpikeFeature.place(level, random, xo + j, y, zo + k); + } + } + Biome::decorate(level, random, xo, zo); +} + +Feature* IceBiome::getTreeFeature(Random* random) +{ + return new SpruceFeature(false); +} \ No newline at end of file diff --git a/Minecraft.World/IceBiome.h b/Minecraft.World/IceBiome.h index 306ba14f..c46a097a 100644 --- a/Minecraft.World/IceBiome.h +++ b/Minecraft.World/IceBiome.h @@ -3,6 +3,10 @@ class IceBiome : public Biome { +private: + bool isSpikes; public: - IceBiome(int id); + IceBiome(int id, bool isSpikes = false); + virtual void decorate(Level *level, Random *random, int xo, int zo) override; + virtual Feature* getTreeFeature(Random* random) override; }; \ No newline at end of file diff --git a/Minecraft.World/IceSpikeFeature.cpp b/Minecraft.World/IceSpikeFeature.cpp new file mode 100644 index 00000000..87c6a016 --- /dev/null +++ b/Minecraft.World/IceSpikeFeature.cpp @@ -0,0 +1,111 @@ +#include "IceSpikeFeature.h" +#include +#include "Level.h" +#include "Tile.h" +#include + +IceSpikeFeature::IceSpikeFeature() {} + +bool IceSpikeFeature::place(Level *level, Random *random, int x, int y, int z) +{ + + while (level->isEmptyTile(x, y, z) && y > 2) + { + y--; + } + + + if (level->getTile(x, y, z) != Tile::snow_Id) + { + return false; + } + + y += random->nextInt(4); + int height = random->nextInt(4) + 7; + int baseRadius = height / 4 + random->nextInt(2); + + + if (baseRadius > 1 && random->nextInt(60) == 0) + { + y += 10 + random->nextInt(30); + } + + + for (int k = 0; k < height; ++k) + { + + float f = (1.0F - (float)k / (float)height) * (float)baseRadius; + int l = ceil(f); + + for (int ix = -l; ix <= l; ++ix) + { + float f1 = (float)abs(ix) - 0.25F; + for (int iz = -l; iz <= l; ++iz) + { + float f2 = (float)abs(iz) - 0.25F; + + + if ((ix == 0 && iz == 0 || f1 * f1 + f2 * f2 <= f * f) && + (ix != -l && ix != l && iz != -l && iz != l || random->nextFloat() <= 0.75F)) + { + int currentTile = level->getTile(x + ix, y + k, z + iz); + + + if (level->isEmptyTile(x + ix, y + k, z + iz) || currentTile == Tile::dirt_Id || + currentTile == Tile::snow_Id || currentTile == Tile::ice_Id) + { + level->setTileAndData(x + ix, y + k, z + iz, Tile::packedIce_Id, 0, 3); + } + + + if (k != 0 && l > 1) + { + currentTile = level->getTile(x + ix, y - k, z + iz); + if (level->isEmptyTile(x + ix, y - k, z + iz) || currentTile == Tile::dirt_Id || + currentTile == Tile::snow_Id || currentTile == Tile::ice_Id) + { + level->setTileAndData(x + ix, y - k, z + iz, Tile::packedIce_Id, 0, 3); + } + } + } + } + } + } + + + int rootRadius = baseRadius - 1; + if (rootRadius < 0) rootRadius = 0; + else if (rootRadius > 1) rootRadius = 1; + + for (int rx = -rootRadius; rx <= rootRadius; ++rx) + { + for (int rz = -rootRadius; rz <= rootRadius; ++rz) + { + int curY = y - 1; + int depthCounter = 50; + + if (abs(rx) == 1 && abs(rz) == 1) depthCounter = random->nextInt(5); + + while (curY > 50) + { + int t = level->getTile(x + rx, curY, z + rz); + if (!level->isEmptyTile(x + rx, curY, z + rz) && t != Tile::dirt_Id && + t != Tile::snow_Id && t != Tile::ice_Id && t != Tile::packedIce_Id) + { + break; + } + + level->setTileAndData(x + rx, curY, z + rz, Tile::packedIce_Id, 0, 3); + curY--; + depthCounter--; + if (depthCounter <= 0) + { + curY -= (random->nextInt(5) + 1); + depthCounter = random->nextInt(5); + } + } + } + } + + return true; +} \ No newline at end of file diff --git a/Minecraft.World/IceSpikeFeature.h b/Minecraft.World/IceSpikeFeature.h new file mode 100644 index 00000000..9511a858 --- /dev/null +++ b/Minecraft.World/IceSpikeFeature.h @@ -0,0 +1,10 @@ +#pragma once +#include "Feature.h" + +class IceSpikeFeature : public Feature +{ +public: + IceSpikeFeature(); + + virtual bool place(Level *level, Random *random, int x, int y, int z) override; +}; \ No newline at end of file diff --git a/Minecraft.World/JungleBiome.cpp b/Minecraft.World/JungleBiome.cpp index 9864eb82..bd187340 100644 --- a/Minecraft.World/JungleBiome.cpp +++ b/Minecraft.World/JungleBiome.cpp @@ -6,14 +6,23 @@ #include "net.minecraft.world.entity.animal.h" #include "JungleBiome.h" - JungleBiome::JungleBiome(int id) : Biome(id) + JungleBiome::JungleBiome(int id, bool isEdge) : Biome(id) { - decorator->treeCount = 50; + this->isEdge = isEdge; + + if (isEdge) + { + decorator->treeCount = 2; + } + else + { + decorator->treeCount = 50; + enemies.push_back(new MobSpawnerData(eTYPE_OCELOT, 2, 1, 1)); + } + decorator->grassCount = 25; decorator->flowerCount = 4; - enemies.push_back(new MobSpawnerData(eTYPE_OCELOT, 2, 1, 1)); - // make chicken a lot more common in the jungle friendlies.push_back(new MobSpawnerData(eTYPE_CHICKEN, 10, 4, 4)); } @@ -23,13 +32,13 @@ { if (random->nextInt(10) == 0) { - return new BasicTree(false); // 4J used to return member fancyTree, now returning newly created object so that caller can be consistently resposible for cleanup + return new BasicTree(false); } if (random->nextInt(2) == 0) { - return new GroundBushFeature(TreeTile::JUNGLE_TRUNK, LeafTile::NORMAL_LEAF); + return new GroundBushFeature(TreeTile::JUNGLE_TRUNK, LeafTile::NORMAL_LEAF); // Shrub } - if (random->nextInt(3) == 0) + if (!this->isEdge && random->nextInt(3) == 0) { return new MegaTreeFeature(false, 10 + random->nextInt(20), TreeTile::JUNGLE_TRUNK, LeafTile::JUNGLE_LEAF); } @@ -52,12 +61,13 @@ PIXBeginNamedEvent(0, "Adding vines"); VinesFeature *vines = new VinesFeature(); - for (int i = 0; i < 50; i++) + for (int j = 0; j < 50; j++) { int x = xo + random->nextInt(16) + 8; - int y = Level::genDepth / 2; + int y2 = 128; int z = zo + random->nextInt(16) + 8; - vines->place(level, random, x, y, z); + vines->place(level, random, x, y2, z); } + delete vines; PIXEndNamedEvent(); } \ No newline at end of file diff --git a/Minecraft.World/JungleBiome.h b/Minecraft.World/JungleBiome.h index 115afb5d..e739fe3d 100644 --- a/Minecraft.World/JungleBiome.h +++ b/Minecraft.World/JungleBiome.h @@ -4,11 +4,13 @@ class JungleBiome : public Biome { +private: + bool isEdge; + public: - JungleBiome(int id); + JungleBiome(int id, bool isEdge); - - Feature *getTreeFeature(Random *random); - Feature *getGrassFeature(Random *random); - void decorate(Level *level, Random *random, int xo, int zo); + virtual Feature *getTreeFeature(Random *random) override; + virtual Feature *getGrassFeature(Random *random) override; + virtual void decorate(Level *level, Random *random, int xo, int zo) override; }; \ No newline at end of file diff --git a/Minecraft.World/MutatedBiome.cpp b/Minecraft.World/MutatedBiome.cpp index 31a24f1f..48d6a2a6 100644 --- a/Minecraft.World/MutatedBiome.cpp +++ b/Minecraft.World/MutatedBiome.cpp @@ -76,6 +76,14 @@ int MutatedBiome::getTemperatureCategory() const { return m_baseBiome ? m_baseBiome->getTemperatureCategory() : Biome::getTemperatureCategory(); } +Feature* MutatedBiome::getFlowerFeature(Random* random, int x, int y, int z) { + return m_baseBiome ? m_baseBiome->getFlowerFeature(random, x, y, z) : Biome::getFlowerFeature(random, x, y, z); +} + +int MutatedBiome::getRandomDoublePlantType(Random* random) { + return m_baseBiome ? m_baseBiome->getRandomDoublePlantType(random) : Biome::getRandomDoublePlantType(random); +} + void MutatedBiome::buildSurfaceAt(Level* level, Random* random, ChunkPrimer* primer, int x, int z, double noiseVal) { if (m_baseBiome) m_baseBiome->buildSurfaceAt(level, random, primer, x, z, noiseVal); diff --git a/Minecraft.World/MutatedBiome.h b/Minecraft.World/MutatedBiome.h index 52445802..0b75008d 100644 --- a/Minecraft.World/MutatedBiome.h +++ b/Minecraft.World/MutatedBiome.h @@ -15,6 +15,8 @@ public: virtual float getCreatureProbability() const override; virtual bool isSame(const Biome* other) const override; virtual int getTemperatureCategory() const override; + virtual Feature* getFlowerFeature(Random* random, int x, int y, int z) override; + virtual int getRandomDoublePlantType(Random* random) override; virtual void buildSurfaceAt(Level* level, Random* random, ChunkPrimer* primer, int x, int z, double noiseVal) override; Biome* getBaseBiome() const { return m_baseBiome; } // Rimosso const diff --git a/Minecraft.World/PlainsBiome.cpp b/Minecraft.World/PlainsBiome.cpp index 7d24af5b..4e562099 100644 --- a/Minecraft.World/PlainsBiome.cpp +++ b/Minecraft.World/PlainsBiome.cpp @@ -1,8 +1,12 @@ #include "stdafx.h" #include "net.minecraft.world.level.biome.h" +#include "DoublePlantFeature.h" +#include "TallGrass2.h" +#include "Level.h" -PlainsBiome::PlainsBiome(int id) : Biome(id) +PlainsBiome::PlainsBiome(int id,bool plains) : Biome(id) { + _plains = plains; friendlies.push_back(new MobSpawnerData(eTYPE_HORSE, 5, 2, 6)); friendlies.push_back(new MobSpawnerData(eTYPE_RABBIT, 4, 2, 3)); @@ -13,18 +17,73 @@ PlainsBiome::PlainsBiome(int id) : Biome(id) Feature* PlainsBiome::getFlowerFeature(Random* random, int x, int y, int z) { - int fType = random->nextInt(3); - if (fType == 0) return new FlowerFeature(Tile::rose_Id, Rose::OXEYE_DAISY); - if (fType == 1) return new FlowerFeature(Tile::rose_Id, Rose::AZURE_BLUET); - - // Tulipani (qualsiasi colore) - int tulipColor = random->nextInt(4); - switch (tulipColor) { - case 0: return new FlowerFeature(Tile::rose_Id, Rose::RED_TULIP); - case 1: return new FlowerFeature(Tile::rose_Id, Rose::ORANGE_TULIP); - case 2: return new FlowerFeature(Tile::rose_Id, Rose::WHITE_TULIP); - case 3: return new FlowerFeature(Tile::rose_Id, Rose::PINK_TULIP); - } + double d0 = GRASS_COLOR_NOISE->getValue((double)(x + 8) / 200.0,(double)(z + 8) / 200.0); + if (d0 < -0.8) + { + int j = random->nextInt(4); + switch (j) { + case 0: return new FlowerFeature(Tile::rose_Id, Rose::ORANGE_TULIP); + case 1: return new FlowerFeature(Tile::rose_Id, Rose::RED_TULIP); + case 2: return new FlowerFeature(Tile::rose_Id, Rose::PINK_TULIP); + case 3: return new FlowerFeature(Tile::rose_Id, Rose::WHITE_TULIP); + } + + }else if (random->nextInt(3) > 0) + { + int i = random->nextInt(3); + if (i == 1) { + return new FlowerFeature(Tile::rose_Id,Rose::AZURE_BLUET); + } else + return new FlowerFeature(Tile::rose_Id,Rose::OXEYE_DAISY); + + + } + else + { + return new FlowerFeature(Tile::flower_Id); + } return Biome::getFlowerFeature(random, x, y, z); +} +void PlainsBiome::decorate(Level* level, Random* rand, int xo, int zo) +{ + double d0 = GRASS_COLOR_NOISE->getValue((double)(xo + 8) / 200.0,(double)(zo + 8) / 200.0); + if (d0 < -0.8) + { + decorator->flowerCount = 15; + decorator->grassCount = 5; + } + else + { + + decorator->flowerCount = 4; + decorator->grassCount = 10; + DOUBLE_PLANT_GENERATOR->setPlantType(TallGrass2::TALL_GRASS); + + + + + + for (int i = 0; i < 7; ++i) + { + int x = xo + rand->nextInt(16) + 8; + int z = zo + rand->nextInt(16) + 8; + int y = rand->nextInt(level->getHeightmap(x, z) + 32); + DOUBLE_PLANT_GENERATOR->place(level, rand, x, y, z); + } + } + + if (_plains) + { + DOUBLE_PLANT_GENERATOR->setPlantType(TallGrass2::SUNFLOWER); + + for (int i1 = 0; i1 < 10; ++i1) + { + int j1 = rand->nextInt(16) + 8; + int k1 = rand->nextInt(16) + 8; + int l1 = rand->nextInt(level->getHeightmap(j1, k1) + 32); + DOUBLE_PLANT_GENERATOR->place(level, rand, j1, l1, k1); + } + } + Biome::decorate(level, rand, xo, zo); } \ No newline at end of file diff --git a/Minecraft.World/PlainsBiome.h b/Minecraft.World/PlainsBiome.h index 305e95c9..a7f5cc71 100644 --- a/Minecraft.World/PlainsBiome.h +++ b/Minecraft.World/PlainsBiome.h @@ -6,6 +6,11 @@ class PlainsBiome : public Biome { friend class Biome; protected: - PlainsBiome(int id); + bool _plains; +protected: + PlainsBiome(int id,bool plains); virtual Feature* getFlowerFeature(Random* random, int x, int y, int z) override; + void decorate(Level* level, Random* rand, int xo, int zo)override; + bool isPlains() { return _plains; }; + }; \ No newline at end of file diff --git a/Minecraft.World/SavannaBiome.cpp b/Minecraft.World/SavannaBiome.cpp index 8c337e4b..58cb9317 100644 --- a/Minecraft.World/SavannaBiome.cpp +++ b/Minecraft.World/SavannaBiome.cpp @@ -5,6 +5,10 @@ #include "net.minecraft.world.entity.h" #include "SavannaBiome.h" #include "SavannaTreeFeature.h" +#include "DoublePlantFeature.h" +#include "TallGrass2.h" +#include "Level.h" +#include "Random.h" SavannaBiome::SavannaBiome(int id) : Biome(id) { @@ -48,6 +52,51 @@ Feature *SavannaBiome::getFlowerFeature(Random *random, int x, int y, int z) int SavannaBiome::getRandomDoublePlantType(Random *random) { - return 0; } + +void SavannaBiome::decorate(Level *level, Random *random, int xo, int zo) +{ + DOUBLE_PLANT_GENERATOR->setPlantType(TallGrass2::TALL_GRASS); + + for (int i = 0; i < 7; ++i) + { + int x = xo + random->nextInt(16) + 8; + int z = zo + random->nextInt(16) + 8; + int y = random->nextInt(level->getHeightmap(x, z) + 32); + DOUBLE_PLANT_GENERATOR->place(level, random, x, y, z); + } + + Biome::decorate(level, random, xo, zo); +} + +MutatedSavannaBiome::MutatedSavannaBiome(int id, Biome* baseBiome) : MutatedBiome(id, baseBiome) +{ + decorator->treeCount = 2; + decorator->flowerCount = 2; + decorator->grassCount = 5; +} + +void MutatedSavannaBiome::buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlocks, int x, int z, double noiseVal) +{ + topMaterial = static_cast(Tile::grass_Id); + material = static_cast(Tile::dirt_Id); + + if (noiseVal > 1.75) + { + topMaterial = static_cast(Tile::stone_Id); + material = static_cast(Tile::stone_Id); + } + else if (noiseVal > -0.5) + { + topMaterial = static_cast(Tile::dirt_Id); + material = static_cast(Tile::dirt_Id); + } + + Biome::buildSurfaceAtDefault(level, random, chunkBlocks, x, z, noiseVal); +} + +void MutatedSavannaBiome::decorate(Level *level, Random *random, int xo, int zo) +{ + MutatedBiome::decorate(level, random, xo, zo); +} diff --git a/Minecraft.World/SavannaBiome.h b/Minecraft.World/SavannaBiome.h index 6de306a2..5d8f3ab5 100644 --- a/Minecraft.World/SavannaBiome.h +++ b/Minecraft.World/SavannaBiome.h @@ -1,5 +1,6 @@ #pragma once #include "Biome.h" +#include "MutatedBiome.h" class SavannaBiome : public Biome { @@ -12,4 +13,14 @@ public: //virtual int getWaterColor() override; virtual Feature *getFlowerFeature(Random *random, int x, int y, int z) override; virtual int getRandomDoublePlantType(Random *random) override; + virtual void decorate(Level *level, Random *random, int xo, int zo) override; +}; + +class MutatedSavannaBiome : public MutatedBiome +{ +public: + MutatedSavannaBiome(int id, Biome* baseBiome); + + virtual void buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlocks, int x, int z, double noiseVal) override; + virtual void decorate(Level *level, Random *random, int xo, int zo) override; }; \ No newline at end of file diff --git a/Minecraft.World/SwampBiome.cpp b/Minecraft.World/SwampBiome.cpp index 33403d90..be229aa6 100644 --- a/Minecraft.World/SwampBiome.cpp +++ b/Minecraft.World/SwampBiome.cpp @@ -2,26 +2,58 @@ #include "net.minecraft.world.level.h" #include "net.minecraft.world.level.biome.h" #include "SwampTreeFeature.h" +#include "net.minecraft.world.level.tile.h" +#include "PerlinNoise.h" SwampBiome::SwampBiome(int id) : Biome(id) { decorator->treeCount = 2; - decorator->flowerCount = -999; + decorator->flowerCount = 1; decorator->deadBushCount = 1; decorator->mushroomCount = 8; decorator->reedsCount = 10; decorator->clayCount = 1; decorator->waterlilyCount = 4; + decorator->sandCount = 0; + decorator->grassCount = 5; - // waterColor = 0xe0ffae; - enemies.push_back(new MobSpawnerData(eTYPE_SLIME, 1, 1, 1)); } Feature *SwampBiome::getTreeFeature(Random *random) { - return new SwampTreeFeature(); // 4J used to return member swampTree, now returning newly created object so that caller can be consistently resposible for cleanup + return new SwampTreeFeature(); +} + +void SwampBiome::buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlocks, int x, int z, double noiseVal) +{ + double d0 = GRASS_COLOR_NOISE->getValue(x * 0.25, z * 0.25); + + if (d0 > 0.0) + { + int localX = x & 15; + int localZ = z & 15; + + for (int y = 255; y >= 0; --y) + { + int index = (localX * 16 + localZ) * 256 + y; + if (chunkBlocks[index] != 0) + { + if (y == 62 && chunkBlocks[index] != static_cast(Tile::water_Id)) + { + chunkBlocks[index] = static_cast(Tile::water_Id); + if (d0 < 0.12) + { + chunkBlocks[index + 1] = static_cast(Tile::waterLily_Id); + } + } + break; + } + } + } + + Biome::buildSurfaceAtDefault(level, random, chunkBlocks, x, z, noiseVal); } // 4J Stu - Not using these any more diff --git a/Minecraft.World/SwampBiome.h b/Minecraft.World/SwampBiome.h index 0d6483bd..7108602c 100644 --- a/Minecraft.World/SwampBiome.h +++ b/Minecraft.World/SwampBiome.h @@ -14,6 +14,7 @@ public: public: virtual Feature *getTreeFeature(Random *random); + virtual void buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlocks, int x, int z, double noiseVal) override; virtual Feature* getFlowerFeature(Random* random, int x, int y, int z) override{return new FlowerFeature(Tile::rose_Id, Rose::BLUE_ORCHID);} // 4J Stu - Not using these any more //virtual int getGrassColor(); diff --git a/Minecraft.World/TaigaBiome.cpp b/Minecraft.World/TaigaBiome.cpp index dea881e0..8c940ab7 100644 --- a/Minecraft.World/TaigaBiome.cpp +++ b/Minecraft.World/TaigaBiome.cpp @@ -4,20 +4,96 @@ #include "net.minecraft.world.level.levelgen.feature.h" #include "net.minecraft.world.level.biome.h" -TaigaBiome::TaigaBiome(int id) : Biome(id) +#include "net.minecraft.world.level.tile.h" +#include "DoublePlantFeature.h" +#include "TallGrass2.h" +#include "Level.h" +#include "Random.h" + +TaigaBiome::TaigaBiome(int id, int type) : Biome(id) { + this->type = type; friendlies_wolf.push_back(new MobSpawnerData(eTYPE_WOLF, 8, 4, 4)); // 4J - moved to their own category friendlies.push_back(new MobSpawnerData(eTYPE_RABBIT, 4, 2, 3)); decorator->treeCount = 10; - decorator->grassCount = 1; + + if (type != 1 && type != 2) + { + decorator->grassCount = 1; + decorator->mushroomCount = 1; + } + else + { + decorator->grassCount = 7; + decorator->deadBushCount = 1; + decorator->mushroomCount = 3; + } } Feature *TaigaBiome::getTreeFeature(Random *random) { + if ((type == 1 || type == 2) && random->nextInt(3) == 0) + { + return new MegaTreeFeature(false, 10 + random->nextInt(20), TreeTile::SPRUCE_TRUNK, LeafTile::EVERGREEN_LEAF); + } if (random->nextInt(3) == 0) { return new PineFeature(); } return new SpruceFeature(false); +} + +void TaigaBiome::decorate(Level *level, Random *random, int xo, int zo) +{ + if (type == 1 || type == 2) + { + int count = random->nextInt(3); + for (int i = 0; i < count; ++i) + { + int x = xo + random->nextInt(16) + 8; + int z = zo + random->nextInt(16) + 8; + int y = level->getHeightmap(x, z); + + for (int dx = -1; dx <= 1; ++dx) { + for (int dy = -1; dy <= 1; ++dy) { + for (int dz = -1; dz <= 1; ++dz) { + int tileAt = level->getTile(x + dx, y + dy, z + dz); + if (random->nextInt(4) != 0 && (tileAt == 0 || tileAt == Tile::grass_Id)) { + level->setTileAndData(x + dx, y + dy, z + dz, Tile::mossyCobblestone_Id, 0, Tile::UPDATE_CLIENTS); + } + } + } + } + } + } + + DOUBLE_PLANT_GENERATOR->setPlantType(TallGrass2::LARGE_FERN); + for (int i = 0; i < 7; ++i) + { + int x = xo + random->nextInt(16) + 8; + int z = zo + random->nextInt(16) + 8; + int y = random->nextInt(level->getHeightmap(x, z) + 32); + DOUBLE_PLANT_GENERATOR->place(level, random, x, y, z); + } + + Biome::decorate(level, random, xo, zo); +} + +void TaigaBiome::buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlocks, int x, int z, double noiseVal) +{ + if (type == 1 || type == 2) + { + topMaterial = static_cast(Tile::grass_Id); + material = static_cast(Tile::dirt_Id); + if (noiseVal > 1.75) + { + topMaterial = static_cast(Tile::dirt_Id); + } + else if (noiseVal > -0.95) + { + topMaterial = static_cast(Tile::dirt_Id); + } + } + Biome::buildSurfaceAtDefault(level, random, chunkBlocks, x, z, noiseVal); } \ No newline at end of file diff --git a/Minecraft.World/TaigaBiome.h b/Minecraft.World/TaigaBiome.h index 8250fab1..133b08c9 100644 --- a/Minecraft.World/TaigaBiome.h +++ b/Minecraft.World/TaigaBiome.h @@ -3,8 +3,12 @@ class TaigaBiome : public Biome { +private: + int type; public: - TaigaBiome(int id); + TaigaBiome(int id, int type = 0); - virtual Feature *getTreeFeature(Random *random); + virtual Feature *getTreeFeature(Random *random) override; + virtual void decorate(Level *level, Random *random, int xo, int zo) override; + virtual void buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlocks, int x, int z, double noiseVal) override; }; \ No newline at end of file diff --git a/Minecraft.World/Tile.cpp b/Minecraft.World/Tile.cpp index 7709d8b4..4082f811 100644 --- a/Minecraft.World/Tile.cpp +++ b/Minecraft.World/Tile.cpp @@ -259,7 +259,7 @@ Tile* Tile::prismarine = nullptr; Tile* Tile::tree2Trunk = nullptr; -Tile* Tile::packed_ice = nullptr; +Tile* Tile::packedIce = nullptr; TallGrass2* Tile::tallgrass2 = nullptr; @@ -520,7 +520,7 @@ void Tile::staticCtor() Tile::coalBlock = (new Tile(173, Material::stone)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_coal)->setDestroyTime(5.0f)->setExplodeable(10)->setSoundType(SOUND_STONE)->setIconName(L"coal_block")->setDescriptionId(IDS_TILE_COAL)->setUseDescriptionId(IDS_DESC_COAL_BLOCK); // - Tile::packed_ice = (new PackedIceTile(174))->setDestroyTime(0.5f)->setSoundType(SOUND_GLASS)->setIconName(L"packed_ice")->setDescriptionId(IDS_TILE_PACKED_ICE)->setUseDescriptionId(IDS_DESC_PACKED_ICE); + Tile::packedIce = (new PackedIceTile(174))->setDestroyTime(0.5f)->setSoundType(SOUND_GLASS)->setIconName(L"packed_ice")->setDescriptionId(IDS_TILE_PACKED_ICE)->setUseDescriptionId(IDS_DESC_PACKED_ICE); Tile::invertedDaylightDetector = static_cast((new DaylightDetectorTile(178, true))->setDestroyTime(0.2f)->setSoundType(SOUND_WOOD)->setIconName(L"daylight_detector")->setDescriptionId(IDS_TILE_DAYLIGHT_DETECTOR)->setUseDescriptionId(IDS_DESC_DAYLIGHT_DETECTOR)); Tile::red_sandstone = (new RedSandStoneTile(179))->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_sand)->setSoundType(Tile::SOUND_STONE)->setDestroyTime(0.8f)->sendTileData()->setIconName(L"red_sandstone")->setDescriptionId(IDS_TILE_RED_SANDSTONE)->setUseDescriptionId(IDS_DESC_RED_SANDSTONE)->sendTileData(); diff --git a/Minecraft.World/Tile.h b/Minecraft.World/Tile.h index aea8b5b6..9d6c177b 100644 --- a/Minecraft.World/Tile.h +++ b/Minecraft.World/Tile.h @@ -380,7 +380,7 @@ public: static const int woolCarpet_Id = 171; static const int clayHardened_Id = 172; static const int coalBlock_Id = 173; - static const int packed_ice_Id = 174; + static const int packedIce_Id = 174; static const int tallgrass2_Id = 175; //176 standing_banner //177 wall_banner @@ -629,7 +629,7 @@ public: static Tile* red_sandstone; static Tile* stairs_red_sandstone; static Tile* tree2Trunk; - static Tile* packed_ice; + static Tile* packedIce; static Tile* seaLantern; static Tile* prismarine;