Mountains fixes & caves feature
This commit is contained in:
parent
48a83f5047
commit
5228d778c8
7 changed files with 97 additions and 54 deletions
|
@ -20,7 +20,7 @@ public class BiomeChorusForest extends EndBiome {
|
|||
.setLoop(SoundRegistry.AMBIENT_CHORUS_FOREST)
|
||||
.setMusic(SoundRegistry.MUSIC_CHORUS_FOREST)
|
||||
.addFeature(FeatureRegistry.VIOLECITE_LAYER)
|
||||
.addFeature(FeatureRegistry.RARE_END_LAKE)
|
||||
.addFeature(FeatureRegistry.END_LAKE_RARE)
|
||||
.addFeature(FeatureRegistry.PYTHADENDRON_TREE)
|
||||
.addFeature(FeatureRegistry.PYTHADENDRON_BUSH)
|
||||
.addFeature(Feature.VEGETAL_DECORATION, ConfiguredFeatures.CHORUS_PLANT)
|
||||
|
|
66
src/main/java/ru/betterend/world/features/RoundCave.java
Normal file
66
src/main/java/ru/betterend/world/features/RoundCave.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package ru.betterend.world.features;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.BlockTagRegistry;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class RoundCave extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
int radius = MHelper.randRange(10, 30, random);
|
||||
int bottom = BlocksHelper.upRay(world, new BlockPos(pos.getX(), 0, pos.getZ()), 32) + radius;
|
||||
int top = world.getTopY(Heightmap.Type.WORLD_SURFACE, pos.getX(), pos.getZ()) - radius;
|
||||
if (top <= bottom) {
|
||||
return false;
|
||||
}
|
||||
pos = new BlockPos(pos.getX(), MHelper.randRange(bottom, top, random), pos.getZ());
|
||||
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, pos.getX(), pos.getZ()));
|
||||
|
||||
int x1 = pos.getX() - radius;
|
||||
int z1 = pos.getZ() - radius;
|
||||
int x2 = pos.getX() + radius;
|
||||
int z2 = pos.getZ() + radius;
|
||||
int y1 = MHelper.floor(pos.getY() - radius / 1.6);
|
||||
int y2 = MHelper.floor(pos.getY() + radius / 1.6);
|
||||
|
||||
double hr = radius * 0.75;
|
||||
double nr = radius * 0.25;
|
||||
|
||||
Mutable bpos = new Mutable();
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
int xsq = x - pos.getX();
|
||||
xsq *= xsq;
|
||||
bpos.setX(x);
|
||||
for (int z = z1; z <= z2; z++) {
|
||||
int zsq = z - pos.getZ();
|
||||
zsq *= zsq;
|
||||
bpos.setZ(z);
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
int ysq = y - pos.getY();
|
||||
ysq *= 1.6;
|
||||
ysq *= ysq;
|
||||
bpos.setY(y);
|
||||
double r = noise.eval(x * 0.1, y * 0.1, z * 0.1) * nr + hr;
|
||||
double dist = xsq + ysq + zsq;
|
||||
if (dist < r * r) {
|
||||
if (world.getBlockState(bpos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
BlocksHelper.setWithoutUpdate(world, bpos, AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@ import net.minecraft.world.gen.chunk.ChunkGenerator;
|
|||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.world.structures.piece.CavePiece;
|
||||
import ru.betterend.world.structures.piece.MountainPiece;
|
||||
|
||||
public class StructureMountain extends StructureFeatureBase {
|
||||
|
@ -30,30 +29,11 @@ public class StructureMountain extends StructureFeatureBase {
|
|||
int x = (chunkX << 4) | MHelper.randRange(4, 12, random);
|
||||
int z = (chunkZ << 4) | MHelper.randRange(4, 12, random);
|
||||
int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG);
|
||||
if (y > 5) {
|
||||
if (y > 50) {
|
||||
float radius = MHelper.randRange(50, 100, random);
|
||||
float height = radius * MHelper.randRange(0.8F, 1.2F, random);
|
||||
MountainPiece piece = new MountainPiece(new BlockPos(x, y, z), radius, height, random.nextInt());
|
||||
this.children.add(piece);
|
||||
|
||||
int count = (int) (radius / 15);
|
||||
for (int i = 0; i < count; i++) {
|
||||
double px = random.nextGaussian() * radius * 0.5 + x;
|
||||
double pz = random.nextGaussian() * radius * 0.5 + z;
|
||||
float rad = MHelper.randRange(10, 30, random);
|
||||
|
||||
int posX = MHelper.floor(px);
|
||||
int posZ = MHelper.floor(pz);
|
||||
|
||||
int minY = chunkGenerator.getHeight(posX, posZ, Type.WORLD_SURFACE_WG);
|
||||
if (minY > 56) {
|
||||
int maxY = MHelper.floor(piece.getProtoHeight(posX, minY, posZ) - rad);
|
||||
if (maxY > 20) {
|
||||
int posY = MHelper.randRange(20, maxY, random);
|
||||
this.children.add(new CavePiece(new BlockPos(posX, posY, posZ), rad, random.nextInt()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setBoundingBoxFromChildren();
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class MountainPiece extends BasePiece {
|
|||
if (maxY > 0) {
|
||||
maxY *= (float) noise.eval(px * 0.05, pz * 0.05) * 0.3F + 0.7F;
|
||||
maxY *= (float) noise.eval(px * 0.1, pz * 0.1) * 0.1F + 0.8F;
|
||||
maxY += minY;
|
||||
maxY += 56;
|
||||
for (int y = minY; y < maxY; y++) {
|
||||
pos.setY(y);
|
||||
chunk.setBlockState(pos, Blocks.END_STONE.getDefaultState(), false);
|
||||
|
@ -111,7 +111,7 @@ public class MountainPiece extends BasePiece {
|
|||
int y = map.get(x, z);
|
||||
if (y > 80) {
|
||||
pos.set(x, y, z);
|
||||
if (chunk.getBlockState(pos.down()).getBlock() == Blocks.END_STONE) {
|
||||
if (chunk.getBlockState(pos.down()).isOf(Blocks.END_STONE)) {
|
||||
int height = MHelper.floor(radius * MHelper.randRange(1.5F, 3F, random) + (y - 80) * 0.3F);
|
||||
crystal(chunk, pos, radius, height, fill, random);
|
||||
}
|
||||
|
@ -139,27 +139,6 @@ public class MountainPiece extends BasePiece {
|
|||
return true;
|
||||
}
|
||||
|
||||
public int getProtoHeight(int px, int py, int pz) {
|
||||
int px2 = px - center.getX();
|
||||
px2 *= px2;
|
||||
|
||||
int pz2 = pz - center.getZ();
|
||||
pz2 *= pz2;
|
||||
float dist = px2 + pz2;
|
||||
|
||||
dist = 1 - (float) Math.pow(dist / r2, 0.3);
|
||||
if (py > 56) {
|
||||
float maxY = dist * height;
|
||||
if (maxY > 0) {
|
||||
maxY *= (float) noise.eval(px * 0.05, pz * 0.05) * 0.3F + 0.7F;
|
||||
maxY *= (float) noise.eval(px * 0.1, pz * 0.1) * 0.1F + 0.8F;
|
||||
return MHelper.floor(maxY + py * ((float) MathHelper.clamp((py - 57) / 7F, 0, 1)));
|
||||
}
|
||||
}
|
||||
|
||||
return py;
|
||||
}
|
||||
|
||||
private int getHeight(StructureWorldAccess world, BlockPos pos) {
|
||||
if (BiomeRegistry.getFromBiome(world.getBiome(pos)) != BiomeRegistry.END_HIGHLANDS) {
|
||||
return -4;
|
||||
|
@ -218,6 +197,9 @@ public class MountainPiece extends BasePiece {
|
|||
int az = Math.abs(z);
|
||||
if (ax + az < max) {
|
||||
int minY = map.get(mut.getX(), mut.getZ()) - MHelper.randRange(3, 7, random);
|
||||
if (pos.getY() - minY > 8) {
|
||||
minY = pos.getY() - 8;
|
||||
}
|
||||
int h = coefX * x + coefZ * z + height;
|
||||
for (int y = minY; y < h; y++) {
|
||||
mut.setY(y);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue