mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-06-09 00:33:00 +00:00
reworked the mossyclobblestone feature
This commit is contained in:
parent
8111c594f1
commit
1767c635fe
64
Minecraft.World/BlockBlobFeature.cpp
Normal file
64
Minecraft.World/BlockBlobFeature.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#include "stdafx.h"
|
||||
#include "BlockBlobFeature.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
#include "net.minecraft.world.level.tile.h"
|
||||
|
||||
BlockBlobFeature::BlockBlobFeature(int blockId, int startRadius) : Feature(false)
|
||||
{
|
||||
this->blockId = blockId;
|
||||
this->startRadius = startRadius;
|
||||
}
|
||||
|
||||
bool BlockBlobFeature::place(Level *level, Random *random, int x, int y, int z)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (y > 3)
|
||||
{
|
||||
int tileBelow = level->getTile(x, y - 1, z);
|
||||
if (tileBelow != 0 && (tileBelow == Tile::grass_Id || tileBelow == Tile::dirt_Id || tileBelow == Tile::stone_Id))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (y <= 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
y--;
|
||||
}
|
||||
|
||||
int radius = this->startRadius;
|
||||
|
||||
for (int step = 0; radius >= 0 && step < 3; ++step)
|
||||
{
|
||||
int rX = radius + random->nextInt(2);
|
||||
int rY = radius + random->nextInt(2);
|
||||
int rZ = radius + random->nextInt(2);
|
||||
|
||||
float limit = (float)(rX + rY + rZ) * 0.333F + 0.5F;
|
||||
|
||||
for (int dx = x - rX; dx <= x + rX; ++dx)
|
||||
{
|
||||
for (int dy = y - rY; dy <= y + rY; ++dy)
|
||||
{
|
||||
for (int dz = z - rZ; dz <= z + rZ; ++dz)
|
||||
{
|
||||
float distSq = (dx - x) * (dx - x) + (dy - y) * (dy - y) + (dz - z) * (dz - z);
|
||||
|
||||
if (distSq <= limit * limit)
|
||||
{
|
||||
placeBlock(level, dx, dy, dz, this->blockId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x += -(radius + 1) + random->nextInt(2 + radius * 2);
|
||||
y += -random->nextInt(2);
|
||||
z += -(radius + 1) + random->nextInt(2 + radius * 2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
13
Minecraft.World/BlockBlobFeature.h
Normal file
13
Minecraft.World/BlockBlobFeature.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
#include "Feature.h"
|
||||
|
||||
class BlockBlobFeature : public Feature
|
||||
{
|
||||
private:
|
||||
int blockId;
|
||||
int startRadius;
|
||||
|
||||
public:
|
||||
BlockBlobFeature(int blockId, int startRadius);
|
||||
bool place(Level* level, Random* random, int x, int y, int z)override;;
|
||||
};
|
||||
|
|
@ -11,7 +11,7 @@ set(MINECRAFT_WORLD_SOURCES
|
|||
${SOURCES_COMMON}
|
||||
)
|
||||
|
||||
add_library(Minecraft.World STATIC ${MINECRAFT_WORLD_SOURCES} "IceSpikeFeature.cpp" "IceSpikeFeature.h")
|
||||
add_library(Minecraft.World STATIC ${MINECRAFT_WORLD_SOURCES} "IceSpikeFeature.cpp" "IceSpikeFeature.h" "BlockBlobFeature.h" "BlockBlobFeature.cpp")
|
||||
|
||||
target_include_directories(Minecraft.World
|
||||
PRIVATE
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "Level.h"
|
||||
#include "Random.h"
|
||||
#include "MegaPineTreeFeature.h"
|
||||
#include <BlockBlobFeature.h>
|
||||
|
||||
TaigaBiome::TaigaBiome(int id, int type) : Biome(id)
|
||||
{
|
||||
|
|
@ -52,23 +53,15 @@ void TaigaBiome::decorate(Level *level, Random *random, int xo, int zo)
|
|||
{
|
||||
if (type == 1 || type == 2)
|
||||
{
|
||||
BlockBlobFeature mossyBoulder(Tile::mossyCobblestone_Id, 0);
|
||||
int count = random->nextInt(3);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
int y = level->getHeightmap(x, z);
|
||||
|
||||
for (int dx = -1; dx <= 1; ++dx) {
|
||||
for (int dy = -1; dy <= 1; ++dy) {
|
||||
for (int dz = -1; dz <= 1; ++dz) {
|
||||
int tileAt = level->getTile(x + dx, y + dy, z + dz);
|
||||
if (random->nextInt(4) != 0 && (tileAt == 0 || tileAt == Tile::grass_Id)) {
|
||||
level->setTileAndData(x + dx, y + dy, z + dz, Tile::mossyCobblestone_Id, 0, Tile::UPDATE_CLIENTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mossyBoulder.place(level, random, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue