Cave crystals
This commit is contained in:
parent
5228d778c8
commit
d0a16bf66b
4 changed files with 52 additions and 3 deletions
|
@ -27,7 +27,7 @@ public class StructureRegistry {
|
||||||
|
|
||||||
public static final EndStructureFeature GIANT_MOSSY_GLOWSHROOM = new EndStructureFeature("giant_mossy_glowshroom", new StructureGiantMossyGlowshroom(), Feature.SURFACE_STRUCTURES, 16, 8);
|
public static final EndStructureFeature GIANT_MOSSY_GLOWSHROOM = new EndStructureFeature("giant_mossy_glowshroom", new StructureGiantMossyGlowshroom(), Feature.SURFACE_STRUCTURES, 16, 8);
|
||||||
public static final EndStructureFeature MEGALAKE = new EndStructureFeature("megalake", new StructureMegaLake(), Feature.RAW_GENERATION, 4, 1);
|
public static final EndStructureFeature MEGALAKE = new EndStructureFeature("megalake", new StructureMegaLake(), Feature.RAW_GENERATION, 4, 1);
|
||||||
public static final EndStructureFeature MOUNTAINS = new EndStructureFeature("mountains", new StructureMountain(), Feature.RAW_GENERATION, 3, 2);
|
public static final EndStructureFeature MOUNTAIN = new EndStructureFeature("mountain", new StructureMountain(), Feature.RAW_GENERATION, 3, 2);
|
||||||
|
|
||||||
public static void register() {}
|
public static void register() {}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class StructureRegistry {
|
||||||
public static void registerBiomeStructures(Identifier id, Biome biome, Collection<Supplier<ConfiguredStructureFeature<?, ?>>> structures) {
|
public static void registerBiomeStructures(Identifier id, Biome biome, Collection<Supplier<ConfiguredStructureFeature<?, ?>>> structures) {
|
||||||
if (id.getNamespace().equals("minecraft")) {
|
if (id.getNamespace().equals("minecraft")) {
|
||||||
if (id.getPath().equals("end_highlands")) {
|
if (id.getPath().equals("end_highlands")) {
|
||||||
addStructure(MOUNTAINS, structures);
|
addStructure(MOUNTAIN, structures);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,8 @@ public class SDFRotation extends SDFUnary {
|
||||||
private static final Vector3f POS = new Vector3f();
|
private static final Vector3f POS = new Vector3f();
|
||||||
private Quaternion rotation;
|
private Quaternion rotation;
|
||||||
|
|
||||||
public SDFRotation setRotation() {
|
public SDFRotation setRotation(Vector3f axis, float rotationAngle) {
|
||||||
|
rotation = new Quaternion(axis, rotationAngle, false);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package ru.betterend.util.sdf.primitive;
|
||||||
|
|
||||||
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
|
public class SDFHexPrism extends SDFPrimitive {
|
||||||
|
private float radius;
|
||||||
|
private float height;
|
||||||
|
|
||||||
|
public SDFHexPrism setRadius(float radius) {
|
||||||
|
this.radius = radius;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SDFHexPrism setHeight(float height) {
|
||||||
|
this.height = height;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getDistance(float x, float y, float z) {
|
||||||
|
float px = Math.abs(x);
|
||||||
|
float py = Math.abs(y);
|
||||||
|
float pz = Math.abs(z);
|
||||||
|
return MHelper.max(py - height, MHelper.max((px * 0.866025F + pz * 0.5F), pz) - radius);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package ru.betterend.world.features;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.client.util.math.Vector3f;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockPos.Mutable;
|
import net.minecraft.util.math.BlockPos.Mutable;
|
||||||
import net.minecraft.world.Heightmap;
|
import net.minecraft.world.Heightmap;
|
||||||
|
@ -9,9 +10,14 @@ import net.minecraft.world.StructureWorldAccess;
|
||||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||||
import ru.betterend.noise.OpenSimplexNoise;
|
import ru.betterend.noise.OpenSimplexNoise;
|
||||||
|
import ru.betterend.registry.BlockRegistry;
|
||||||
import ru.betterend.registry.BlockTagRegistry;
|
import ru.betterend.registry.BlockTagRegistry;
|
||||||
|
import ru.betterend.registry.StructureRegistry;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
import ru.betterend.util.sdf.SDF;
|
||||||
|
import ru.betterend.util.sdf.operator.SDFRotation;
|
||||||
|
import ru.betterend.util.sdf.primitive.SDFHexPrism;
|
||||||
|
|
||||||
public class RoundCave extends DefaultFeature {
|
public class RoundCave extends DefaultFeature {
|
||||||
@Override
|
@Override
|
||||||
|
@ -61,6 +67,22 @@ public class RoundCave extends DefaultFeature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (random.nextBoolean() && world.getBiome(pos).getGenerationSettings().hasStructureFeature(StructureRegistry.MOUNTAIN.getStructure())) {
|
||||||
|
pos = pos.add(random.nextGaussian() * 5, random.nextGaussian() * 5, random.nextGaussian() * 5);
|
||||||
|
BlockPos down = pos.down(BlocksHelper.downRay(world, pos, 64) + 2);
|
||||||
|
if (world.getBlockState(down).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||||
|
SDF prism = new SDFHexPrism().setHeight(radius * MHelper.randRange(0.6F, 0.75F, random)).setRadius(3).setBlock(BlockRegistry.AURORA_CRYSTAL);
|
||||||
|
float angleY = MHelper.randRange(0, MHelper.PI2, random);
|
||||||
|
float vx = (float) Math.sin(angleY);
|
||||||
|
float vz = (float) Math.sin(angleY);
|
||||||
|
prism = new SDFRotation().setRotation(new Vector3f(vx, 0, vz), random.nextFloat()).setSource(prism);
|
||||||
|
prism.setReplaceFunction((state) -> {
|
||||||
|
return state.getMaterial().isReplaceable() || state.isIn(BlockTagRegistry.GEN_TERRAIN);
|
||||||
|
});
|
||||||
|
prism.fillRecursive(world, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue