Mountains fixes & caves feature
This commit is contained in:
parent
48a83f5047
commit
5228d778c8
7 changed files with 97 additions and 54 deletions
|
@ -5,6 +5,7 @@ import java.util.function.Supplier;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import ru.betterend.world.features.BlueVineFeature;
|
||||
|
@ -17,6 +18,7 @@ import ru.betterend.world.features.EndLotusLeafFeature;
|
|||
import ru.betterend.world.features.MossyGlowshroomFeature;
|
||||
import ru.betterend.world.features.PythadendronBushFeature;
|
||||
import ru.betterend.world.features.PythadendronTreeFeature;
|
||||
import ru.betterend.world.features.RoundCave;
|
||||
import ru.betterend.world.features.SinglePlantFeature;
|
||||
import ru.betterend.world.features.UnderwaterPlantFeature;
|
||||
import ru.betterend.world.features.VineFeature;
|
||||
|
@ -46,16 +48,25 @@ public class FeatureRegistry {
|
|||
|
||||
// Features //
|
||||
public static final EndFeature END_LAKE = EndFeature.makeLakeFeature("end_lake", new EndLakeFeature(), 4);
|
||||
public static final EndFeature RARE_END_LAKE = EndFeature.makeLakeFeature("rare_end_lake", new EndLakeFeature(), 40);
|
||||
public static final EndFeature END_LAKE_RARE = EndFeature.makeLakeFeature("end_lake_rare", new EndLakeFeature(), 40);
|
||||
public static final EndFeature ROUND_CAVE = EndFeature.makeRawGenFeature("round_cave", new RoundCave(), 2);
|
||||
public static final EndFeature ROUND_CAVE_RARE = EndFeature.makeRawGenFeature("round_cave_rare", new RoundCave(), 25);
|
||||
|
||||
// Ores //
|
||||
public static final EndFeature ENDER_ORE = EndFeature.makeOreFeature("ender_ore", BlockRegistry.ENDER_ORE, 6, 3, 0, 4, 96);
|
||||
public static final EndFeature VIOLECITE_LAYER = EndFeature.makeLayerFeature("violecite_layer", BlockRegistry.VIOLECITE, 15, 4, 96, 8);
|
||||
public static final EndFeature FLAVOLITE_LAYER = EndFeature.makeLayerFeature("flavolite_layer", BlockRegistry.FLAVOLITE, 12, 4, 96, 6);
|
||||
|
||||
public static void registerBiomeFeatures(Biome biome, List<List<Supplier<ConfiguredFeature<?, ?>>>> features) {
|
||||
public static void registerBiomeFeatures(Identifier id, Biome biome, List<List<Supplier<ConfiguredFeature<?, ?>>>> features) {
|
||||
addFeature(FLAVOLITE_LAYER, features);
|
||||
addFeature(ENDER_ORE, features);
|
||||
addFeature(ROUND_CAVE_RARE, features);
|
||||
|
||||
if (id.getNamespace().equals("minecraft")) {
|
||||
if (id.getPath().equals("end_highlands")) {
|
||||
addFeature(ROUND_CAVE, features);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addFeature(EndFeature feature, List<List<Supplier<ConfiguredFeature<?, ?>>>> features) {
|
||||
|
@ -64,7 +75,8 @@ public class FeatureRegistry {
|
|||
features.get(index).add(() -> {
|
||||
return feature.getFeatureConfigured();
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
List<Supplier<ConfiguredFeature<?, ?>>> newFeature = Lists.newArrayList();
|
||||
newFeature.add(() -> {
|
||||
return feature.getFeatureConfigured();
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Collection;
|
|||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.structure.StructurePieceType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.GenerationStep.Feature;
|
||||
|
@ -34,13 +35,15 @@ public class StructureRegistry {
|
|||
return Registry.register(Registry.STRUCTURE_PIECE, BetterEnd.makeID(id), pieceType);
|
||||
}
|
||||
|
||||
public static void registerBiomeStructures(Biome biome, Collection<Supplier<ConfiguredStructureFeature<?, ?>>> collection) {
|
||||
if (BiomeRegistry.getFromBiome(biome) == BiomeRegistry.END_HIGHLANDS) {
|
||||
addFeature(MOUNTAINS, collection);
|
||||
public static void registerBiomeStructures(Identifier id, Biome biome, Collection<Supplier<ConfiguredStructureFeature<?, ?>>> structures) {
|
||||
if (id.getNamespace().equals("minecraft")) {
|
||||
if (id.getPath().equals("end_highlands")) {
|
||||
addStructure(MOUNTAINS, structures);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addFeature(EndStructureFeature feature, Collection<Supplier<ConfiguredStructureFeature<?, ?>>> collection) {
|
||||
private static void addStructure(EndStructureFeature feature, Collection<Supplier<ConfiguredStructureFeature<?, ?>>> collection) {
|
||||
collection.add(() -> { return feature.getFeatureConfigured(); });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ public class FeaturesHelper {
|
|||
features.add(Lists.newArrayList(list));
|
||||
});
|
||||
|
||||
FeatureRegistry.registerBiomeFeatures(biome, features);
|
||||
StructureRegistry.registerBiomeStructures(biome, structures);
|
||||
FeatureRegistry.registerBiomeFeatures(biomeRegistry.getId(biome), biome, features);
|
||||
StructureRegistry.registerBiomeStructures(biomeRegistry.getId(biome), biome, structures);
|
||||
|
||||
accessor.setFeatures(features);
|
||||
accessor.setStructures(structures);
|
||||
|
|
|
@ -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