5 New Technical Biomes
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#include "stdafx.h"
|
||||
#include "DoublePlantFeature.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
#include "net.minecraft.world.level.tile.h"
|
||||
#include "TallGrass2.h"
|
||||
|
||||
DoublePlantFeature::DoublePlantFeature(bool doUpdate)
|
||||
: Feature(doUpdate), m_plantType(0)
|
||||
{
|
||||
}
|
||||
|
||||
void DoublePlantFeature::setPlantType(int plantType)
|
||||
{
|
||||
m_plantType = plantType;
|
||||
}
|
||||
|
||||
bool DoublePlantFeature::place(Level* level, Random* rand, int x, int y, int z)
|
||||
{
|
||||
bool placed = false;
|
||||
|
||||
for (int i = 0; i < 64; ++i)
|
||||
{
|
||||
int bx = x + rand->nextInt(8) - rand->nextInt(8);
|
||||
int by = y + rand->nextInt(4) - rand->nextInt(4);
|
||||
int bz = z + rand->nextInt(8) - rand->nextInt(8);
|
||||
|
||||
if (by >= Level::maxBuildHeight - 1) continue;
|
||||
if (by < 1) continue;
|
||||
|
||||
if (level->getTile(bx, by, bz) != 0) continue;
|
||||
if (level->getTile(bx, by + 1, bz) != 0) continue;
|
||||
|
||||
|
||||
if (!static_cast<TallGrass2*>(Tile::tiles[Tile::tallgrass2_Id])->mayPlace(level, bx, by, bz)) continue;
|
||||
|
||||
level->setTileAndData(bx, by, bz, Tile::tallgrass2_Id, m_plantType, Tile::UPDATE_ALL);
|
||||
level->setTileAndData(bx, by + 1, bz, Tile::tallgrass2_Id, m_plantType | TallGrass2::UPPER_BIT, Tile::UPDATE_ALL);
|
||||
|
||||
placed = true;
|
||||
}
|
||||
|
||||
return placed;
|
||||
}
|
||||
Reference in New Issue
Block a user