Savanna Biome

This commit is contained in:
Lord Cambion 2026-03-18 01:09:20 +01:00
parent 5e7cf04505
commit 9c876448bb
12 changed files with 188 additions and 75 deletions

View file

@ -82,7 +82,7 @@ void Biome::staticCtor()
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 Biome(35))->setName(L"Savanna")->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Savanna, eMinecraftColour_Foliage_Savanna, eMinecraftColour_Sky_Desert, eMinecraftColour_Sky_Desert);
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 Biome(29))->setName(L"Roofed Forest")->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_RoofedForest, eMinecraftColour_Foliage_RoofedForest, eMinecraftColour_Water_Forest, eMinecraftColour_Sky_Forest);
}

View file

@ -14,6 +14,7 @@ class BirchFeature;
class SwampTreeFeature;
class ChunkRebuildData;
class Biome
{
friend class ChunkRebuildData;

View file

@ -14,6 +14,7 @@ class BiomeDecorator
friend class TaigaBiome;
friend class MushroomIslandBiome;
friend class BeachBiome;
friend class SavannaBiome;
friend class JungleBiome;
protected:
Level *level;

View file

@ -21,7 +21,7 @@ BiomeInitLayer::BiomeInitLayer(int64_t seed, shared_ptr<Layer>parent, LevelType
}
else
{
startBiomes = BiomeArray(7);
startBiomes = BiomeArray(8);
startBiomes[0] = Biome::desert;
startBiomes[1] = Biome::forest;
startBiomes[2] = Biome::extremeHills;
@ -29,6 +29,7 @@ BiomeInitLayer::BiomeInitLayer(int64_t seed, shared_ptr<Layer>parent, LevelType
startBiomes[4] = Biome::plains;
startBiomes[5] = Biome::taiga;
startBiomes[6] = Biome::jungle;
startBiomes[7] = Biome::savanna;
}
}

View file

@ -24,6 +24,7 @@ void BiomeSource::_init()
playerSpawnBiomes.push_back(Biome::forestHills);
playerSpawnBiomes.push_back(Biome::jungle);
playerSpawnBiomes.push_back(Biome::jungleHills);
playerSpawnBiomes.push_back(Biome::savanna);
}
void BiomeSource::_init(int64_t seed, LevelType *generator)

View file

@ -4,99 +4,157 @@
#include "net.minecraft.world.level.tile.h"
#include "TreeTile2.h"
#include "LeafTile2.h"
#include <cmath>
DarkOakFeature::DarkOakFeature(bool doUpdate) : Feature(doUpdate)
{
this->baseHeight = 6;
#include <algorithm>
DarkOakFeature::DarkOakFeature(bool doUpdate) : Feature(doUpdate) {
this->baseHeight = 6;
}
bool DarkOakFeature::place(Level *level, Random *random, int x, int y, int z)
{
int treeHeight = random->nextInt(3) + baseHeight;
if (y < 1 || y + treeHeight + 1 > Level::maxBuildHeight) return false;
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;
for (int ix = 0; ix <= 1; ix++) {
for (int iz = 0; iz <= 1; iz++) {
int below = level->getTile(x + ix, y - 1, z + iz);
if (below != Tile::grass_Id && below != Tile::dirt_Id) return false;
}
}
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);
int dx = random->nextInt(3) - 1;
int dz = random->nextInt(3) - 1;
int bendStart = treeHeight - random->nextInt(4);
int bendLength = 2 - random->nextInt(3);
if (!(isSoil && k < Level::maxBuildHeight - i - 1)) {
return false;
} else if (!this->checkSpace(worldIn, j, k, l, i)) {
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 curX = x;
int curZ = z;
int i1 = i - rand->nextInt(4);
int j1 = 2 - rand->nextInt(3);
int k1 = j;
int l1 = l;
int i2 = k + i - 1;
for (int h = 0; h < treeHeight; h++)
{
if (h >= bendStart && bendLength > 0)
{
curX += dx;
curZ += dz;
bendLength--;
}
placeTrunk2x2(level, curX, y + h, curZ);
}
int topY = y + treeHeight;
for (int lx = -2; lx <= 3; lx++)
{
for (int lz = -2; lz <= 3; lz++)
{
for (int ly = -1; ly <= 1; ly++)
{
if ((lx == -2 && lz == -2) || (lx == 3 && lz == -2) || (lx == -2 && lz == 3) || (lx == 3 && lz == 3))
if (ly != 0) continue;
placeLeaf(level, curX + lx, topY + ly, curZ + lz);
for (int j2 = 0; j2 < i; ++j2) {
if (j2 >= i1 && j1 > 0) {
k1 += dirX;
l1 += dirZ;
--j1;
}
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);
}
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);
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);
}
}
}
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);
}
}
}
for (int k3 = -1; k3 <= 2; ++k3) {
for (int j4 = -1; j4 <= 2; ++j4) {
if ((k3 < 0 || k3 > 1 || j4 < 0 || j4 > 1) && rand->nextInt(3) <= 0) {
int l4 = rand->nextInt(3) + 2;
for (int i5 = 0; i5 < l4; ++i5) {
this->placeLog(worldIn, j + k3, i2 - i5 - 1, l + 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);
}
}
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);
}
}
}
}
}
}
return true;
}
}
return false;
}
for (int rx = -1; rx <= 2; rx++)
{
for (int rz = -1; rz <= 2; rz++)
{
if ((rx < 0 || rx > 1 || rz < 0 || rz > 1) && random->nextInt(3) == 0)
{
int branchLen = random->nextInt(3) + 2;
for (int bh = 0; bh < branchLen; bh++)
{
placeBlock(level, x + rx, topY - bh - 1, z + rz, Tile::tree2Trunk_Id, TreeTile2::DARK_TRUNK);
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;
for (int j1 = -i1; j1 <= i1; ++j1) {
for (int k1 = -i1; k1 <= i1; ++k1) {
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) {
return false;
}
}
}
}
return true;
}
void DarkOakFeature::placeTrunk2x2(Level *level, int x, int y, int z)
{
void DarkOakFeature::placeLog(Level *worldIn, int x, int y, int z) {
int tile = worldIn->getTile(x, y, z);
placeBlock(level, x, y, z, Tile::tree2Trunk_Id, TreeTile2::DARK_TRUNK);
placeBlock(level, x + 1, y, z, Tile::tree2Trunk_Id, TreeTile2::DARK_TRUNK);
placeBlock(level, x, y, z + 1, Tile::tree2Trunk_Id, TreeTile2::DARK_TRUNK);
placeBlock(level, x + 1, y, z + 1, Tile::tree2Trunk_Id, TreeTile2::DARK_TRUNK);
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 *level, int x, int y, int z)
{
int tile = level->getTile(x, y, z);
if (tile == 0 || tile == Tile::leaves_Id || tile == Tile::leaves2_Id)
{
void DarkOakFeature::placeLeaf(Level *worldIn, int x, int y, int z) {
int tile = worldIn->getTile(x, y, z);
if (tile == 0) {
placeBlock(level, x, y, z, Tile::leaves2_Id, 1);
placeBlock(worldIn, x, y, z, Tile::leaves2_Id, 1);
}
}

View file

@ -14,4 +14,8 @@ private:
void placeTrunk2x2(Level *level, int x, int y, int z);
void placeLeaf(Level *level, int x, int y, int z);
private:
bool checkSpace(Level *worldIn, int x, int y, int z, int height);
void placeLog(Level *worldIn, int x, int y, int z);
};

View file

@ -2718,6 +2718,7 @@
<ClInclude Include="RotatedPillarTile.h" />
<ClInclude Include="SandTile.h" />
<ClInclude Include="Sapling2.h" />
<ClInclude Include="SavannaBiome.h" />
<ClInclude Include="SavannaTreeFeature.h" />
<ClInclude Include="Score.h" />
<ClInclude Include="Scoreboard.h" />
@ -3658,6 +3659,7 @@
<ClCompile Include="RotatedPillarTile.cpp" />
<ClCompile Include="SandTile.cpp" />
<ClCompile Include="Sapling2.cpp" />
<ClCompile Include="SavannaBiome.cpp" />
<ClCompile Include="SavannaTreeFeature.cpp" />
<ClCompile Include="Score.cpp" />
<ClCompile Include="Scoreboard.cpp" />

View file

@ -824,6 +824,7 @@
<ClCompile Include="Sapling2.cpp" />
<ClCompile Include="SavannaTreeFeature.cpp" />
<ClCompile Include="DarkOakFeature.cpp" />
<ClCompile Include="SavannaBiome.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AABB.h" />
@ -1817,6 +1818,7 @@
<ClInclude Include="Sapling2.h" />
<ClInclude Include="SavannaTreeFeature.h" />
<ClInclude Include="DarkOakFeature.h" />
<ClInclude Include="SavannaBiome.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\Minecraft.Client\Xbox\res\audio\Minecraft.xgs" />

View file

@ -0,0 +1,30 @@
#include "stdafx.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 "SavannaBiome.h"
#include "SavannaTreeFeature.h"
SavannaBiome::SavannaBiome(int id) : Biome(id)
{
friendlies.push_back(new MobSpawnerData(eTYPE_HORSE, 1, 2, 6));
decorator->treeCount = 1;
decorator->flowerCount = 4;
decorator->grassCount = 20;
}
Feature *SavannaBiome::getTreeFeature(Random *random)
{
if (random->nextInt(5) > 0)
{
return new SavannaTreeFeature(false);
}
return new TreeFeature(false);
}

View file

@ -0,0 +1,10 @@
#pragma once
#include "Biome.h"
class SavannaBiome : public Biome
{
public:
SavannaBiome(int id);
virtual Feature *getTreeFeature(Random *random);
};

View file

@ -29,4 +29,7 @@
#include "BeachBiome.h"
//1.2.3
#include "JungleBiome.h"
#include "JungleBiome.h"
//TU31
#include "SavannaBiome.h"