diff --git a/Minecraft.World/Biome.cpp b/Minecraft.World/Biome.cpp index 607b2099..918d40fa 100644 --- a/Minecraft.World/Biome.cpp +++ b/Minecraft.World/Biome.cpp @@ -147,7 +147,9 @@ Biome::Biome(int id) : id(id) { color = 0; topMaterial = static_cast(Tile::grass_Id); + topMaterialData = 0; material = static_cast(Tile::dirt_Id); + materialData = 0; leafColor = 0x4EE031; _hasRain = true; depth = 0.1f; diff --git a/Minecraft.World/ExtremeHillsBiome.cpp b/Minecraft.World/ExtremeHillsBiome.cpp index 658da319..d5c05244 100644 --- a/Minecraft.World/ExtremeHillsBiome.cpp +++ b/Minecraft.World/ExtremeHillsBiome.cpp @@ -77,7 +77,9 @@ void ExtremeHillsBiome::buildSurfaceAtDefault(Level *level, Random *random, byte else if (noiseVal > 1.0 && type != 1) { topMaterial = static_cast(Tile::stone_Id); + topMaterialData = 0; material = static_cast(Tile::stone_Id); + materialData = 0; } Biome::buildSurfaceAtDefault(level, random, chunkBlocks, x, z, noiseVal); diff --git a/Minecraft.World/JungleBiome.cpp b/Minecraft.World/JungleBiome.cpp index bd187340..672ef7c1 100644 --- a/Minecraft.World/JungleBiome.cpp +++ b/Minecraft.World/JungleBiome.cpp @@ -5,6 +5,7 @@ #include "net.minecraft.world.level.h" #include "net.minecraft.world.entity.animal.h" #include "JungleBiome.h" + #include "MelonFeature.h" JungleBiome::JungleBiome(int id, bool isEdge) : Biome(id) { @@ -70,4 +71,16 @@ } delete vines; PIXEndNamedEvent(); + + PIXBeginNamedEvent(0, "Adding melons"); + if (random->nextInt(4) == 0) // Common: 1 in 4 chunks + { + int x = xo + random->nextInt(16) + 8; + int z = zo + random->nextInt(16) + 8; + int y = random->nextInt(Level::genDepth); + MelonFeature *melonFeature = new MelonFeature(); + melonFeature->place(level, random, x, y, z); + delete melonFeature; + } + PIXEndNamedEvent(); } \ No newline at end of file diff --git a/Minecraft.World/MelonFeature.cpp b/Minecraft.World/MelonFeature.cpp new file mode 100644 index 00000000..0921fd09 --- /dev/null +++ b/Minecraft.World/MelonFeature.cpp @@ -0,0 +1,23 @@ +#include "stdafx.h" +#include "net.minecraft.world.level.h" +#include "net.minecraft.world.level.tile.h" +#include "MelonFeature.h" + +bool MelonFeature::place(Level *level, Random *random, int x, int y, int z) +{ + 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->getTile(x2, y2 - 1, z2) == Tile::grass_Id) + { + if (Tile::melon->mayPlace(level, x2, y2, z2)) + { + level->setTileAndData(x2, y2, z2, Tile::melon_Id, 0, Tile::UPDATE_CLIENTS); + } + } + } + + return true; +} diff --git a/Minecraft.World/MelonFeature.h b/Minecraft.World/MelonFeature.h new file mode 100644 index 00000000..ce1ad792 --- /dev/null +++ b/Minecraft.World/MelonFeature.h @@ -0,0 +1,9 @@ +#pragma once +#include "Feature.h" + + +class MelonFeature : public Feature +{ +public: + virtual bool place(Level *level, Random *random, int x, int y, int z); +}; diff --git a/Minecraft.World/MutatedBiome.cpp b/Minecraft.World/MutatedBiome.cpp index 08188f9f..e98f821d 100644 --- a/Minecraft.World/MutatedBiome.cpp +++ b/Minecraft.World/MutatedBiome.cpp @@ -12,7 +12,9 @@ MutatedBiome::MutatedBiome(int id, Biome* baseBiome) color = baseBiome->color; topMaterial = baseBiome->topMaterial; + topMaterialData = baseBiome->topMaterialData; material = baseBiome->material; + materialData = baseBiome->materialData; leafColor = baseBiome->leafColor; depth = baseBiome->depth + 0.1f; scale = baseBiome->scale + 0.2f; diff --git a/Minecraft.World/SavannaBiome.cpp b/Minecraft.World/SavannaBiome.cpp index 3428618c..422388c8 100644 --- a/Minecraft.World/SavannaBiome.cpp +++ b/Minecraft.World/SavannaBiome.cpp @@ -85,12 +85,23 @@ void MutatedSavannaBiome::buildSurfaceAtDefault(Level *level, Random *random, by if (noiseVal > 1.75) { topMaterial = static_cast(Tile::stone_Id); + topMaterialData = 0; material = static_cast(Tile::stone_Id); + materialData = 0; } else if (noiseVal > -0.5) { topMaterial = static_cast(Tile::dirt_Id); + topMaterialData = 0; material = static_cast(Tile::dirt_Id); + materialData = 0; + } + else + { + topMaterial = static_cast(Tile::grass_Id); + topMaterialData = 0; + material = static_cast(Tile::dirt_Id); + materialData = 0; } Biome::buildSurfaceAtDefault(level, random, chunkBlocks, x, z, noiseVal); diff --git a/Minecraft.World/cmake/sources/Common.cmake b/Minecraft.World/cmake/sources/Common.cmake index 2856d770..5752df23 100644 --- a/Minecraft.World/cmake/sources/Common.cmake +++ b/Minecraft.World/cmake/sources/Common.cmake @@ -1498,6 +1498,8 @@ set(_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_LEVEL_LEVELGEN_FEATURE "${CMAKE_CURRENT_SOURCE_DIR}/PineFeature.h" "${CMAKE_CURRENT_SOURCE_DIR}/PumpkinFeature.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/PumpkinFeature.h" + "${CMAKE_CURRENT_SOURCE_DIR}/MelonFeature.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/MelonFeature.h" "${CMAKE_CURRENT_SOURCE_DIR}/ReedsFeature.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/ReedsFeature.h" "${CMAKE_CURRENT_SOURCE_DIR}/SandFeature.cpp" diff --git a/Minecraft.World/net.minecraft.world.level.levelgen.feature.h b/Minecraft.World/net.minecraft.world.level.levelgen.feature.h index 768b8ca4..dc780682 100644 --- a/Minecraft.World/net.minecraft.world.level.levelgen.feature.h +++ b/Minecraft.World/net.minecraft.world.level.levelgen.feature.h @@ -18,6 +18,7 @@ #include "OreFeature.h" #include "PineFeature.h" #include "PumpkinFeature.h" +#include "MelonFeature.h" #include "ReedsFeature.h" #include "SpringFeature.h" #include "SpruceFeature.h"