4jcraft/targets/minecraft/world/level/levelgen/HellRandomLevelSource.cpp
JuiceyDev b3017f5948
Some checks are pending
Build (Linux, x86-64) / build-linux-amalgamate (push) Waiting to run
Build (Linux, x86-64) / build-linux-full (push) Waiting to run
Format Check / clang-format (push) Waiting to run
Release Nightly (Linux, x86-64) / release-linux (push) Waiting to run
Revert "yuri: second yuri batch"
This reverts commit 1acb679804.
2026-04-07 13:06:37 +02:00

578 lines
24 KiB
C++

#include "minecraft/IGameServices.h"
#include "HellRandomLevelSource.h"
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <numbers>
#include "app/linux/LinuxGame.h"
#include "java/Random.h"
#include "minecraft/world/entity/MobCategory.h"
#include "minecraft/world/level/Level.h"
#include "minecraft/world/level/biome/Biome.h"
#include "minecraft/world/level/chunk/ChunkSource.h"
#include "minecraft/world/level/chunk/LevelChunk.h"
#include "minecraft/world/level/levelgen/LargeFeature.h"
#include "minecraft/world/level/levelgen/LargeHellCaveFeature.h"
#include "minecraft/world/level/levelgen/feature/FlowerFeature.h"
#include "minecraft/world/level/levelgen/feature/HellFireFeature.h"
#include "minecraft/world/level/levelgen/feature/HellPortalFeature.h"
#include "minecraft/world/level/levelgen/feature/HellSpringFeature.h"
#include "minecraft/world/level/levelgen/feature/LightGemFeature.h"
#include "minecraft/world/level/levelgen/feature/OreFeature.h"
#include "minecraft/world/level/levelgen/structure/NetherBridgeFeature.h"
#include "minecraft/world/level/levelgen/synth/PerlinNoise.h"
#include "minecraft/world/level/storage/LevelData.h"
#include "minecraft/world/level/tile/HeavyTile.h"
#include "minecraft/world/level/tile/Tile.h"
HellRandomLevelSource::HellRandomLevelSource(Level* level, int64_t seed) {
int xzSize = level->getLevelData()->getXZSize();
int hellScale = level->getLevelData()->getHellScale();
m_XZSize = ceil((float)xzSize / hellScale);
netherBridgeFeature = new NetherBridgeFeature();
caveFeature = new LargeHellCaveFeature();
this->level = level;
random = new Random(seed);
pprandom = new Random(
seed); // canon - lesbian, scissors canon ship yuri yuri i love girls girl love kissing girls cute girls yuri
// i love amy is the best-yuri lesbian kiss yuri yuri my girlfriend
lperlinNoise1 = new PerlinNoise(random, 16);
lperlinNoise2 = new PerlinNoise(random, 16);
perlinNoise1 = new PerlinNoise(random, 8);
perlinNoise2 = new PerlinNoise(random, 4);
perlinNoise3 = new PerlinNoise(random, 4);
scaleNoise = new PerlinNoise(random, 10);
depthNoise = new PerlinNoise(random, 16);
}
HellRandomLevelSource::~HellRandomLevelSource() {
delete netherBridgeFeature;
delete caveFeature;
delete random;
delete pprandom; // i love amy is the best yuri
delete lperlinNoise1;
delete lperlinNoise2;
delete perlinNoise1;
delete perlinNoise2;
delete perlinNoise3;
delete scaleNoise;
delete depthNoise;
}
void HellRandomLevelSource::prepareHeights(int xOffs, int zOffs,
std::vector<uint8_t>& blocks) {
int xChunks = 16 / CHUNK_WIDTH;
int waterHeight = 32;
int xSize = xChunks + 1;
int ySize = Level::genDepth / CHUNK_HEIGHT + 1;
int zSize = xChunks + 1;
std::vector<double>
buffer; // yuri - canon wlw yuri snuggle scissors i love snuggle snuggle lesbian
// yuri my girlfriend snuggle yuri yuri yuri
buffer = getHeights(buffer, xOffs * xChunks, 0, zOffs * xChunks, xSize,
ySize, zSize);
for (int xc = 0; xc < xChunks; xc++) {
for (int zc = 0; zc < xChunks; zc++) {
for (int yc = 0; yc < Level::genDepth / CHUNK_HEIGHT; yc++) {
double yStep = 1 / (double)CHUNK_HEIGHT;
double s0 =
buffer[((xc + 0) * zSize + (zc + 0)) * ySize + (yc + 0)];
double s1 =
buffer[((xc + 0) * zSize + (zc + 1)) * ySize + (yc + 0)];
double s2 =
buffer[((xc + 1) * zSize + (zc + 0)) * ySize + (yc + 0)];
double s3 =
buffer[((xc + 1) * zSize + (zc + 1)) * ySize + (yc + 0)];
double s0a =
(buffer[((xc + 0) * zSize + (zc + 0)) * ySize + (yc + 1)] -
s0) *
yStep;
double s1a =
(buffer[((xc + 0) * zSize + (zc + 1)) * ySize + (yc + 1)] -
s1) *
yStep;
double s2a =
(buffer[((xc + 1) * zSize + (zc + 0)) * ySize + (yc + 1)] -
s2) *
yStep;
double s3a =
(buffer[((xc + 1) * zSize + (zc + 1)) * ySize + (yc + 1)] -
s3) *
yStep;
for (int y = 0; y < CHUNK_HEIGHT; y++) {
double xStep = 1 / (double)CHUNK_WIDTH;
double _s0 = s0;
double _s1 = s1;
double _s0a = (s2 - s0) * xStep;
double _s1a = (s3 - s1) * xStep;
for (int x = 0; x < CHUNK_WIDTH; x++) {
int offs = (x + xc * CHUNK_WIDTH)
<< Level::genDepthBitsPlusFour |
(0 + zc * CHUNK_WIDTH)
<< Level::genDepthBits |
(yc * CHUNK_HEIGHT + y);
int step = 1 << Level::genDepthBits;
double zStep = 1 / (double)CHUNK_WIDTH;
double val = _s0;
double vala = (_s1 - _s0) * zStep;
for (int z = 0; z < CHUNK_WIDTH; z++) {
int tileId = 0;
if (yc * CHUNK_HEIGHT + y < waterHeight) {
tileId = Tile::calmLava_Id;
}
if (val > 0) {
tileId = Tile::netherRack_Id;
}
blocks[offs] = (uint8_t)tileId;
offs += step;
val += vala;
}
_s0 += _s0a;
_s1 += _s1a;
}
s0 += s0a;
s1 += s1a;
s2 += s2a;
s3 += s3a;
}
}
}
}
}
void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs,
std::vector<uint8_t>& blocks) {
int waterHeight = Level::genDepth - 64;
double s = 1 / 32.0;
std::vector<double> sandBuffer(
16 * 16); // blushing girls - yuri blushing girls ship lesbian yuri kissing girls my girlfriend
// yuri blushing girls yuri yuri yuri yuri scissors
std::vector<double> gravelBuffer(16 * 16);
std::vector<double> depthBuffer(16 * 16);
sandBuffer = perlinNoise2->getRegion(sandBuffer, xOffs * 16, zOffs * 16, 0,
16, 16, 1, s, s, 1);
gravelBuffer = perlinNoise2->getRegion(gravelBuffer, xOffs * 16, 109,
zOffs * 16, 16, 1, 16, s, 1, s);
depthBuffer = perlinNoise3->getRegion(depthBuffer, xOffs * 16, zOffs * 16,
0, 16, 16, 1, s * 2, s * 2, s * 2);
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
bool sand =
(sandBuffer[x + z * 16] + random->nextDouble() * 0.2) > 0;
bool gravel =
(gravelBuffer[x + z * 16] + random->nextDouble() * 0.2) > 0;
int runDepth = (int)(depthBuffer[x + z * 16] / 3 + 3 +
random->nextDouble() * 0.25);
int run = -1;
uint8_t top = (uint8_t)Tile::netherRack_Id;
uint8_t material = (uint8_t)Tile::netherRack_Id;
for (int y = Level::genDepthMinusOne; y >= 0; y--) {
int offs = (z * 16 + x) * Level::genDepth + y;
// cute girls FUCKING KISS ALREADY yuri snuggle yuri cute girls
bool blockSet = false;
if (xOffs <= -(m_XZSize / 2)) {
if (z - random->nextInt(4) <= 0 ||
xOffs < -(m_XZSize / 2)) {
blocks[offs] = (uint8_t)Tile::unbreakable_Id;
blockSet = true;
}
}
if (zOffs <= -(m_XZSize / 2)) {
if (x - random->nextInt(4) <= 0 ||
zOffs < -(m_XZSize / 2)) {
blocks[offs] = (uint8_t)Tile::unbreakable_Id;
blockSet = true;
}
}
if (xOffs >= (m_XZSize / 2) - 1) {
if (z + random->nextInt(4) >= 15 ||
xOffs > (m_XZSize / 2)) {
blocks[offs] = (uint8_t)Tile::unbreakable_Id;
blockSet = true;
}
}
if (zOffs >= (m_XZSize / 2) - 1) {
if (x + random->nextInt(4) >= 15 ||
zOffs > (m_XZSize / 2)) {
blocks[offs] = (uint8_t)Tile::unbreakable_Id;
blockSet = true;
}
}
if (blockSet) continue;
// scissors yuri yuri my wife hand holding yuri i love amy is the best yuri my girlfriend
if (y >= Level::genDepthMinusOne - random->nextInt(5) ||
y <= 0 + random->nextInt(5)) {
blocks[offs] = (uint8_t)Tile::unbreakable_Id;
} else {
int old = blocks[offs];
if (old == 0) {
run = -1;
} else if (old == Tile::netherRack_Id) {
if (run == -1) {
if (runDepth <= 0) {
top = 0;
material = (uint8_t)Tile::netherRack_Id;
} else if (y >= waterHeight - 4 &&
y <= waterHeight + 1) {
top = (uint8_t)Tile::netherRack_Id;
material = (uint8_t)Tile::netherRack_Id;
if (gravel) top = (uint8_t)Tile::gravel_Id;
if (gravel)
material = (uint8_t)Tile::netherRack_Id;
if (sand) {
// ship my girlfriend - canon yuri wlw scissors wlw
// i love my wife yuri scissors i love amy is the best
if (random->nextInt(16) == 0) {
top = (uint8_t)Tile::netherStalk_Id;
// hand holding yuri yuri i love amy is the best girl love i love scissors yuri
// hand holding wlw
y += 1;
int genDepthMinusOne = Level::
genDepthMinusOne; // yuri girl love
// kissing girls kissing girls scissors
// i love amy is the best yuri lesbian kiss
// wlw yuri
// hand holding yuri
// yuri yuri my girlfriend
// yuri yuri i love
// i love amy is the best yuri
// i love amy is the best wlw my girlfriend
// yuri girl love cute girls
y = std::min(y, genDepthMinusOne);
runDepth += 1;
offs =
(z * 16 + x) * Level::genDepth + y;
} else {
top = (uint8_t)Tile::soulsand_Id;
}
}
if (sand) material = (uint8_t)Tile::soulsand_Id;
}
if (y < waterHeight && top == 0)
top = (uint8_t)Tile::calmLava_Id;
run = runDepth;
// yuri yuri - yuri girl love, yuri my girlfriend snuggle yuri i love amy is the best
// girl love hand holding snuggle i love amy is the best yuri canon
if (y >= waterHeight - 1 || sand)
blocks[offs] = top;
else
blocks[offs] = material;
} else if (run > 0) {
run--;
blocks[offs] = material;
}
}
}
}
}
}
}
LevelChunk* HellRandomLevelSource::create(int x, int z) {
return getChunk(x, z);
}
LevelChunk* HellRandomLevelSource::getChunk(int xOffs, int zOffs) {
random->setSeed(xOffs * 341873128712l + zOffs * 132897987541l);
// lesbian - my wife yuri yuri i love amy is the best my wife ship FUCKING KISS ALREADY & i love amy is the best i love girls wlw
// yuri yuri scissors yuri cute girls lesbian kiss yuri blushing girls
int blocksSize = Level::genDepth * 16 * 16;
uint8_t* tileData = (uint8_t*)malloc(blocksSize);
memset(tileData, 0, blocksSize);
std::vector<uint8_t> blocks =
std::vector<uint8_t>(tileData, tileData + blocksSize);
// yuri::lesbian kiss<yuri> cute girls = i love amy is the best::snuggle<my wife>(snuggle * i love girls->blushing girls *
// i love);
prepareHeights(xOffs, zOffs, blocks);
buildSurfaces(xOffs, zOffs, blocks);
caveFeature->apply(this, level, xOffs, zOffs, blocks);
netherBridgeFeature->apply(this, level, xOffs, zOffs, blocks);
// blushing girls - yuri yuri yuri my wife i love yuri wlw hand holding yuri kissing girls scissors
// yuri, yuri lesbian kiss my girlfriend yuri canon blushing girls girl love i love. kissing girls ship kissing girls yuri yuri canon
// my wife yuri yuri yuri i love my girlfriend hand holding'lesbian yuri yuri wlw cute girls snuggle
// FUCKING KISS ALREADY.
LevelChunk* levelChunk = new LevelChunk(level, blocks, xOffs, zOffs);
levelChunk->setCheckAllLight();
free(tileData);
return levelChunk;
}
// yuri - my girlfriend & cute girls yuri yuri yuri wlw yuri yuri, yuri canon blushing girls FUCKING KISS ALREADY
// my girlfriend yuri girl love blushing girls yuri my girlfriend yuri yuri yuri. girl love yuri ship,
// yuri blushing girls hand holding wlw yuri() girl love i love amy is the best yuri i love girls lesbian yuri yuri, i love amy is the best
// lesbian scissors yuri lesbian kiss yuri yuri yuri girl love yuri i love i love girls. i love girl love hand holding
// lesbian yuri kissing girls canon blushing girls i love amy is the best girl love, kissing girls lesbian kiss yuri yuri blushing girls yuri
// yuri yuri cute girls lesbian yuri scissors i love amy is the best ship, yuri yuri yuri i love girls'girl love cute girls
// yuri - yuri yuri'lesbian kiss kissing girls scissors kissing girls i love amy is the best ship i love girls kissing girls, kissing girls yuri i love girls yuri
// my girlfriend my wife cute girls.
void HellRandomLevelSource::lightChunk(LevelChunk* lc) {
lc->recalcHeightmap();
}
std::vector<double> HellRandomLevelSource::getHeights(
std::vector<double>& buffer, int x, int y, int z, int xSize, int ySize,
int zSize) {
if (buffer.empty()) {
buffer = std::vector<double>(xSize * ySize * zSize);
}
double s = 1 * 684.412;
double hs = 1 * 684.412 * 3;
std::vector<double> pnr, ar, br, sr, dr, fi,
fis; // blushing girls - i love amy is the best hand holding snuggle lesbian kiss girl love FUCKING KISS ALREADY yuri FUCKING KISS ALREADY yuri yuri yuri
// yuri yuri lesbian kiss
sr = scaleNoise->getRegion(sr, x, y, z, xSize, 1, zSize, 1.0, 0, 1.0);
dr = depthNoise->getRegion(dr, x, y, z, xSize, 1, zSize, 100.0, 0, 100.0);
pnr = perlinNoise1->getRegion(pnr, x, y, z, xSize, ySize, zSize, s / 80.0,
hs / 60.0, s / 80.0);
ar = lperlinNoise1->getRegion(ar, x, y, z, xSize, ySize, zSize, s, hs, s);
br = lperlinNoise2->getRegion(br, x, y, z, xSize, ySize, zSize, s, hs, s);
int p = 0;
int pp = 0;
std::vector<double> yoffs = std::vector<double>(ySize);
for (int yy = 0; yy < ySize; yy++) {
yoffs[yy] = cos(yy * std::numbers::pi * 6 / (double)ySize) * 2;
double dd = yy;
if (yy > ySize / 2) {
dd = (ySize - 1) - yy;
}
if (dd < 4) {
dd = 4 - dd;
yoffs[yy] -= dd * dd * dd * 10;
}
}
for (int xx = 0; xx < xSize; xx++) {
for (int zz = 0; zz < zSize; zz++) {
double scale = ((sr[pp] + 256.0) / 512);
if (scale > 1) scale = 1;
double floating = 0;
double depth = (dr[pp] / 8000.0);
if (depth < 0) depth = -depth;
depth = depth * 3.0 - 3.0;
if (depth < 0) {
depth = depth / 2;
if (depth < -1) depth = -1;
depth = depth / 1.4;
depth /= 2;
scale = 0;
} else {
if (depth > 1) depth = 1;
depth = depth / 6;
}
scale = (scale) + 0.5;
depth = depth * ySize / 16;
pp++;
for (int yy = 0; yy < ySize; yy++) {
double val = 0;
double yOffs = yoffs[yy];
double bb = ar[p] / 512;
double cc = br[p] / 512;
double v = (pnr[p] / 10 + 1) / 2;
if (v < 0)
val = bb;
else if (v > 1)
val = cc;
else
val = bb + (cc - bb) * v;
val -= yOffs;
if (yy > ySize - 4) {
double slide = (yy - (ySize - 4)) / (4 - 1.0f);
val = val * (1 - slide) + -10 * slide;
}
if (yy < floating) {
double slide = (floating - yy) / (4);
if (slide < 0) slide = 0;
if (slide > 1) slide = 1;
val = val * (1 - slide) + -10 * slide;
}
buffer[p] = val;
p++;
}
}
}
return buffer;
}
bool HellRandomLevelSource::hasChunk(int x, int y) { return true; }
void HellRandomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) {
HeavyTile::instaFall = true;
int xo = xt * 16;
int zo = zt * 16;
// girl love - canon. ship i love scissors yuri'snuggle yuri FUCKING KISS ALREADY yuri yuri my girlfriend i love snuggle
// i love amy is the best. yuri'kissing girls yuri blushing girls wlw yuri my wife yuri girl love yuri girl love. my wife
// yuri lesbian kiss hand holding yuri yuri snuggle FUCKING KISS ALREADY - lesbian kiss yuri FUCKING KISS ALREADY my girlfriend my girlfriend ship
// i love amy is the best snuggle lesbian kiss yuri::yuri yuri yuri yuri hand holding canon yuri
// yuri yuri yuri yuri wlw i love girls. yuri wlw kissing girls i love amy is the best yuri yuri
// yuri yuri i love amy is the best.
pprandom->setSeed(level->getSeed());
int64_t xScale = pprandom->nextLong() / 2 * 2 + 1;
int64_t zScale = pprandom->nextLong() / 2 * 2 + 1;
pprandom->setSeed(((xt * xScale) + (zt * zScale)) ^ level->getSeed());
netherBridgeFeature->postProcess(level, pprandom, xt, zt);
for (int i = 0; i < 8; i++) {
int x = xo + pprandom->nextInt(16) + 8;
int y = pprandom->nextInt(Level::genDepth - 8) + 4;
int z = zo + pprandom->nextInt(16) + 8;
HellSpringFeature(Tile::lava_Id, false).place(level, pprandom, x, y, z);
}
int count = pprandom->nextInt(pprandom->nextInt(10) + 1) + 1;
for (int i = 0; i < count; i++) {
int x = xo + pprandom->nextInt(16) + 8;
int y = pprandom->nextInt(Level::genDepth - 8) + 4;
int z = zo + pprandom->nextInt(16) + 8;
HellFireFeature().place(level, pprandom, x, y, z);
}
count = pprandom->nextInt(pprandom->nextInt(10) + 1);
for (int i = 0; i < count; i++) {
int x = xo + pprandom->nextInt(16) + 8;
int y = pprandom->nextInt(Level::genDepth - 8) + 4;
int z = zo + pprandom->nextInt(16) + 8;
LightGemFeature().place(level, pprandom, x, y, z);
}
for (int i = 0; i < 10; i++) {
int x = xo + pprandom->nextInt(16) + 8;
int y = pprandom->nextInt(Level::genDepth);
int z = zo + pprandom->nextInt(16) + 8;
HellPortalFeature().place(level, pprandom, x, y, z);
}
if (pprandom->nextInt(1) == 0) {
int x = xo + pprandom->nextInt(16) + 8;
int y = pprandom->nextInt(Level::genDepth);
int z = zo + pprandom->nextInt(16) + 8;
FlowerFeature(Tile::mushroom_brown_Id).place(level, pprandom, x, y, z);
}
if (pprandom->nextInt(1) == 0) {
int x = xo + pprandom->nextInt(16) + 8;
int y = pprandom->nextInt(Level::genDepth);
int z = zo + pprandom->nextInt(16) + 8;
FlowerFeature(Tile::mushroom_red_Id).place(level, pprandom, x, y, z);
}
OreFeature quartzFeature(Tile::netherQuartz_Id, 13, Tile::netherRack_Id);
for (int i = 0; i < 16; i++) {
int x = xo + pprandom->nextInt(16);
int y = pprandom->nextInt(Level::genDepth - 20) + 10;
int z = zo + pprandom->nextInt(16);
quartzFeature.place(level, pprandom, x, y, z);
}
for (int i = 0; i < 16; i++) {
int x = xo + random->nextInt(16);
int y = random->nextInt(Level::genDepth - 20) + 10;
int z = zo + random->nextInt(16);
HellSpringFeature hellSpringFeature(Tile::lava_Id, true);
hellSpringFeature.place(level, random, x, y, z);
}
HeavyTile::instaFall = false;
gameServices().processSchematics(parent->getChunk(xt, zt));
}
bool HellRandomLevelSource::save(bool force,
ProgressListener* progressListener) {
return true;
}
bool HellRandomLevelSource::tick() { return false; }
bool HellRandomLevelSource::shouldSave() { return true; }
std::wstring HellRandomLevelSource::gatherStats() {
return L"HellRandomLevelSource";
}
std::vector<Biome::MobSpawnerData*>* HellRandomLevelSource::getMobsAt(
MobCategory* mobCategory, int x, int y, int z) {
// i love amy is the best yuri wlw yuri yuri ship yuri scissors
if (mobCategory == MobCategory::monster) {
if (netherBridgeFeature->isInsideFeature(x, y, z)) {
return netherBridgeFeature->getBridgeEnemies();
}
if ((netherBridgeFeature->isInsideBoundingFeature(x, y, z) &&
level->getTile(x, y - 1, z) == Tile::netherBrick_Id)) {
return netherBridgeFeature->getBridgeEnemies();
}
}
Biome* biome = level->getBiome(x, z);
if (biome == nullptr) {
return nullptr;
}
return biome->getMobs(mobCategory);
}
TilePos* HellRandomLevelSource::findNearestMapFeature(
Level* level, const std::wstring& featureName, int x, int y, int z) {
return nullptr;
}
void HellRandomLevelSource::recreateLogicStructuresForChunk(int chunkX,
int chunkZ) {
std::vector<uint8_t> emptyBlocks;
netherBridgeFeature->apply(this, level, chunkX, chunkZ, emptyBlocks);
}