From f0b06116c2b6cf8b69df5fa7a0c3d0357f822211 Mon Sep 17 00:00:00 2001 From: Lord Cambion Date: Mon, 23 Mar 2026 03:44:02 +0100 Subject: [PATCH] flower forste part 1 + decompiled roofed forest --- Minecraft.World/Biome.cpp | 376 ++++++++++-------- Minecraft.World/Biome.h | 224 +++++------ Minecraft.World/BiomeDecorator.cpp | 44 ++ Minecraft.World/BiomeDecorator.h | 9 + Minecraft.World/BiomeInitLayer.cpp | 3 +- Minecraft.World/BiomeSource.cpp | 1 + Minecraft.World/BirchFeature.cpp | 134 ++++--- Minecraft.World/BirchFeature.h | 15 +- Minecraft.World/DarkOakFeature.cpp | 143 ++++--- Minecraft.World/FlowerFeature.cpp | 57 ++- Minecraft.World/FlowerFeature.h | 10 +- Minecraft.World/ForestBiome.cpp | 90 ++++- Minecraft.World/ForestBiome.h | 14 +- Minecraft.World/Minecraft.World.vcxproj | 2 + .../Minecraft.World.vcxproj.filters | 2 + Minecraft.World/RoofedForestBiome.cpp | 20 +- Minecraft.World/StrongholdFeature.cpp | 3 + Minecraft.World/Vec3.cpp | 274 ++++++------- Minecraft.World/Vec3.h | 58 +-- Minecraft.World/Vec3i.cpp | 30 ++ Minecraft.World/Vec3i.h | 20 + ...t.minecraft.world.level.levelgen.feature.h | 2 + 22 files changed, 901 insertions(+), 630 deletions(-) create mode 100644 Minecraft.World/Vec3i.cpp create mode 100644 Minecraft.World/Vec3i.h diff --git a/Minecraft.World/Biome.cpp b/Minecraft.World/Biome.cpp index 3684f3d8..09280ff6 100644 --- a/Minecraft.World/Biome.cpp +++ b/Minecraft.World/Biome.cpp @@ -9,24 +9,20 @@ #include "net.minecraft.world.entity.h" #include "Biome.h" #include "net.minecraft.world.level.biome.h" +#include "PerlinNoise.h" -//public static final Biome[] biomes = new Biome[256]; Biome *Biome::biomes[256]; Biome *Biome::ocean = nullptr; Biome *Biome::plains = nullptr; Biome *Biome::desert = nullptr; - Biome *Biome::extremeHills = nullptr; Biome *Biome::forest = nullptr; Biome *Biome::taiga = nullptr; - Biome *Biome::swampland = nullptr; Biome *Biome::river = nullptr; - Biome *Biome::hell = nullptr; Biome *Biome::sky = nullptr; - Biome *Biome::frozenOcean = nullptr; Biome *Biome::frozenRiver = nullptr; Biome *Biome::iceFlats = nullptr; @@ -38,283 +34,333 @@ Biome *Biome::desertHills = nullptr; Biome *Biome::forestHills = nullptr; Biome *Biome::taigaHills = nullptr; Biome *Biome::smallerExtremeHills = nullptr; - Biome *Biome::jungle = nullptr; Biome *Biome::jungleHills = nullptr; - Biome *Biome::savanna = nullptr; Biome *Biome::roofedForest = nullptr; - +Biome *Biome::flowerForest = nullptr; void Biome::staticCtor() { - //public static final Biome[] biomes = new Biome[256]; - - 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::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); - Biome::forest = (new ForestBiome(4))->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); - // 4J - brought forward Taiga temperature change from 0.3f to 0.05f, from 1.2.3 - 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::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::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::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::forestHills = (new ForestBiome(18))->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::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::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::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::roofedForest = (new RoofedForestBiome(29))->setName(L"RoofedForest")->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_RoofedForest, eMinecraftColour_Foliage_RoofedForest, eMinecraftColour_Water_Forest, eMinecraftColour_Sky_Forest); - + 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::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); + 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::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::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::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::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::forestHills = (new ForestBiome(18,1))->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::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::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::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::roofedForest = (new ForestBiome(29, 3))->setColor(0x056621)->setName(L"Roofed Forest")->setTemperatureAndDownfall(0.7f, 0.8f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_RoofedForest, eMinecraftColour_Foliage_RoofedForest, eMinecraftColour_Water_Forest, eMinecraftColour_Sky_Forest); + 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::Biome(int id) : id(id) { - // 4J Stu Default inits - color = 0; - // snowCovered = false; // 4J - this isn't set by the java game any more so removing to save confusion - - topMaterial = static_cast(Tile::grass_Id); - material = static_cast(Tile::dirt_Id); - leafColor = 0x4EE031; - _hasRain = true; - depth = 0.1f; - scale = 0.3f; - temperature = 0.5f; - downfall = 0.5f; - //waterColor = 0xffffff; // 4J Stu - Not used - decorator = nullptr; - - m_grassColor = eMinecraftColour_NOT_SET; - m_foliageColor = eMinecraftColour_NOT_SET; - m_waterColor = eMinecraftColour_NOT_SET; - - /* 4J - removing these so that we can consistently return newly created trees via getTreeFeature, and let the calling function be resposible for deleting the returned tree - normalTree = new TreeFeature(); - fancyTree = new BasicTree(); - birchTree = new BirchFeature(); - swampTree = new SwampTreeFeature(); - */ - - biomes[id] = this; - decorator = createDecorator(); - - friendlies.push_back(new MobSpawnerData(eTYPE_SHEEP, 12, 4, 4)); - friendlies.push_back(new MobSpawnerData(eTYPE_PIG, 10, 4, 4)); - friendlies_chicken.push_back(new MobSpawnerData(eTYPE_CHICKEN, 10, 4, 4)); // 4J - moved chickens to their own category - friendlies.push_back(new MobSpawnerData(eTYPE_COW, 8, 4, 4)); + color = 0; + topMaterial = static_cast(Tile::grass_Id); + material = static_cast(Tile::dirt_Id); + leafColor = 0x4EE031; + _hasRain = true; + depth = 0.1f; + scale = 0.3f; + temperature = 0.5f; + downfall = 0.5f; + decorator = nullptr; + m_temperatureNoise = nullptr; - enemies.push_back(new MobSpawnerData(eTYPE_SPIDER, 10, 4, 4)); - enemies.push_back(new MobSpawnerData(eTYPE_ZOMBIE, 10, 4, 4)); - enemies.push_back(new MobSpawnerData(eTYPE_SKELETON, 10, 4, 4)); - enemies.push_back(new MobSpawnerData(eTYPE_CREEPER, 10, 4, 4)); - enemies.push_back(new MobSpawnerData(eTYPE_SLIME, 10, 4, 4)); - enemies.push_back(new MobSpawnerData(eTYPE_ENDERMAN, 1, 1, 4)); - enemies.push_back(new MobSpawnerData(eTYPE_WITCH, 1, 1, 1)); + m_grassColor = eMinecraftColour_NOT_SET; + m_foliageColor = eMinecraftColour_NOT_SET; + m_waterColor = eMinecraftColour_NOT_SET; - // wolves are added to forests and taigas + biomes[id] = this; + decorator = createDecorator(); - waterFriendlies.push_back(new MobSpawnerData(eTYPE_SQUID, 10, 4, 4)); + friendlies.push_back(new MobSpawnerData(eTYPE_SHEEP, 12, 4, 4)); + friendlies.push_back(new MobSpawnerData(eTYPE_PIG, 10, 4, 4)); + friendlies_chicken.push_back(new MobSpawnerData(eTYPE_CHICKEN, 10, 4, 4)); + friendlies.push_back(new MobSpawnerData(eTYPE_COW, 8, 4, 4)); - ambientFriendlies.push_back(new MobSpawnerData(eTYPE_BAT, 10, 8, 8)); + enemies.push_back(new MobSpawnerData(eTYPE_SPIDER, 10, 4, 4)); + enemies.push_back(new MobSpawnerData(eTYPE_ZOMBIE, 10, 4, 4)); + enemies.push_back(new MobSpawnerData(eTYPE_SKELETON, 10, 4, 4)); + enemies.push_back(new MobSpawnerData(eTYPE_CREEPER, 10, 4, 4)); + enemies.push_back(new MobSpawnerData(eTYPE_SLIME, 10, 4, 4)); + enemies.push_back(new MobSpawnerData(eTYPE_ENDERMAN, 1, 1, 4)); + enemies.push_back(new MobSpawnerData(eTYPE_WITCH, 1, 1, 1)); + + waterFriendlies.push_back(new MobSpawnerData(eTYPE_SQUID, 10, 4, 4)); + ambientFriendlies.push_back(new MobSpawnerData(eTYPE_BAT, 10, 8, 8)); } Biome::~Biome() { - if(decorator != nullptr) delete decorator; + if(decorator != nullptr) delete decorator; } BiomeDecorator *Biome::createDecorator() { - return new BiomeDecorator(this); + return new BiomeDecorator(this); } -// 4J Added Biome *Biome::setLeafFoliageWaterSkyColor(eMinecraftColour grassColor, eMinecraftColour foliageColor, eMinecraftColour waterColour, eMinecraftColour skyColour) { - m_grassColor = grassColor; - m_foliageColor = foliageColor; - m_waterColor = waterColour; - m_skyColor = skyColour; - return this; + m_grassColor = grassColor; + m_foliageColor = foliageColor; + m_waterColor = waterColour; + m_skyColor = skyColour; + return this; } Biome *Biome::setTemperatureAndDownfall(float temp, float downfall) { - temperature = temp; - this->downfall = downfall; - return this; + temperature = temp; + this->downfall = downfall; + return this; } Biome *Biome::setDepthAndScale(float depth, float scale) { - this->depth = depth; - this->scale = scale; - return this; + this->depth = depth; + this->scale = scale; + return this; } Biome *Biome::setNoRain() { - _hasRain = false; - return this; + _hasRain = false; + return this; } Feature *Biome::getTreeFeature(Random *random) { - 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 TreeFeature(false); // 4J used to return member normalTree, now returning newly created object so that caller can be consistently resposible for cleanup + if (random->nextInt(10) == 0) + { + return new BasicTree(false); + } + return new TreeFeature(false); } Feature *Biome::getGrassFeature(Random *random) { - return new TallGrassFeature(Tile::tallgrass_Id, TallGrass::TALL_GRASS); + return new TallGrassFeature(Tile::tallgrass_Id, TallGrass::TALL_GRASS); } Biome *Biome::setSnowCovered() { - snowCovered = true; - return this; + snowCovered = true; + return this; } Biome *Biome::setName(const wstring &name) { - this->m_name = name; - return this; + this->m_name = name; + return this; } Biome *Biome::setLeafColor(int leafColor) { - this->leafColor = leafColor; - return this; + this->leafColor = leafColor; + return this; } -Biome *Biome::setColor(int color) +Biome* Biome::setColor(int color, bool b) { - this->color = color; - return this; + this->color = color; + return this; } int Biome::getSkyColor(float temp) { - //temp /= 3.0f; - //if (temp < -1) temp = -1; - //if (temp > 1) temp = 1; - //return Color::getHSBColor(224 / 360.0f - temp * 0.05f, 0.50f + temp * 0.1f, 1.0f).getRGB(); - - // 4J Stu - Load colour from texture pack - return Minecraft::GetInstance()->getColourTable()->getColor( m_skyColor ); + return Minecraft::GetInstance()->getColourTable()->getColor( m_skyColor ); } vector *Biome::getMobs(MobCategory *category) { - if (category == MobCategory::monster) return &enemies; - if (category == MobCategory::creature) return &friendlies; - if (category == MobCategory::waterCreature) return &waterFriendlies; - if (category == MobCategory::creature_chicken) return &friendlies_chicken; - if (category == MobCategory::creature_wolf) return &friendlies_wolf; - if (category == MobCategory::creature_mushroomcow) return &friendlies_mushroomcow; - if (category == MobCategory::ambient) return &ambientFriendlies; - return nullptr; + if (category == MobCategory::monster) return &enemies; + if (category == MobCategory::creature) return &friendlies; + if (category == MobCategory::waterCreature) return &waterFriendlies; + if (category == MobCategory::creature_chicken) return &friendlies_chicken; + if (category == MobCategory::creature_wolf) return &friendlies_wolf; + if (category == MobCategory::creature_mushroomcow) return &friendlies_mushroomcow; + if (category == MobCategory::ambient) return &ambientFriendlies; + return nullptr; } bool Biome::hasSnow() { - // 4J - snowCovered flag removed as it wasn't being set by the game anymore - snow is now temperature dependent to match code in rain rendering, shouldFreeze functions etc. - if( !_hasRain ) return false; - - if( getTemperature() >= 0.15f ) return false; - - return true; + if( !_hasRain ) return false; + if( getTemperature() >= 0.15f ) return false; + return true; } bool Biome::hasRain() { - // 4J - snowCovered flag removed as it wasn't being set by the game anymore, replaced by call to hasSnow() - if( hasSnow() ) return false; - // if (snowCovered) return false; - return _hasRain; + if( hasSnow() ) return false; + return _hasRain; } bool Biome::isHumid() { - return downfall > .85f; + return downfall > .85f; } float Biome::getCreatureProbability() { - return 0.1f; + return 0.1f; } int Biome::getDownfallInt() { - return static_cast(downfall * 65536); + return static_cast(downfall * 65536); } int Biome::getTemperatureInt() { - return static_cast(temperature * 65536); + return static_cast(temperature * 65536); } -// 4J - brought forward from 1.2.3 float Biome::getDownfall() { - return downfall; + return downfall; } -// 4J - brought forward from 1.2.3 float Biome::getTemperature() { - return temperature; + return temperature; } void Biome::decorate(Level *level, Random *random, int xo, int zo) { - decorator->decorate(level, random, xo, zo); + decorator->decorate(level, random, xo, zo); } int Biome::getGrassColor() { - //double temp = Mth::clamp(getTemperature(), 0.0f, 1.0f); - //double rain = Mth::clamp(getDownfall(), 0.0f, 1.0f); - - //return GrassColor::get(temp, rain); - return Minecraft::GetInstance()->getColourTable()->getColor( m_grassColor ); + return Minecraft::GetInstance()->getColourTable()->getColor( m_grassColor ); } int Biome::getFolageColor() { - //double temp = Mth::clamp(getTemperature(), 0.0f, 1.0f); - //double rain = Mth::clamp(getDownfall(), 0.0f, 1.0f); - - //return FoliageColor::get(temp, rain); - return Minecraft::GetInstance()->getColourTable()->getColor( m_foliageColor ); + return Minecraft::GetInstance()->getColourTable()->getColor( m_foliageColor ); } -// 4J Added int Biome::getWaterColor() { - return Minecraft::GetInstance()->getColourTable()->getColor( m_waterColor ); + return Minecraft::GetInstance()->getColourTable()->getColor( m_waterColor ); +} + +float Biome::getTemperature(int x, int y, int z) +{ + if (y > 64) + { + float noiseTemp = 0.0f; + if (m_temperatureNoise != nullptr) + { + noiseTemp = (float)(m_temperatureNoise->getValue((double)x / 8.0, (double)z / 8.0) * 4.0); + } + return temperature - (noiseTemp + (float)(y - 64)) * 0.05f / 30.0f; + } + + return temperature; +} + +void Biome::buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlocks, int x, int z, double noiseVal) +{ + byte topState = this->topMaterial; + byte fillerState = this->material; + + int runDepth = -1; + int noiseDepth = (int)(noiseVal / 3.0 + 3.0 + random->nextDouble() * 0.25); + int localX = x & 15; + int localZ = z & 15; + + for (int y = 255; y >= 0; --y) + { + int index = (localX * 16 + localZ) * 256 + y; + + if (y <= random->nextInt(5)) + { + chunkBlocks[index] = static_cast(Tile::unbreakable_Id); + continue; + } + + byte currentBlockId = chunkBlocks[index]; + + if (currentBlockId == 0) + { + runDepth = -1; + } + else if (currentBlockId == static_cast(Tile::stone_Id)) + { + if (runDepth == -1) + { + if (noiseDepth <= 0) + { + topState = 0; + fillerState = static_cast(Tile::stone_Id); + } + else if (y >= 59 && y <= 64) + { + topState = this->topMaterial; + fillerState = this->material; + } + + if (y < 63 && topState == 0) + { + if (this->getTemperature(x, y, z) < 0.15f) { + topState = static_cast(Tile::ice_Id); + } else { + topState = static_cast(Tile::water_Id); + } + } + + runDepth = noiseDepth; + + if (y >= 62) + { + chunkBlocks[index] = topState; + } + else if (y < 56 - noiseDepth) + { + topState = 0; + fillerState = static_cast(Tile::stone_Id); + chunkBlocks[index] = static_cast(Tile::gravel_Id); + } + else + { + chunkBlocks[index] = fillerState; + } + } + else if (runDepth > 0) + { + --runDepth; + chunkBlocks[index] = fillerState; + + if (runDepth == 0 && fillerState == static_cast(Tile::sand_Id)) + { + runDepth = random->nextInt(4) + (y - 63 > 0 ? y - 63 : 0); + fillerState = static_cast(Tile::sandStone_Id); + } + } + } + } } \ No newline at end of file diff --git a/Minecraft.World/Biome.h b/Minecraft.World/Biome.h index 42f46be9..fc4f9a6f 100644 --- a/Minecraft.World/Biome.h +++ b/Minecraft.World/Biome.h @@ -13,144 +13,146 @@ class BasicTree; class BirchFeature; class SwampTreeFeature; class ChunkRebuildData; - +class PerlinNoise; class Biome { - friend class ChunkRebuildData; + friend class ChunkRebuildData; public: - // 4J JEV, replaces the static blocks. - static void staticCtor(); + static void staticCtor(); - static Biome *biomes[256]; + static Biome *biomes[256]; - static Biome *ocean; - static Biome *plains; - static Biome *desert; - static Biome *extremeHills; - static Biome *forest; - static Biome *taiga; - static Biome *swampland; - static Biome *river; - static Biome *hell; - static Biome *sky; - static Biome *frozenOcean; - static Biome *frozenRiver; - static Biome *iceFlats; - static Biome *iceMountains; - static Biome *mushroomIsland; - static Biome *mushroomIslandShore ; - static Biome *beaches; - static Biome *desertHills; - static Biome *forestHills; - static Biome *taigaHills; - static Biome *smallerExtremeHills; - static Biome *jungle; - static Biome *jungleHills; - static Biome *savanna; + static Biome *ocean; + static Biome *plains; + static Biome *desert; + static Biome *extremeHills; + static Biome *forest; + static Biome *taiga; + static Biome *swampland; + static Biome *river; + static Biome *hell; + static Biome *sky; + static Biome *frozenOcean; + static Biome *frozenRiver; + static Biome *iceFlats; + static Biome *iceMountains; + static Biome *mushroomIsland; + static Biome *mushroomIslandShore ; + static Biome *beaches; + static Biome *desertHills; + static Biome *forestHills; + static Biome *taigaHills; + static Biome *smallerExtremeHills; + static Biome *jungle; + static Biome *jungleHills; + static Biome *savanna; static Biome *roofedForest; + static Biome *flowerForest; - static const int BIOME_COUNT = 23; // 4J Stu added + static const int BIOME_COUNT = 23; // 4J Stu added public: - wstring m_name; - int color; - byte topMaterial; - byte material; - int leafColor; - float depth; - float scale; - float temperature; - float downfall; - //int waterColor; // 4J Stu removed + wstring m_name; + int color; + byte topMaterial; + byte material; + int leafColor; + float depth; + float scale; + float temperature; + float downfall; - BiomeDecorator *decorator; + BiomeDecorator *decorator; + PerlinNoise *m_temperatureNoise; - const int id; + const int id; - class MobSpawnerData : public WeighedRandomItem - { - public: - eINSTANCEOF mobClass; - int minCount; - int maxCount; + class MobSpawnerData : public WeighedRandomItem + { + public: + eINSTANCEOF mobClass; + int minCount; + int maxCount; - MobSpawnerData(eINSTANCEOF mobClass, int probabilityWeight, int minCount, int maxCount) : WeighedRandomItem(probabilityWeight) - { - this->mobClass = mobClass; - this->minCount = minCount; - this->maxCount = maxCount; - } - }; + MobSpawnerData(eINSTANCEOF mobClass, int probabilityWeight, int minCount, int maxCount) : WeighedRandomItem(probabilityWeight) + { + this->mobClass = mobClass; + this->minCount = minCount; + this->maxCount = maxCount; + } + }; protected: - vector enemies; - vector friendlies; - vector waterFriendlies; - vector friendlies_chicken; - vector friendlies_wolf; - vector friendlies_mushroomcow; - vector ambientFriendlies; + vector enemies; + vector friendlies; + vector waterFriendlies; + vector friendlies_chicken; + vector friendlies_wolf; + vector friendlies_mushroomcow; + vector ambientFriendlies; - Biome(int id); - ~Biome(); + Biome(int id); + virtual ~Biome(); - BiomeDecorator *createDecorator(); - -private: - Biome *setTemperatureAndDownfall(float temp, float downfall); - Biome *setDepthAndScale(float depth, float scale); - - bool snowCovered; - bool _hasRain; - - // 4J Added - eMinecraftColour m_grassColor; - eMinecraftColour m_foliageColor; - eMinecraftColour m_waterColor; - eMinecraftColour m_skyColor; - - Biome *setNoRain(); - -protected: - /* removing these so that we can consistently return newly created trees via getTreeFeature, and let the calling function be resposible for deleting the returned tree - TreeFeature *normalTree; - BasicTree *fancyTree; - BirchFeature *birchTree; - SwampTreeFeature *swampTree; - */ + BiomeDecorator *createDecorator(); public: - virtual Feature *getTreeFeature(Random *random); - virtual Feature *getGrassFeature(Random *random); + Biome *setTemperatureAndDownfall(float temp, float downfall); + Biome *setDepthAndScale(float depth, float scale); -protected: - Biome *setSnowCovered(); - Biome *setName(const wstring &name); - Biome *setLeafColor(int leafColor); - Biome *setColor(int color); + bool snowCovered; + bool _hasRain; - // 4J Added - Biome *setLeafFoliageWaterSkyColor(eMinecraftColour grassColor, eMinecraftColour foliageColor, eMinecraftColour waterColour, eMinecraftColour skyColour); + // 4J Added + eMinecraftColour m_grassColor; + eMinecraftColour m_foliageColor; + eMinecraftColour m_waterColor; + eMinecraftColour m_skyColor; + + Biome *setNoRain(); public: - virtual int getSkyColor(float temp); + virtual Feature *getTreeFeature(Random *random); + virtual Feature *getGrassFeature(Random *random); - vector *getMobs(MobCategory *category); +protected: + Biome *setSnowCovered(); + Biome *setName(const wstring &name); + Biome *setLeafColor(int leafColor); + + public: + + virtual Biome *setColor(int color, bool b = false); - virtual bool hasSnow(); - virtual bool hasRain(); - virtual bool isHumid(); + // 4J Added + Biome *setLeafFoliageWaterSkyColor(eMinecraftColour grassColor, eMinecraftColour foliageColor, eMinecraftColour waterColour, eMinecraftColour skyColour); - virtual float getCreatureProbability(); - virtual int getDownfallInt(); - virtual int getTemperatureInt(); - virtual float getDownfall(); // 4J - brought forward from 1.2.3 - virtual float getTemperature(); // 4J - brought forward from 1.2.3 +public: + virtual int getSkyColor(float temp); - virtual void decorate(Level *level, Random *random, int xo, int zo); + vector *getMobs(MobCategory *category); - virtual int getGrassColor(); - virtual int getFolageColor(); - virtual int getWaterColor(); // 4J Added + virtual bool hasSnow(); + virtual bool hasRain(); + virtual bool isHumid(); + + virtual float getCreatureProbability(); + virtual int getDownfallInt(); + virtual int getTemperatureInt(); + + virtual float getDownfall(); + virtual float getTemperature(); + + + virtual float getTemperature(int x, int y, int z); + + virtual void decorate(Level *level, Random *random, int xo, int zo); + + + virtual void buildSurfaceAtDefault(Level *level, Random *random, byte* chunkBlocks, int x, int z, double noiseVal); + + virtual int getGrassColor(); + virtual int getFolageColor(); + virtual int getWaterColor(); }; \ No newline at end of file diff --git a/Minecraft.World/BiomeDecorator.cpp b/Minecraft.World/BiomeDecorator.cpp index add156e8..d1f2fc44 100644 --- a/Minecraft.World/BiomeDecorator.cpp +++ b/Minecraft.World/BiomeDecorator.cpp @@ -55,12 +55,17 @@ void BiomeDecorator::_init() lapisOreFeature = new OreFeature(Tile::lapisOre_Id, 6); yellowFlowerFeature = new FlowerFeature(Tile::flower_Id); roseFlowerFeature = new FlowerFeature(Tile::rose_Id); + brownMushroomFeature = new FlowerFeature(Tile::mushroom_brown_Id); redMushroomFeature = new FlowerFeature(Tile::mushroom_red_Id); hugeMushroomFeature = new HugeMushroomFeature(); reedsFeature = new ReedsFeature(); cactusFeature = new CactusFeature(); waterlilyFeature = new WaterlilyFeature(); + blueOrchidFeature = new FlowerFeature(Tile::rose_Id, Rose::BLUE_ORCHID); + alliumFeature = new FlowerFeature(Tile::rose_Id, Rose::ALLIUM); + azureBluetFeature = new FlowerFeature(Tile::rose_Id, Rose::AZURE_BLUET); + oxeyeDaisyFeature = new FlowerFeature(Tile::rose_Id, Rose::OXEYE_DAISY); waterlilyCount = 0; treeCount = 0; @@ -74,6 +79,10 @@ void BiomeDecorator::_init() sandCount = 3; clayCount = 1; hugeMushrooms = 0; + blueOrchidCount = 0; + alliumCount = 0; + azureBluetCount = 0; + oxeyeDaisyCount = 0; liquids = true; } @@ -146,6 +155,41 @@ void BiomeDecorator::decorate() } } + + + // Nuovi fiori — generati solo se il bioma ha impostato il contatore + for (int i = 0; i < blueOrchidCount; i++) + { + int x = xo + random->nextInt(16) + 8; + int y = random->nextInt(Level::genDepth); + int z = zo + random->nextInt(16) + 8; + blueOrchidFeature->place(level, random, x, y, z); + } + + for (int i = 0; i < alliumCount; i++) + { + int x = xo + random->nextInt(16) + 8; + int y = random->nextInt(Level::genDepth); + int z = zo + random->nextInt(16) + 8; + alliumFeature->place(level, random, x, y, z); + } + + for (int i = 0; i < azureBluetCount; i++) + { + int x = xo + random->nextInt(16) + 8; + int y = random->nextInt(Level::genDepth); + int z = zo + random->nextInt(16) + 8; + azureBluetFeature->place(level, random, x, y, z); + } + + for (int i = 0; i < oxeyeDaisyCount; i++) + { + int x = xo + random->nextInt(16) + 8; + int y = random->nextInt(Level::genDepth); + int z = zo + random->nextInt(16) + 8; + oxeyeDaisyFeature->place(level, random, x, y, z); + } + for (int i = 0; i < grassCount; i++) { //int grassType = TallGrass::TALL_GRASS; diff --git a/Minecraft.World/BiomeDecorator.h b/Minecraft.World/BiomeDecorator.h index 4e6e00dd..da2777e0 100644 --- a/Minecraft.World/BiomeDecorator.h +++ b/Minecraft.World/BiomeDecorator.h @@ -17,6 +17,7 @@ class BiomeDecorator friend class SavannaBiome; friend class JungleBiome; friend class RoofedForestBiome; + friend class FlowerForestBiome; protected: Level *level; Random *random; @@ -49,6 +50,10 @@ protected: Feature *reedsFeature; Feature *cactusFeature; Feature *waterlilyFeature; + Feature *blueOrchidFeature; + Feature *alliumFeature; + Feature *azureBluetFeature; + Feature *oxeyeDaisyFeature; int waterlilyCount; int treeCount; @@ -63,6 +68,10 @@ protected: int clayCount; int hugeMushrooms; bool liquids; + int blueOrchidCount; + int alliumCount; + int azureBluetCount; + int oxeyeDaisyCount; void _init(); diff --git a/Minecraft.World/BiomeInitLayer.cpp b/Minecraft.World/BiomeInitLayer.cpp index d2ea3d66..9a78d38c 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(9); + startBiomes = BiomeArray(10); startBiomes[0] = Biome::desert; startBiomes[1] = Biome::forest; startBiomes[2] = Biome::extremeHills; @@ -31,6 +31,7 @@ BiomeInitLayer::BiomeInitLayer(int64_t seed, shared_ptrparent, LevelType startBiomes[6] = Biome::jungle; startBiomes[7] = Biome::savanna; startBiomes[8] = Biome::roofedForest; + startBiomes[9] = Biome::flowerForest; } } diff --git a/Minecraft.World/BiomeSource.cpp b/Minecraft.World/BiomeSource.cpp index c001b146..d0e220c8 100644 --- a/Minecraft.World/BiomeSource.cpp +++ b/Minecraft.World/BiomeSource.cpp @@ -26,6 +26,7 @@ void BiomeSource::_init() playerSpawnBiomes.push_back(Biome::jungleHills); playerSpawnBiomes.push_back(Biome::savanna); playerSpawnBiomes.push_back(Biome::roofedForest); + playerSpawnBiomes.push_back(Biome::flowerForest); } void BiomeSource::_init(int64_t seed, LevelType *generator) diff --git a/Minecraft.World/BirchFeature.cpp b/Minecraft.World/BirchFeature.cpp index 3c423564..7a1d0f7a 100644 --- a/Minecraft.World/BirchFeature.cpp +++ b/Minecraft.World/BirchFeature.cpp @@ -3,80 +3,88 @@ #include "BirchFeature.h" #include "net.minecraft.world.level.tile.h" -BirchFeature::BirchFeature(bool doUpdate) : Feature(doUpdate) + +BirchFeature::BirchFeature(bool doUpdate, bool useTallBirch) : Feature(doUpdate) { + this->useTallBirch = useTallBirch; } bool BirchFeature::place(Level *level, Random *random, int x, int y, int z) { - int treeHeight = random->nextInt(3) + 5; + int treeHeight = random->nextInt(3) + 5; - bool free = true; - if (y < 1 || y + treeHeight + 1 > Level::maxBuildHeight) return false; + + if (this->useTallBirch) + { + treeHeight += random->nextInt(7); + } + - for (int yy = y; yy <= y + 1 + treeHeight; yy++) - { - int r = 1; - if (yy == y) r = 0; - if (yy >= y + 1 + treeHeight - 2) r = 2; - for (int xx = x - r; xx <= x + r && free; xx++) - { - for (int zz = z - r; zz <= z + r && free; zz++) - { - if (yy >= 0 && yy < Level::maxBuildHeight) - { - int tt = level->getTile(xx, yy, zz); - if (tt != 0 && tt != Tile::leaves_Id) free = false; - } - else - { - free = false; - } - } - } - } + bool free = true; + if (y < 1 || y + treeHeight + 1 > Level::maxBuildHeight) return false; - if (!free) return false; + for (int yy = y; yy <= y + 1 + treeHeight; yy++) + { + int r = 1; + if (yy == y) r = 0; + if (yy >= y + 1 + treeHeight - 2) r = 2; + for (int xx = x - r; xx <= x + r && free; xx++) + { + for (int zz = z - r; zz <= z + r && free; zz++) + { + if (yy >= 0 && yy < Level::maxBuildHeight) + { + int tt = level->getTile(xx, yy, zz); + if (tt != 0 && tt != Tile::leaves_Id) free = false; + } + else + { + free = false; + } + } + } + } - int belowTile = level->getTile(x, y - 1, z); - if ((belowTile != Tile::grass_Id && belowTile != Tile::dirt_Id) || y >= Level::maxBuildHeight - treeHeight - 1) return false; + if (!free) return false; - // 4J Stu Added to stop tree features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != nullptr) - { - LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); - int radius = 3; - bool intersects = levelGenOptions->checkIntersects(x - radius, y - 1, z - radius, x + radius, y + treeHeight, z + radius); - if(intersects) - { - //app.DebugPrintf("Skipping reeds feature generation as it overlaps a game rule structure\n"); - return false; - } - } + int belowTile = level->getTile(x, y - 1, z); + if ((belowTile != Tile::grass_Id && belowTile != Tile::dirt_Id) || y >= Level::maxBuildHeight - treeHeight - 1) return false; - placeBlock(level, x, y - 1, z, Tile::dirt_Id); + // 4J Stu Added to stop tree features generating areas previously place by game rule generation + if(app.getLevelGenerationOptions() != nullptr) + { + LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); + int radius = 3; + bool intersects = levelGenOptions->checkIntersects(x - radius, y - 1, z - radius, x + radius, y + treeHeight, z + radius); + if(intersects) + { + + return false; + } + } - for (int yy = y - 3 + treeHeight; yy <= y + treeHeight; yy++) - { - int yo = yy - (y + treeHeight); - int offs = 1 - yo / 2; - for (int xx = x - offs; xx <= x + offs; xx++) - { - int xo = xx - (x); - for (int zz = z - offs; zz <= z + offs; zz++) - { - int zo = zz - (z); - if (abs(xo) == offs && abs(zo) == offs && (random->nextInt(2) == 0 || yo == 0)) continue; - int t = level->getTile(xx, yy, zz); - if (t == 0 || t == Tile::leaves_Id) placeBlock(level, xx, yy, zz, Tile::leaves_Id, LeafTile::BIRCH_LEAF); - } - } - } - for (int hh = 0; hh < treeHeight; hh++) - { - int t = level->getTile(x, y + hh, z); - if (t == 0 || t == Tile::leaves_Id) placeBlock(level, x, y + hh, z, Tile::treeTrunk_Id, TreeTile::BIRCH_TRUNK); - } - return true; + placeBlock(level, x, y - 1, z, Tile::dirt_Id); + for (int yy = y - 3 + treeHeight; yy <= y + treeHeight; yy++) + { + int yo = yy - (y + treeHeight); + int offs = 1 - yo / 2; + for (int xx = x - offs; xx <= x + offs; xx++) + { + int xo = xx - (x); + for (int zz = z - offs; zz <= z + offs; zz++) + { + int zo = zz - (z); + if (abs(xo) == offs && abs(zo) == offs && (random->nextInt(2) == 0 || yo == 0)) continue; + int t = level->getTile(xx, yy, zz); + if (t == 0 || t == Tile::leaves_Id) placeBlock(level, xx, yy, zz, Tile::leaves_Id, LeafTile::BIRCH_LEAF); + } + } + } + for (int hh = 0; hh < treeHeight; hh++) + { + int t = level->getTile(x, y + hh, z); + if (t == 0 || t == Tile::leaves_Id) placeBlock(level, x, y + hh, z, Tile::treeTrunk_Id, TreeTile::BIRCH_TRUNK); + } + return true; } \ No newline at end of file diff --git a/Minecraft.World/BirchFeature.h b/Minecraft.World/BirchFeature.h index 6fabd122..141cedc3 100644 --- a/Minecraft.World/BirchFeature.h +++ b/Minecraft.World/BirchFeature.h @@ -1,11 +1,14 @@ #pragma once -#include "Feature.h" - -class Level; +#include "Feature.h" // O "AbstractTreeFeature.h" se ne hai uno class BirchFeature : public Feature { +private: + bool useTallBirch; // Aggiunto dall'assembly (offset 8) + public: - BirchFeature(bool doUpdate); - virtual bool place(Level *level, Random *random, int x, int y, int z); -}; + // Aggiunto il secondo parametro opzionale per evitare errori altrove + BirchFeature(bool doUpdate, bool useTallBirch = false); + + 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/DarkOakFeature.cpp b/Minecraft.World/DarkOakFeature.cpp index 84de0a16..c61a050c 100644 --- a/Minecraft.World/DarkOakFeature.cpp +++ b/Minecraft.World/DarkOakFeature.cpp @@ -5,81 +5,108 @@ #include "TreeTile2.h" #include "LeafTile2.h" #include - #include DarkOakFeature::DarkOakFeature(bool doUpdate) : Feature(doUpdate) { - this->baseHeight = 6; + } -bool DarkOakFeature::place(Level *worldIn, Random *rand, int x, int y, int z) { - int i = rand->nextInt(3) + rand->nextInt(2) + 6; - int j = x; - int k = y; - int l = z; +bool DarkOakFeature::place(Level *level, Random *rand, int x, int y, int z) { + int treeHeight = rand->nextInt(3) + rand->nextInt(2) + 6; + int startX = x; + int startY = y; + int startZ = z; - if (k >= 1 && k + i + 1 < Level::maxBuildHeight) { - int below = worldIn->getTile(j, k - 1, l); - bool isSoil = (below == Tile::grass_Id || below == Tile::dirt_Id); + if (startY >= 1 && startY + treeHeight + 1 < Level::maxBuildHeight) { + int belowTile = level->getTile(startX, startY - 1, startZ); + bool isSoil = (belowTile == Tile::grass_Id || belowTile == Tile::dirt_Id); - if (!(isSoil && k < Level::maxBuildHeight - i - 1)) { + if (!(isSoil && startY < Level::maxBuildHeight - treeHeight - 1)) { return false; - } else if (!this->checkSpace(worldIn, j, k, l, i)) { + } else if (!this->checkSpace(level, startX, startY, startZ, treeHeight)) { return false; } else { - int dirX = 0; - int dirZ = 0; - int facing = rand->nextInt(4); - if (facing == 0) dirX = 1; - else if (facing == 1) dirX = -1; - else if (facing == 2) dirZ = 1; - else if (facing == 3) dirZ = -1; - - int i1 = i - rand->nextInt(4); - int j1 = 2 - rand->nextInt(3); - int k1 = j; - int l1 = l; - int i2 = k + i - 1; + if(app.getLevelGenerationOptions() != nullptr) + { + LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); + int radius = 4; + bool intersects = levelGenOptions->checkIntersects(x - radius, y - 1, z - radius, x + radius + 1, y + treeHeight, z + radius + 1); + if(intersects) + { + return false; + } + } - for (int j2 = 0; j2 < i; ++j2) { - if (j2 >= i1 && j1 > 0) { - k1 += dirX; - l1 += dirZ; - --j1; + placeBlock(level, startX, startY - 1, startZ, Tile::dirt_Id); + placeBlock(level, startX + 1, startY - 1, startZ, Tile::dirt_Id); + placeBlock(level, startX, startY - 1, startZ + 1, Tile::dirt_Id); + placeBlock(level, startX + 1, startY - 1, startZ + 1, Tile::dirt_Id); + + + int face = rand->nextInt(4); // Direzione: 0=N, 1=E, 2=S, 3=W + int dx = 0; + int dz = 0; + if (face == 0) dz = -1; + else if (face == 1) dx = 1; + else if (face == 2) dz = 1; + else if (face == 3) dx = -1; + + int bendHeight = treeHeight - rand->nextInt(4); + int bendLength = 2 - rand->nextInt(3); + int trunkX = startX; + int trunkZ = startZ; + int topY = startY + treeHeight - 1; + + + for (int j2 = 0; j2 < treeHeight; ++j2) { + + if (j2 >= bendHeight && bendLength > 0) { + trunkX += dx; + trunkZ += dz; + --bendLength; } - int k2 = k + j2; - this->placeLog(worldIn, k1, k2, l1); - this->placeLog(worldIn, k1 + 1, k2, l1); - this->placeLog(worldIn, k1, k2, l1 + 1); - this->placeLog(worldIn, k1 + 1, k2, l1 + 1); + + int currentY = startY + j2; + this->placeLog(level, trunkX, currentY, trunkZ); + this->placeLog(level, trunkX + 1, currentY, trunkZ); + this->placeLog(level, trunkX, currentY, trunkZ + 1); + this->placeLog(level, trunkX + 1, currentY, trunkZ + 1); } for (int i3 = -2; i3 <= 0; ++i3) { for (int l3 = -2; l3 <= 0; ++l3) { int k4 = -1; - this->placeLeaf(worldIn, k1 + i3, i2 + k4, l1 + l3); - this->placeLeaf(worldIn, 1 + k1 - i3, i2 + k4, l1 + l3); - this->placeLeaf(worldIn, k1 + i3, i2 + k4, 1 + l1 - l3); - this->placeLeaf(worldIn, 1 + k1 - i3, i2 + k4, 1 + l1 - l3); + this->placeLeaf(level, trunkX + i3, topY + k4, trunkZ + l3); + this->placeLeaf(level, 1 + trunkX - i3, topY + k4, trunkZ + l3); + this->placeLeaf(level, trunkX + i3, topY + k4, 1 + trunkZ - l3); + this->placeLeaf(level, 1 + trunkX - i3, topY + k4, 1 + trunkZ - l3); if ((i3 > -2 || l3 > -1) && (i3 != -1 || l3 != -2)) { k4 = 1; - this->placeLeaf(worldIn, k1 + i3, i2 + k4, l1 + l3); - this->placeLeaf(worldIn, 1 + k1 - i3, i2 + k4, l1 + l3); - this->placeLeaf(worldIn, k1 + i3, i2 + k4, 1 + l1 - l3); - this->placeLeaf(worldIn, 1 + k1 - i3, i2 + k4, 1 + l1 - l3); + this->placeLeaf(level, trunkX + i3, topY + k4, trunkZ + l3); + this->placeLeaf(level, 1 + trunkX - i3, topY + k4, trunkZ + l3); + this->placeLeaf(level, trunkX + i3, topY + k4, 1 + trunkZ - l3); + this->placeLeaf(level, 1 + trunkX - i3, topY + k4, 1 + trunkZ - l3); } } } + if (rand->nextInt(2) == 0) { + this->placeLeaf(level, trunkX, topY + 2, trunkZ); + this->placeLeaf(level, trunkX + 1, topY + 2, trunkZ); + this->placeLeaf(level, trunkX + 1, topY + 2, trunkZ + 1); + this->placeLeaf(level, trunkX, topY + 2, trunkZ + 1); + } + + for (int j3 = -3; j3 <= 4; ++j3) { for (int i4 = -3; i4 <= 4; ++i4) { if ((j3 != -3 || i4 != -3) && (j3 != -3 || i4 != 4) && (j3 != 4 || i4 != -3) && (j3 != 4 || i4 != 4) && (std::abs(j3) < 3 || std::abs(i4) < 3)) { - this->placeLeaf(worldIn, k1 + j3, i2, l1 + i4); + this->placeLeaf(level, trunkX + j3, topY, trunkZ + i4); } } } @@ -92,21 +119,20 @@ bool DarkOakFeature::place(Level *worldIn, Random *rand, int x, int y, int z) { for (int i5 = 0; i5 < l4; ++i5) { - this->placeLog(worldIn, j + k3, i2 - i5 - 1, l + j4); + this->placeLog(level, startX + k3, topY - i5 - 1, startZ + j4); } for (int j5 = -1; j5 <= 1; ++j5) { for (int l2 = -1; l2 <= 1; ++l2) { - this->placeLeaf(worldIn, k1 + k3 + j5, i2, l1 + j4 + l2); + this->placeLeaf(level, trunkX + k3 + j5, topY, trunkZ + j4 + l2); } } - for (int k5 = -2; k5 <= 2; ++k5) { for (int l5 = -2; l5 <= 2; ++l5) { if (std::abs(k5) != 2 || std::abs(l5) != 2) { - this->placeLeaf(worldIn, k1 + k3 + k5, i2 - 1, l1 + j4 + l5); + this->placeLeaf(level, trunkX + k3 + k5, topY - 1, trunkZ + j4 + l5); } } } @@ -120,27 +146,18 @@ bool DarkOakFeature::place(Level *worldIn, Random *rand, int x, int y, int z) { return false; } - bool DarkOakFeature::checkSpace(Level *worldIn, int x, int y, int z, int height) { - - for (int l = 0; l <= height + 1; ++l) { int i1 = 1; - if (l == 0) { - i1 = 0; - } - if (l >= height - 1) { - i1 = 2; - } + if (l == 0) i1 = 0; + if (l >= height - 1) i1 = 2; for (int j1 = -i1; j1 <= i1; ++j1) { for (int k1 = -i1; k1 <= i1; ++k1) { - if (l == 0 && j1 == 0 && k1 == 0) continue; int tile = worldIn->getTile(x + j1, y + l, z + k1); - if (tile != 0 && tile != Tile::leaves_Id && tile != Tile::leaves2_Id && tile != Tile::tallgrass_Id && tile != Tile::sapling_Id && @@ -149,10 +166,7 @@ bool DarkOakFeature::checkSpace(Level *worldIn, int x, int y, int z, int height) return false; } - - if (tile == Tile::water_Id) { - return false; - } + if (tile == Tile::water_Id) return false; } } } @@ -161,16 +175,13 @@ bool DarkOakFeature::checkSpace(Level *worldIn, int x, int y, int z, int height) void DarkOakFeature::placeLog(Level *worldIn, int x, int y, int z) { int tile = worldIn->getTile(x, y, z); - if (tile == 0 || tile == Tile::leaves_Id || tile == Tile::leaves2_Id || tile == Tile::tallgrass_Id) { - placeBlock(worldIn, x, y, z, Tile::tree2Trunk_Id, TreeTile2::DARK_TRUNK); } } void DarkOakFeature::placeLeaf(Level *worldIn, int x, int y, int z) { int tile = worldIn->getTile(x, y, z); - if (tile == 0) { placeBlock(worldIn, x, y, z, Tile::leaves2_Id, 1); diff --git a/Minecraft.World/FlowerFeature.cpp b/Minecraft.World/FlowerFeature.cpp index c5cd68c6..7539910e 100644 --- a/Minecraft.World/FlowerFeature.cpp +++ b/Minecraft.World/FlowerFeature.cpp @@ -4,38 +4,35 @@ #include "FlowerFeature.h" #include "net.minecraft.world.level.tile.h" -FlowerFeature::FlowerFeature(int tile) +FlowerFeature::FlowerFeature(int tile, int variant) { - this->tile = tile; + this->tile = tile; + this->variant = variant; } -bool FlowerFeature::place(Level *level, Random *random, int x, int y, int z) +bool FlowerFeature::place(Level* level, Random* random, int x, int y, int z) { - // 4J Stu Added to stop tree features generating areas previously place by game rule generation - if(app.getLevelGenerationOptions() != nullptr) - { - LevelGenerationOptions *levelGenOptions = app.getLevelGenerationOptions(); - bool intersects = levelGenOptions->checkIntersects(x - 8, y - 4, z - 8, x + 8, y + 4, z + 8); - if(intersects) - { - //app.DebugPrintf("Skipping reeds feature generation as it overlaps a game rule structure\n"); - return false; - } - } - - for (int i = 0; i < 64; i++) - { - int x2 = x + random->nextInt(8) - random->nextInt(8); - int y2 = y + random->nextInt(4) - random->nextInt(4); - int z2 = z + random->nextInt(8) - random->nextInt(8); - if (level->isEmptyTile(x2, y2, z2) && (!level->dimension->hasCeiling || y2 < Level::genDepthMinusOne)) - { - if (Tile::tiles[tile]->canSurvive(level, x2, y2, z2)) - { - level->setTileAndData(x2, y2, z2, tile, 0, Tile::UPDATE_CLIENTS); - } - } - } - - return true; + if (app.getLevelGenerationOptions() != nullptr) + { + LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions(); + bool intersects = levelGenOptions->checkIntersects(x - 8, y - 4, z - 8, x + 8, y + 4, z + 8); + if (intersects) + { + return false; + } + } + for (int i = 0; i < 64; i++) + { + int x2 = x + random->nextInt(8) - random->nextInt(8); + int y2 = y + random->nextInt(4) - random->nextInt(4); + int z2 = z + random->nextInt(8) - random->nextInt(8); + if (level->isEmptyTile(x2, y2, z2) && (!level->dimension->hasCeiling || y2 < Level::genDepthMinusOne)) + { + if (Tile::tiles[tile]->canSurvive(level, x2, y2, z2)) + { + level->setTileAndData(x2, y2, z2, tile, variant, Tile::UPDATE_CLIENTS); + } + } + } + return true; } \ No newline at end of file diff --git a/Minecraft.World/FlowerFeature.h b/Minecraft.World/FlowerFeature.h index 47a0c3bc..52394799 100644 --- a/Minecraft.World/FlowerFeature.h +++ b/Minecraft.World/FlowerFeature.h @@ -1,14 +1,12 @@ #pragma once #include "Feature.h" - class Level; - class FlowerFeature : public Feature { private: - int tile; - + int tile; + int variant; public: - FlowerFeature (int tile); - bool place(Level *level, Random *random, int x, int y, int z); + FlowerFeature(int tile, int variant = 0); + bool place(Level* level, Random* random, int x, int y, int z); }; \ No newline at end of file diff --git a/Minecraft.World/ForestBiome.cpp b/Minecraft.World/ForestBiome.cpp index 70c8a04f..56c68622 100644 --- a/Minecraft.World/ForestBiome.cpp +++ b/Minecraft.World/ForestBiome.cpp @@ -1,27 +1,85 @@ #include "stdafx.h" +#include "ForestBiome.h" #include "net.minecraft.world.level.levelgen.feature.h" #include "net.minecraft.world.level.biome.h" -#include "net.minecraft.world.entity.animal.h" -#include "net.minecraft.world.entity.h" -#include "ForestBiome.h" +#include "DarkOakFeature.h" -ForestBiome::ForestBiome(int id) : Biome(id) +ForestBiome::ForestBiome(int id, int type) : Biome(id) { - friendlies_wolf.push_back(new MobSpawnerData(eTYPE_WOLF, 5, 4, 4)); // 4J - moved to their own category - friendlies.push_back(new MobSpawnerData(eTYPE_RABBIT, 4, 2, 3)); - decorator->treeCount = 10; - decorator->grassCount = 2; + this->biomeType = type; + + + this->setLeafColor(0x4EBA31); + this->setTemperatureAndDownfall(0.7f, 0.8f); + + if (this->biomeType == 1) //flowerforest + { + this->decorator->treeCount = 10; + this->decorator->grassCount = 2; + this->decorator->flowerCount = 100; + this->decorator->alliumCount = 2; + this->decorator->azureBluetCount = 2; + this->decorator->oxeyeDaisyCount = 2; + this->decorator->blueOrchidCount = 0; + this->setTemperatureAndDownfall(0.6f, 0.6f); + } + else if (this->biomeType == 2) //birchforest + { + this->decorator->treeCount = 10; + this->decorator->grassCount = 2; + } + else if (this->biomeType == 3) //roofedforest + { + + this->decorator->treeCount = 50; + this->decorator->grassCount = 2; + this->decorator->flowerCount = 1; + this->decorator->hugeMushrooms = 2; + } + else + { + this->decorator->treeCount = 6; + this->decorator->flowerCount = 4; + this->decorator->grassCount = 1; + + MobSpawnerData* wolfSpawn = new MobSpawnerData(eTYPE_WOLF, 5, 4, 4); + this->friendlies.push_back(wolfSpawn); + } + + if (this->biomeType == 0) + { + MobSpawnerData* rabbitSpawn = new MobSpawnerData(eTYPE_RABBIT, 4, 2, 3); + this->friendlies.push_back(rabbitSpawn); + } } -Feature *ForestBiome::getTreeFeature(Random *random) +Feature* ForestBiome::getTreeFeature(Random* random) { - if (random->nextInt(5) == 0) - { - return new BirchFeature(false); // 4J used to return member birchTree, now returning newly created object so that caller can be consistently resposible for cleanup + if (this->biomeType == 3) // Roofed Forest + { + + if (random->nextInt(3) > 0) + { + return new DarkOakFeature(false); + } } - 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 + + + if (this->biomeType == 2 || random->nextInt(5) == 0) + { + return new BirchFeature(false, false); } - return new TreeFeature(false); // 4J used to return member normalTree, now returning newly created object so that caller can be consistently resposible for cleanup + + + return new TreeFeature(false); } + + +Biome* ForestBiome::setColor(int color, bool b) +{ + + Biome::setColor(color, b); + + + return this; +} \ No newline at end of file diff --git a/Minecraft.World/ForestBiome.h b/Minecraft.World/ForestBiome.h index e8045bd4..ce0f6007 100644 --- a/Minecraft.World/ForestBiome.h +++ b/Minecraft.World/ForestBiome.h @@ -3,8 +3,14 @@ class ForestBiome : public Biome { -public: - ForestBiome(int id); +private: + int biomeType; - virtual Feature *getTreeFeature(Random *random); -}; +public: + ForestBiome(int id, int type = 0); + + virtual Feature *getTreeFeature(Random *random) override; + + + virtual Biome *setColor(int color, bool b = false) override; +}; \ No newline at end of file diff --git a/Minecraft.World/Minecraft.World.vcxproj b/Minecraft.World/Minecraft.World.vcxproj index 807a6cc0..e0017d26 100644 --- a/Minecraft.World/Minecraft.World.vcxproj +++ b/Minecraft.World/Minecraft.World.vcxproj @@ -2850,6 +2850,7 @@ + @@ -3681,6 +3682,7 @@ + diff --git a/Minecraft.World/Minecraft.World.vcxproj.filters b/Minecraft.World/Minecraft.World.vcxproj.filters index 8d39f6ac..153933c0 100644 --- a/Minecraft.World/Minecraft.World.vcxproj.filters +++ b/Minecraft.World/Minecraft.World.vcxproj.filters @@ -829,6 +829,7 @@ + @@ -1827,6 +1828,7 @@ + diff --git a/Minecraft.World/RoofedForestBiome.cpp b/Minecraft.World/RoofedForestBiome.cpp index e75a9117..1400d007 100644 --- a/Minecraft.World/RoofedForestBiome.cpp +++ b/Minecraft.World/RoofedForestBiome.cpp @@ -3,6 +3,8 @@ #include "BiomeDecorator.h" #include "DarkOakFeature.h" #include "HugeMushroomFeature.h" +#include "TreeFeature.h" +#include "BirchFeature.h" #include "net.minecraft.world.level.tile.h" #include "..\Level.h" @@ -29,16 +31,24 @@ RoofedForestBiome::RoofedForestBiome(int id) : Biome(id) Feature* RoofedForestBiome::getTreeFeature(Random* random) { - - - if (random->nextInt(15) == 0) + if (random->nextInt(20) == 0) { - return new HugeMushroomFeature(); } + + if (random->nextInt(3) > 0) + { + return new DarkOakFeature(true); + } - return new DarkOakFeature(true); + + { + return new TreeFeature(false); + } + + + return new BirchFeature(false); } diff --git a/Minecraft.World/StrongholdFeature.cpp b/Minecraft.World/StrongholdFeature.cpp index 83f05cf3..2e702565 100644 --- a/Minecraft.World/StrongholdFeature.cpp +++ b/Minecraft.World/StrongholdFeature.cpp @@ -29,6 +29,9 @@ void StrongholdFeature::staticCtor() allowedBiomes.push_back(Biome::taigaHills); allowedBiomes.push_back(Biome::jungle); allowedBiomes.push_back(Biome::jungleHills); + allowedBiomes.push_back(Biome::savanna); + allowedBiomes.push_back(Biome::roofedForest); + allowedBiomes.push_back(Biome::flowerForest); }; void StrongholdFeature::_init() diff --git a/Minecraft.World/Vec3.cpp b/Minecraft.World/Vec3.cpp index b513c149..93a326ce 100644 --- a/Minecraft.World/Vec3.cpp +++ b/Minecraft.World/Vec3.cpp @@ -1,49 +1,51 @@ #include "stdafx.h" #include "Vec3.h" #include "AABB.h" +#include +#include DWORD Vec3::tlsIdx = 0; Vec3::ThreadStorage *Vec3::tlsDefault = nullptr; Vec3::ThreadStorage::ThreadStorage() { - pool = new Vec3[POOL_SIZE]; - poolPointer = 0; + pool = new Vec3[POOL_SIZE]; + poolPointer = 0; } Vec3::ThreadStorage::~ThreadStorage() { - delete [] pool; + delete [] pool; } void Vec3::CreateNewThreadStorage() { - ThreadStorage *tls = new ThreadStorage(); - if(tlsDefault == nullptr ) - { - tlsIdx = TlsAlloc(); - tlsDefault = tls; - } - TlsSetValue(tlsIdx, tls); + ThreadStorage *tls = new ThreadStorage(); + if(tlsDefault == nullptr ) + { + tlsIdx = TlsAlloc(); + tlsDefault = tls; + } + TlsSetValue(tlsIdx, tls); } void Vec3::UseDefaultThreadStorage() { - TlsSetValue(tlsIdx, tlsDefault); + TlsSetValue(tlsIdx, tlsDefault); } void Vec3::ReleaseThreadStorage() { - ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); - if( tls == tlsDefault ) return; + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); + if( tls == tlsDefault ) return; - delete tls; + delete tls; } Vec3 *Vec3::newPermanent(double x, double y, double z) { - return new Vec3(x,y,z); -}; + return new Vec3(x,y,z); +} void Vec3::clearPool() { @@ -55,238 +57,244 @@ void Vec3::resetPool() Vec3 *Vec3::newTemp(double x, double y, double z) { - ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); - Vec3 *thisVec = &tls->pool[tls->poolPointer]; - thisVec->set(x, y, z); - tls->poolPointer = ( tls->poolPointer + 1 ) % ThreadStorage::POOL_SIZE; - return thisVec; + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); + Vec3 *thisVec = &tls->pool[tls->poolPointer]; + thisVec->set(x, y, z); + tls->poolPointer = ( tls->poolPointer + 1 ) % ThreadStorage::POOL_SIZE; + return thisVec; } Vec3::Vec3(double x, double y, double z) { - if (x == -0.0) x = 0.0; - if (y == -0.0) y = 0.0; - if (z == -0.0) z = 0.0; - this->x = x; - this->y = y; - this->z = z; + if (x == -0.0) x = 0.0; + if (y == -0.0) y = 0.0; + if (z == -0.0) z = 0.0; + this->x = x; + this->y = y; + this->z = z; } Vec3 *Vec3::set(double x, double y, double z) { - this->x = x; - this->y = y; - this->z = z; - return this; + this->x = x; + this->y = y; + this->z = z; + return this; +} + +// 4J/Assembly overload +Vec3 *Vec3::set(Vec3 *other) +{ + this->x = other->x; + this->y = other->y; + this->z = other->z; + return this; } Vec3 *Vec3::interpolateTo(Vec3 *t, double p) { - double xt = x + (t->x - x) * p; - double yt = y + (t->y - y) * p; - double zt = z + (t->z - z) * p; + double xt = x + (t->x - x) * p; + double yt = y + (t->y - y) * p; + double zt = z + (t->z - z) * p; - return Vec3::newTemp(xt, yt, zt); + return Vec3::newTemp(xt, yt, zt); } Vec3 *Vec3::vectorTo(Vec3 *p) { - return Vec3::newTemp(p->x - x, p->y - y, p->z - z); + return Vec3::newTemp(p->x - x, p->y - y, p->z - z); } Vec3 *Vec3::normalize() { - double dist = (double) (sqrt(x * x + y * y + z * z)); - if (dist < 0.0001) return Vec3::newTemp(0, 0, 0); - return Vec3::newTemp(x / dist, y / dist, z / dist); + double dist = (double) (sqrt(x * x + y * y + z * z)); + if (dist < 0.0001) return Vec3::newTemp(0, 0, 0); + return Vec3::newTemp(x / dist, y / dist, z / dist); } double Vec3::dot(Vec3 *p) { - return x * p->x + y * p->y + z * p->z; + return x * p->x + y * p->y + z * p->z; } Vec3 *Vec3::cross(Vec3 *p) { - return Vec3::newTemp(y * p->z - z * p->y, z * p->x - x * p->z, x * p->y - y * p->x); + return Vec3::newTemp(y * p->z - z * p->y, z * p->x - x * p->z, x * p->y - y * p->x); } Vec3 *Vec3::add(double x, double y, double z) { - return Vec3::newTemp(this->x + x, this->y + y, this->z + z); + return Vec3::newTemp(this->x + x, this->y + y, this->z + z); } double Vec3::distanceTo(Vec3 *p) { - double xd = p->x - x; - double yd = p->y - y; - double zd = p->z - z; - return (double) sqrt(xd * xd + yd * yd + zd * zd); + double xd = p->x - x; + double yd = p->y - y; + double zd = p->z - z; + return (double) sqrt(xd * xd + yd * yd + zd * zd); } double Vec3::distanceToSqr(Vec3 *p) { - double xd = p->x - x; - double yd = p->y - y; - double zd = p->z - z; - return xd * xd + yd * yd + zd * zd; + double xd = p->x - x; + double yd = p->y - y; + double zd = p->z - z; + return xd * xd + yd * yd + zd * zd; } double Vec3::distanceToSqr(double x2, double y2, double z2) { - double xd = x2 - x; - double yd = y2 - y; - double zd = z2 - z; - return xd * xd + yd * yd + zd * zd; + double xd = x2 - x; + double yd = y2 - y; + double zd = z2 - z; + return xd * xd + yd * yd + zd * zd; } Vec3 *Vec3::scale(double l) { - return Vec3::newTemp(x * l, y * l, z * l); + return Vec3::newTemp(x * l, y * l, z * l); } double Vec3::length() { - return sqrt(x * x + y * y + z * z); + return sqrt(x * x + y * y + z * z); } Vec3 *Vec3::clipX(Vec3 *b, double xt) { - double xd = b->x - x; - double yd = b->y - y; - double zd = b->z - z; + double xd = b->x - x; + double yd = b->y - y; + double zd = b->z - z; - if (xd * xd < 0.0000001f) return nullptr; + if (xd * xd < 0.0000001) return nullptr; - double d = (xt - x) / xd; - if (d < 0 || d > 1) return nullptr; - return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d); + double d = (xt - x) / xd; + if (d < 0 || d > 1) return nullptr; + return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d); } Vec3 *Vec3::clipY(Vec3 *b, double yt) { - double xd = b->x - x; - double yd = b->y - y; - double zd = b->z - z; + double xd = b->x - x; + double yd = b->y - y; + double zd = b->z - z; - if (yd * yd < 0.0000001f) return nullptr; + if (yd * yd < 0.0000001) return nullptr; - double d = (yt - y) / yd; - if (d < 0 || d > 1) return nullptr; - return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d); + double d = (yt - y) / yd; + if (d < 0 || d > 1) return nullptr; + return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d); } Vec3 *Vec3::clipZ(Vec3 *b, double zt) { - double xd = b->x - x; - double yd = b->y - y; - double zd = b->z - z; + double xd = b->x - x; + double yd = b->y - y; + double zd = b->z - z; - if (zd * zd < 0.0000001f) return nullptr; + if (zd * zd < 0.0000001) return nullptr; - double d = (zt - z) / zd; - if (d < 0 || d > 1) return nullptr; - return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d); + double d = (zt - z) / zd; + if (d < 0 || d > 1) return nullptr; + return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d); } wstring Vec3::toString() { - static wchar_t buf[128]; - swprintf(buf, 128, L"(%f,%f,%f)",x,y,z); - return wstring(buf); + static wchar_t buf[128]; + swprintf(buf, 128, L"(%f,%f,%f)",x,y,z); + return wstring(buf); } Vec3 *Vec3::lerp(Vec3 *v, double a) { - return Vec3::newTemp(x + (v->x - x) * a, y + (v->y - y) * a, z + (v->z - z) * a); + return Vec3::newTemp(x + (v->x - x) * a, y + (v->y - y) * a, z + (v->z - z) * a); } void Vec3::xRot(float degs) { - double _cos = cos(degs); // 4J - cos/sin were floats but seems pointless wasting precision here - double _sin = sin(degs); + double _cos = cos((double)degs); // Use double for precision + double _sin = sin((double)degs); - double xx = x; - double yy = y * _cos + z * _sin; - double zz = z * _cos - y * _sin; + double xx = x; + double yy = y * _cos + z * _sin; + double zz = z * _cos - y * _sin; - x = xx; - y = yy; - z = zz; + x = xx; + y = yy; + z = zz; } void Vec3::yRot(float degs) { - double _cos = cos(degs); // 4J - cos/sin were floats but seems pointless wasting precision here - double _sin = sin(degs); + double _cos = cos((double)degs); + double _sin = sin((double)degs); - double xx = x * _cos + z * _sin; - double yy = y; - double zz = z * _cos - x * _sin; + double xx = x * _cos + z * _sin; + double yy = y; + double zz = z * _cos - x * _sin; - x = xx; - y = yy; - z = zz; + x = xx; + y = yy; + z = zz; } void Vec3::zRot(float degs) { - double _cos = cos(degs); // 4J - cos/sin were floats but seems pointless wasting precision here - double _sin = sin(degs); + double _cos = cos((double)degs); + double _sin = sin((double)degs); - double xx = x * _cos + y * _sin; - double yy = y * _cos - x * _sin; - double zz = z; + double xx = x * _cos + y * _sin; + double yy = y * _cos - x * _sin; + double zz = z; - x = xx; - y = yy; - z = zz; + x = xx; + y = yy; + z = zz; } -// Returns 0 if this point is within the box -// Otherwise returns the distance to the box double Vec3::distanceTo(AABB *box) { - if(box->contains(this)) return 0; + if(box->contains(this)) return 0; - double xd = 0, yd = 0, zd = 0; + double xd = 0, yd = 0, zd = 0; - if(x < box->x0) xd = box->x0 - x; - else if( x > box->x1) xd = x - box->x1; + if(x < box->x0) xd = box->x0 - x; + else if( x > box->x1) xd = x - box->x1; - if(y < box->y0) yd = box->y0 - y; - else if( y > box->y1) yd = y - box->y1; + if(y < box->y0) yd = box->y0 - y; + else if( y > box->y1) yd = y - box->y1; - if(z < box->z0) zd = box->z0 - z; - else if( z > box->z1) zd = z - box->z1; + if(z < box->z0) zd = box->z0 - z; + else if( z > box->z1) zd = z - box->z1; - return sqrt(xd * xd + yd * yd + zd * zd); + return sqrt(xd * xd + yd * yd + zd * zd); } - - Vec3* Vec3::closestPointOnLine(Vec3* p1, Vec3* p2) { - Vec3* diff = newTemp(x-p1->x, y-p1->y, z-p1->z); - Vec3* dir = newTemp(p2->x-p1->x, p2->y-p1->y, p2->z-p1->z); - float dot1 = diff->dot(dir); - if (dot1 <= 0.0f) - return p1; + Vec3* diff = newTemp(x-p1->x, y-p1->y, z-p1->z); + Vec3* dir = newTemp(p2->x-p1->x, p2->y-p1->y, p2->z-p1->z); + + // Cambiato float in double + double dot1 = diff->dot(dir); + if (dot1 <= 0.0) + return p1; - float dot2 = dir->dot(dir); + double dot2 = dir->dot(dir); - if (dot2 <= dot1) - return p2; + if (dot2 <= dot1) + return p2; - float t=dot1/dot2; - return newTemp(p1->x + t * dir->x, p1->y + t * dir->y, p1->z + t * dir->z); + double t=dot1/dot2; + return newTemp(p1->x + t * dir->x, p1->y + t * dir->y, p1->z + t * dir->z); } - double Vec3::distanceFromLine(Vec3* p1, Vec3* p2) { - Vec3* closestPoint = closestPointOnLine(p1, p2); - Vec3* diff = newTemp(x-closestPoint->x, y-closestPoint->y, z-closestPoint->z); - return diff->length(); -} + Vec3* closestPoint = closestPointOnLine(p1, p2); + Vec3* diff = newTemp(x-closestPoint->x, y-closestPoint->y, z-closestPoint->z); + return diff->length(); +} \ No newline at end of file diff --git a/Minecraft.World/Vec3.h b/Minecraft.World/Vec3.h index 0ef6cae0..2afc9ea7 100644 --- a/Minecraft.World/Vec3.h +++ b/Minecraft.World/Vec3.h @@ -1,39 +1,48 @@ #pragma once +#include + using namespace std; class AABB; class Vec3 { - // 4J added so we can have separate pools for different threads - class ThreadStorage - { - public: - static const int POOL_SIZE = 1024; - Vec3 *pool; - unsigned int poolPointer; - ThreadStorage(); - ~ThreadStorage(); - }; - static DWORD tlsIdx; - static ThreadStorage *tlsDefault; + // 4J added so we can have separate pools for different threads + class ThreadStorage + { + public: + static const unsigned int POOL_SIZE = 1024; // 4J Stu - size + Vec3 *pool; + unsigned int poolPointer; + ThreadStorage(); + ~ThreadStorage(); + }; + + static DWORD tlsIdx; + static ThreadStorage *tlsDefault; + public: - // Each new thread that needs to use Vec3 pools will need to call one of the following 2 functions, to either create its own - // local storage, or share the default storage already allocated by the main thread - static void CreateNewThreadStorage(); - static void UseDefaultThreadStorage(); - static void ReleaseThreadStorage(); + // Each new thread that needs to use Vec3 pools will need to call one of the following 2 functions, to either create its own + // local storage, or share the default storage already allocated by the main thread + static void CreateNewThreadStorage(); + static void UseDefaultThreadStorage(); + static void ReleaseThreadStorage(); static Vec3 *newPermanent(double x, double y, double z); static void clearPool(); static void resetPool(); static Vec3 *newTemp(double x, double y, double z); + double x, y, z; + private: - Vec3() {} + Vec3() {} Vec3(double x, double y, double z); - Vec3 *set(double x, double y, double z); + public: + Vec3 *set(double x, double y, double z); + Vec3 *set(Vec3 *other); + Vec3 *interpolateTo(Vec3 *t, double p); Vec3 *vectorTo(Vec3 *p); Vec3 *normalize(); @@ -50,14 +59,15 @@ public: Vec3 *clipZ(Vec3 *b, double zt); wstring toString(); Vec3 *lerp(Vec3 *v, double a); + + void xRot(float degs); void yRot(float degs); void zRot(float degs); - // 4J Added - double distanceTo(AABB *box); - - Vec3* closestPointOnLine(Vec3* p1, Vec3* p2); - double distanceFromLine(Vec3* p1, Vec3* p2); + // 4J Added + double distanceTo(AABB *box); + Vec3* closestPointOnLine(Vec3* p1, Vec3* p2); + double distanceFromLine(Vec3* p1, Vec3* p2); }; \ No newline at end of file diff --git a/Minecraft.World/Vec3i.cpp b/Minecraft.World/Vec3i.cpp new file mode 100644 index 00000000..3291bfd6 --- /dev/null +++ b/Minecraft.World/Vec3i.cpp @@ -0,0 +1,30 @@ +#include "stdafx.h" +#include "Vec3i.h" +#include + +Vec3i::Vec3i(int x, int y, int z) : x(x), y(y), z(z) +{ +} + +int Vec3i::getX() const +{ + return this->x; +} + +int Vec3i::getY() const +{ + return this->y; +} + +int Vec3i::getZ() const +{ + return this->z; +} + +double Vec3i::distSqr(const Vec3i& other) const +{ + double dx = (double)(this->x - other.getX()); + double dy = (double)(this->y - other.getY()); + double dz = (double)(this->z - other.getZ()); + return dx * dx + dy * dy + dz * dz; +} \ No newline at end of file diff --git a/Minecraft.World/Vec3i.h b/Minecraft.World/Vec3i.h new file mode 100644 index 00000000..730f3fd8 --- /dev/null +++ b/Minecraft.World/Vec3i.h @@ -0,0 +1,20 @@ +#pragma once + +class Vec3i +{ +protected: + int x; + int y; + int z; + +public: + Vec3i(int x, int y, int z); + virtual ~Vec3i() = default; + + int getX() const; + int getY() const; + int getZ() const; + + + double distSqr(const Vec3i& other) const; +}; \ No newline at end of file diff --git a/Minecraft.World/net.minecraft.world.level.levelgen.feature.h b/Minecraft.World/net.minecraft.world.level.levelgen.feature.h index 81ac8637..f00041c1 100644 --- a/Minecraft.World/net.minecraft.world.level.levelgen.feature.h +++ b/Minecraft.World/net.minecraft.world.level.levelgen.feature.h @@ -30,6 +30,8 @@ #include "BonusChestFeature.h" #include "SpikeFeature.h" #include "EndPodiumFeature.h" +#include "SavannaTreeFeature.h" +#include "DarkOakFeature.h" #include "DesertWellFeature.h" #include "MegaTreeFeature.h"