Mountains fixes & caves feature
This commit is contained in:
parent
48a83f5047
commit
5228d778c8
7 changed files with 97 additions and 54 deletions
|
@ -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