diff --git a/Minecraft.World/Biome.cpp b/Minecraft.World/Biome.cpp index 7adbfcae..3c0e4b2c 100644 --- a/Minecraft.World/Biome.cpp +++ b/Minecraft.World/Biome.cpp @@ -12,7 +12,7 @@ #include "PerlinNoise.h" -Biome *Biome::biomes[256]; +Biome *Biome::biomes[257]; Biome *Biome::ocean = nullptr;//0 Biome *Biome::plains = nullptr;//1 @@ -120,6 +120,8 @@ void Biome::staticCtor() Biome::coldTaigaHills = (new TaigaBiome(31))->setColor(0x163933)->setName(L"Cold Taiga Hills")->setLeafColor(0x4EBA31)->setSnowCovered()->setTemperatureAndDownfall(-0.5f, 0.4f)->setDepthAndScale(0.3f, 0.8f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_TaigaHills, eMinecraftColour_Foliage_TaigaHills, eMinecraftColour_Water_TaigaHills,eMinecraftColour_Sky_TaigaHills); Biome::megaTaiga = (new TaigaBiome(32,1))->setColor(0x0b6659)->setName(L"Mega Taiga")->setLeafColor(0x4EBA31)->setTemperatureAndDownfall(0.3f, 0.8f)->setDepthAndScale(0.1f, 0.4f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Taiga, eMinecraftColour_Foliage_Taiga, eMinecraftColour_Water_Taiga,eMinecraftColour_Sky_Taiga); Biome::megaTaigaHills = (new TaigaBiome(33,2))->setColor(0x0b6659)->setName(L"Mega Taiga Hills")->setLeafColor(0x4EBA31)->setTemperatureAndDownfall(0.3f, 0.8f)->setDepthAndScale(0.3f, 0.8f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_TaigaHills, eMinecraftColour_Foliage_TaigaHills, eMinecraftColour_Water_TaigaHills,eMinecraftColour_Sky_TaigaHills); + Biome::extremeHills_plus = (new ExtremeHillsBiome(34, true))->setColor(0x507050)->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); + 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::savannaPlateau = (new SavannaBiome(36))->setColor(0xa79d64)->setName(L"Savanna Plateau")->setNoRain()->setTemperatureAndDownfall(1.0f, 0.0f)->setDepthAndScale(1.5f, 0.025f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Savanna, eMinecraftColour_Foliage_Savanna, eMinecraftColour_Sky_Desert, eMinecraftColour_Sky_Desert); @@ -128,12 +130,13 @@ void Biome::staticCtor() Biome::mesaPlateau = (new MesaBiome(39, true, false))->setColor(0xca5936)->setName(L"Mesa Plateau")->setDepthAndScale(1.5f, 0.025f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Mesa, eMinecraftColour_Foliage_Mesa, eMinecraftColour_Water_Mesa, eMinecraftColour_Sky_Desert); 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::extremeHillsM = static_cast(Biome::biomes[3])->createMutatedBiome(131); Biome::flowerForest = (new ForestBiome(132, 1))->setColor(0x056621)->setName(L"Flower Forest")->setTemperatureAndDownfall(0.7f, 0.8f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Forest, eMinecraftColour_Foliage_Forest, eMinecraftColour_Water_Forest,eMinecraftColour_Sky_Forest); Biome::iceSpikes = (new IceBiome(140,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::birchForestM=(new ForestBiome::MutatedBirchForestBiome(155, biomes[27]))->setColor(0x47875a)->setName(L"Birch Forest M")->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Forest, eMinecraftColour_Foliage_Birch, eMinecraftColour_Water_Forest, eMinecraftColour_Sky_Forest); Biome::birchForestHillsM=(new ForestBiome::MutatedBirchForestBiome(156, biomes[28]))->setColor(0x47875a)->setName(L"Birch Forest Hills M")->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_ForestHills, eMinecraftColour_Foliage_Birch, eMinecraftColour_Water_Forest, eMinecraftColour_Sky_ForestHills); Biome::roofedForestM=(new ForestBiome::MutatedForestBiome(157, biomes[29]))->setColor(0x177a35)->setName(L"Roofed Forest M")->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_RoofedForest, eMinecraftColour_Foliage_RoofedForest, eMinecraftColour_Water_Forest, eMinecraftColour_Sky_Forest); - + Biome::extremeHills_plusM = static_cast(Biome::biomes[34])->createMutatedBiome(162); Biome::savannaM = (new MutatedSavannaBiome(163, biomes[35]))->setColor(0xe5da87)->setName(L"Savanna M")->setNoRain()->setTemperatureAndDownfall(1.1f, 0.0f)->setDepthAndScale(0.35f, 1.3f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Savanna, eMinecraftColour_Foliage_Savanna, eMinecraftColour_Sky_Desert, eMinecraftColour_Sky_Desert); Biome::savannaPlateauM = (new MutatedSavannaBiome(164, biomes[36]))->setColor(0xd1c890)->setName(L"Savanna Plateau M")->setNoRain()->setTemperatureAndDownfall(1.0f, 0.0f)->setDepthAndScale(1.05f, 1.2125f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Savanna, eMinecraftColour_Foliage_Savanna, eMinecraftColour_Sky_Desert, eMinecraftColour_Sky_Desert); @@ -382,28 +385,31 @@ float Biome::getTemperature(int x, int y, int z) void Biome::buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlocks, int x, int z, double noiseVal) { byte topState = this->topMaterial; + byte topStateData = this->topMaterialData; byte fillerState = this->material; - + byte fillerStateData = this->materialData; + int runDepth = -1; int noiseDepth = (int)(noiseVal / 3.0 + 3.0 + random->nextDouble() * 0.25); int localX = x & 15; int localZ = z & 15; - int seaLevel = level->seaLevel; - for (int y = Level::genDepthMinusOne; y >= 0; --y) + + const int SEA_LEVEL = 63; + + for (int y = 127; y >= 0; --y) { - int index = (localZ * 16 + localX) * Level::genDepth + y; - if (y <= 1 + random->nextInt(2)) + if (y <= 1 + random->nextInt(2)) { - chunkBlocks[index] = static_cast(Tile::unbreakable_Id); + chunkBlocks[index] = static_cast(Tile::unbreakable_Id); continue; } byte currentBlockId = chunkBlocks[index]; - if (currentBlockId == 0) + if (currentBlockId == 0) { runDepth = -1; } @@ -413,34 +419,41 @@ void Biome::buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlock { if (noiseDepth <= 0) { - topState = 0; + topState = 0; + topStateData = 0; fillerState = static_cast(Tile::stone_Id); + fillerStateData = 0; } - else if (y >= seaLevel - 4 && y <= seaLevel + 1) + else if (y < 6) { topState = this->topMaterial; + topStateData = this->topMaterialData; fillerState = this->material; + fillerStateData = this->materialData; } - if (y < seaLevel && topState == 0) + if (y < SEA_LEVEL && topState == 0) { - if (this->getTemperature(x, y, z) < 0.15f) { + if (this->getTemperature(x, y, z) < 0.15f) topState = static_cast(Tile::ice_Id); - } else { - topState = static_cast(Tile::calmWater_Id); - } + else + topState = static_cast(Tile::calmWater_Id); + topStateData = 0; } runDepth = noiseDepth; - if (y >= seaLevel - 1) + if (y >= SEA_LEVEL - 1) { chunkBlocks[index] = topState; + } - else if (y < seaLevel - 7 - noiseDepth) + else if (y < SEA_LEVEL - 7 - noiseDepth) { topState = 0; + topStateData = 0; fillerState = static_cast(Tile::stone_Id); + fillerStateData = 0; chunkBlocks[index] = static_cast(Tile::gravel_Id); } else @@ -455,8 +468,10 @@ void Biome::buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlock if (runDepth == 0 && fillerState == static_cast(Tile::sand_Id)) { - runDepth = random->nextInt(4) + (y - 63 > 0 ? y - 63 : 0); + runDepth = random->nextInt(4) + (y > 0 ? y : 0); + fillerState = static_cast(Tile::sandStone_Id); + fillerStateData = 0; } } } diff --git a/Minecraft.World/Biome.h b/Minecraft.World/Biome.h index 63269e89..ed6e766f 100644 --- a/Minecraft.World/Biome.h +++ b/Minecraft.World/Biome.h @@ -27,7 +27,7 @@ class Biome public: static void staticCtor(); - static Biome *biomes[256]; + static Biome *biomes[257]; static Biome *ocean; static Biome *plains; diff --git a/Minecraft.World/BiomeInitLayer.cpp b/Minecraft.World/BiomeInitLayer.cpp index bdba2915..8616725f 100644 --- a/Minecraft.World/BiomeInitLayer.cpp +++ b/Minecraft.World/BiomeInitLayer.cpp @@ -60,7 +60,7 @@ BiomeInitLayer::BiomeInitLayer(int64_t seed, shared_ptr parent, int64_t s icyBiomes[3] = Biome::coldTaiga; - if (levelType != LevelType::lvl_normal_1_1 && levelType == LevelType::lvl_flat) + if (levelType != LevelType::lvl_normal_1_1 && levelType == LevelType::lvl_customized) { this->customSettings = (CustomizableSourceSettings*)superflatConfig; } diff --git a/Minecraft.World/ExtremeHillsBiome.cpp b/Minecraft.World/ExtremeHillsBiome.cpp index d5c05244..2e517ad2 100644 --- a/Minecraft.World/ExtremeHillsBiome.cpp +++ b/Minecraft.World/ExtremeHillsBiome.cpp @@ -1,85 +1,98 @@ + #include "stdafx.h" #include "net.minecraft.world.level.h" #include "net.minecraft.world.level.tile.h" #include "net.minecraft.world.level.levelgen.feature.h" #include "ExtremeHillsBiome.h" #include "BiomeDecorator.h" - #include "SpruceFeature.h" #include "TreeFeature.h" +ExtremeHillsBiome::ExtremeHillsBiome(int id) : ExtremeHillsBiome(id, false) +{ +} + 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; - } + + silverfishFeature = new OreFeature(Tile::monsterStoneEgg_Id, 9); + + taigaFeature = new SpruceFeature(false); + + friendlies.clear(); + type = TYPE_NORMAL; + + if (extraTrees) + { + decorator->treeCount = 3; + type = TYPE_TREES; + } } ExtremeHillsBiome::~ExtremeHillsBiome() { - delete silverfishFeature; - delete taigaFeature; + delete silverfishFeature; + delete taigaFeature; } -Feature *ExtremeHillsBiome::getTreeFeature(Random *random) +Feature* ExtremeHillsBiome::getTreeFeature(Random* random) { - if (random->nextInt(3) > 0) - { - return new SpruceFeature(false); - } - return Biome::getTreeFeature(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) { - Biome::decorate(level, random, xo, zo); - - if (GENERATE_EMERALD_ORE) - { - int emeraldCount = 3 + random->nextInt(6); - for (int d = 0; d < emeraldCount; d++) - { - int x = xo + random->nextInt(16); - int y = random->nextInt((Level::genDepth / 4) - 4) + 4; - int z = zo + random->nextInt(16); - int tile = level->getTile(x, y, z); - if (tile == Tile::stone_Id) - { - level->setTileAndData(x, y, z, Tile::emeraldOre_Id, 0, Tile::UPDATE_CLIENTS); - } - } - } - - for (int i = 0; i < 7; i++) - { - int x = xo + random->nextInt(16); - 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) +void ExtremeHillsBiome::decorate(Level* level, Random* random, int xo, int zo) { - topMaterial = static_cast(Tile::grass_Id); - material = static_cast(Tile::dirt_Id); + Biome::decorate(level, random, xo, zo); - if ((noiseVal < -1.0 || noiseVal > 2.0) && type == 2) + if (GENERATE_EMERALD_ORE) + { + int emeraldCount = 3 + random->nextInt(6); + for (int d = 0; d < emeraldCount; d++) + { + int x = xo + random->nextInt(16); + + int y = random->nextInt(28) + 4; + int z = zo + random->nextInt(16); + int tile = level->getTile(x, y, z); + if (tile == Tile::stone_Id) + { + level->setTileAndData(x, y, z, Tile::emeraldOre_Id, 0, Tile::UPDATE_CLIENTS); + } + } + } + + for (int i = 0; i < 7; i++) + { + int x = xo + random->nextInt(16); + 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); + topMaterialData = 0; + material = static_cast(Tile::dirt_Id); + materialData = 0; + + if ((noiseVal < -1.0 || noiseVal > 2.0) && type == TYPE_MUTATED) { topMaterial = static_cast(Tile::gravel_Id); - material = static_cast(Tile::gravel_Id); + material = static_cast(Tile::gravel_Id); } - else if (noiseVal > 1.0 && type != 1) + else if (noiseVal > 1.0 && type != TYPE_TREES) { - topMaterial = static_cast(Tile::stone_Id); + topMaterial = static_cast(Tile::stone_Id); topMaterialData = 0; - material = static_cast(Tile::stone_Id); - materialData = 0; + material = static_cast(Tile::stone_Id); + materialData = 0; } Biome::buildSurfaceAtDefault(level, random, chunkBlocks, x, z, noiseVal); @@ -87,10 +100,16 @@ void ExtremeHillsBiome::buildSurfaceAtDefault(Level *level, Random *random, byte 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; + this->type = TYPE_MUTATED; + 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; } + + +Biome* ExtremeHillsBiome::createMutatedBiome(int id) +{ + return (new ExtremeHillsBiome(id, false))->mutateHills(this); +} \ No newline at end of file diff --git a/Minecraft.World/ExtremeHillsBiome.h b/Minecraft.World/ExtremeHillsBiome.h index 3fd57d12..cec0ef15 100644 --- a/Minecraft.World/ExtremeHillsBiome.h +++ b/Minecraft.World/ExtremeHillsBiome.h @@ -1,23 +1,32 @@ -#pragma once +#pragma once #include "Biome.h" +#include "OreFeature.h" +#include "SpruceFeature.h" class ExtremeHillsBiome : public Biome { - friend class Biome; private: - static const bool GENERATE_EMERALD_ORE = true; + static const bool GENERATE_EMERALD_ORE = true; Feature *silverfishFeature; int type; Feature *taigaFeature; -protected: - ExtremeHillsBiome(int id, bool extraTrees = false); - ~ExtremeHillsBiome(); - + static constexpr int TYPE_NORMAL = 0; + static constexpr int TYPE_TREES = 1; + static constexpr int TYPE_MUTATED = 2; public: - 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); + + ExtremeHillsBiome(int id); + + ExtremeHillsBiome(int id, bool extraTrees); + ~ExtremeHillsBiome(); + + Feature* getTreeFeature(Random* random) override; + void decorate(Level* level, Random* random, int xo, int zo) override; + void buildSurfaceAtDefault(Level* level, Random* random, byte* chunkBlocks, int x, int z, double noiseVal) override; + Biome* mutateHills(Biome* baseBiome); + Biome* createMutatedBiome(int id); + + }; \ No newline at end of file diff --git a/Minecraft.World/MutatedBiome.cpp b/Minecraft.World/MutatedBiome.cpp index e98f821d..455e52f0 100644 --- a/Minecraft.World/MutatedBiome.cpp +++ b/Minecraft.World/MutatedBiome.cpp @@ -20,7 +20,8 @@ MutatedBiome::MutatedBiome(int id, Biome* baseBiome) scale = baseBiome->scale + 0.2f; temperature = baseBiome->temperature; downfall = baseBiome->downfall; - + _hasRain = baseBiome->_hasRain; + snowCovered = baseBiome->snowCovered; friendlies = baseBiome->friendlies; enemies = baseBiome->enemies; @@ -32,15 +33,17 @@ MutatedBiome::MutatedBiome(int id, Biome* baseBiome) m_waterColor = baseBiome->m_waterColor; m_skyColor = baseBiome->m_skyColor; + m_grassColor = baseBiome->m_grassColor; + m_foliageColor = baseBiome->m_foliageColor; m_name = baseBiome->m_name + L" Mutated"; - // Copia parametri del decorator + if (decorator && baseBiome->decorator) { decorator->treeCount = baseBiome->decorator->treeCount; decorator->grassCount = baseBiome->decorator->grassCount; decorator->flowerCount = baseBiome->decorator->flowerCount; decorator->hugeMushrooms = baseBiome->decorator->hugeMushrooms; - // ... altri campi se necessari + } } diff --git a/Minecraft.World/OceanBiome.h b/Minecraft.World/OceanBiome.h index 2f27b6f9..7f590d8c 100644 --- a/Minecraft.World/OceanBiome.h +++ b/Minecraft.World/OceanBiome.h @@ -13,4 +13,8 @@ public: topMaterial = Tile::gravel_Id; // surfaceblock material = Tile::gravel_Id; } + int OceanBiome::getTemperatureCategory() const override +{ + return 0; +} }; diff --git a/Minecraft.World/SuperflatConfig.h b/Minecraft.World/SuperflatConfig.h new file mode 100644 index 00000000..3a0c2029 --- /dev/null +++ b/Minecraft.World/SuperflatConfig.h @@ -0,0 +1,8 @@ +#pragma once + +#include "ByteArrayTag.h" + +class SuperflatConfig { +public: + ByteArrayTag* toTag(); +}; \ No newline at end of file diff --git a/Minecraft.World/cmake/sources/Common.cmake b/Minecraft.World/cmake/sources/Common.cmake index 8e58801c..99f4a115 100644 --- a/Minecraft.World/cmake/sources/Common.cmake +++ b/Minecraft.World/cmake/sources/Common.cmake @@ -1451,6 +1451,7 @@ set(_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_LEVEL_LEVELGEN "${CMAKE_CURRENT_SOURCE_DIR}/TheEndLevelRandomLevelSource.h" "${CMAKE_CURRENT_SOURCE_DIR}/TownFeature.h" "${CMAKE_CURRENT_SOURCE_DIR}/net.minecraft.world.level.levelgen.h" + "${CMAKE_CURRENT_SOURCE_DIR}/SuperflatConfig.h" ) source_group("net/minecraft/world/level/levelgen" FILES ${_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_LEVEL_LEVELGEN})