Dragon Graveyards prototype
This commit is contained in:
parent
05b4e80a9d
commit
0dfcc950ca
15 changed files with 313 additions and 7 deletions
|
@ -0,0 +1,56 @@
|
|||
package ru.betterend.world.features.terrain;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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.EndBlocks;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.util.sdf.operator.SDFDisplacement;
|
||||
import ru.betterend.util.sdf.operator.SDFRotation;
|
||||
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||
import ru.betterend.util.sdf.primitive.SDFCappedCone;
|
||||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class FallenPillarFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
|
||||
if (!world.getBlockState(pos.down(5)).isIn(EndTags.GEN_TERRAIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float height = MHelper.randRange(20F, 40F, random);
|
||||
float radius = MHelper.randRange(2F, 4F, random);
|
||||
SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F).setBlock(Blocks.OBSIDIAN);
|
||||
pillar = new SDFTranslate().setTranslate(0, radius * 0.5F - 2, 0).setSource(pillar);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
pillar = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) (noise.eval(vec.getX() * 0.3, vec.getY() * 0.3, vec.getZ() * 0.3) * 0.5F);
|
||||
}).setSource(pillar);
|
||||
Vector3f vec = MHelper.randomHorizontal(random);
|
||||
float angle = (float) random.nextGaussian() * 0.05F + (float) Math.PI;
|
||||
pillar = new SDFRotation().setRotation(vec, angle).setSource(pillar);
|
||||
|
||||
BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.getDefaultState();
|
||||
pillar.addPostProcess((info) -> {
|
||||
if (info.getStateUp().isAir() && random.nextFloat() > 0.1F) {
|
||||
return mossy;
|
||||
}
|
||||
return info.getState();
|
||||
}).setReplaceFunction((state) -> {
|
||||
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT);
|
||||
}).fillRecursive(world, pos);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package ru.betterend.world.features.terrain;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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.EndBlocks;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.util.sdf.operator.SDFDisplacement;
|
||||
import ru.betterend.util.sdf.operator.SDFScale3D;
|
||||
import ru.betterend.util.sdf.primitive.SDFSphere;
|
||||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class ObsidianBoulderFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
|
||||
if (!world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int count = MHelper.randRange(1, 5, random);
|
||||
for (int i = 0; i < count; i++) {
|
||||
BlockPos p = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16) - 8, pos.getY(), pos.getZ() + random.nextInt(16) - 8));
|
||||
makeBoulder(world, p, random);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void makeBoulder(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||
if (!world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
float radius = MHelper.randRange(1F, 5F, random);
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(Blocks.OBSIDIAN);
|
||||
float sx = MHelper.randRange(0.7F, 1.3F, random);
|
||||
float sy = MHelper.randRange(0.7F, 1.3F, random);
|
||||
float sz = MHelper.randRange(0.7F, 1.3F, random);
|
||||
sphere = new SDFScale3D().setScale(sx, sy, sz).setSource(sphere);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) (noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 1.5F);
|
||||
}).setSource(sphere);
|
||||
|
||||
BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.getDefaultState();
|
||||
sphere.addPostProcess((info) -> {
|
||||
if (info.getStateUp().isAir() && random.nextFloat() > 0.1F) {
|
||||
return mossy;
|
||||
}
|
||||
return info.getState();
|
||||
}).setReplaceFunction((state) -> {
|
||||
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT);
|
||||
}).fillRecursive(world, pos);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package ru.betterend.world.features.terrain;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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.EndBlocks;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.util.sdf.operator.SDFDisplacement;
|
||||
import ru.betterend.util.sdf.operator.SDFRotation;
|
||||
import ru.betterend.util.sdf.operator.SDFSubtraction;
|
||||
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||
import ru.betterend.util.sdf.primitive.SDFCappedCone;
|
||||
import ru.betterend.util.sdf.primitive.SDFFlatland;
|
||||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class ObsidianPillarBasementFeature extends DefaultFeature {
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
|
||||
if (!world.getBlockState(pos.down(5)).isIn(EndTags.GEN_TERRAIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float height = MHelper.randRange(10F, 35F, random);
|
||||
float radius = MHelper.randRange(2F, 5F, random);
|
||||
SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F).setBlock(Blocks.OBSIDIAN);
|
||||
pillar = new SDFTranslate().setTranslate(0, height * 0.5F - 3, 0).setSource(pillar);
|
||||
SDF cut = new SDFFlatland().setBlock(Blocks.OBSIDIAN);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
cut = new SDFDisplacement().setFunction((vec) -> {
|
||||
return (float) (noise.eval(vec.getX() * 0.2, vec.getZ() * 0.2) * 3);
|
||||
}).setSource(cut);
|
||||
Vector3f vec = MHelper.randomHorizontal(random);
|
||||
float angle = random.nextFloat() * 0.5F + (float) Math.PI;
|
||||
cut = new SDFRotation().setRotation(vec, angle).setSource(cut);
|
||||
cut = new SDFTranslate().setTranslate(0, height * 0.7F - 3, 0).setSource(cut);
|
||||
pillar = new SDFSubtraction().setSourceA(pillar).setSourceB(cut);
|
||||
vec = MHelper.randomHorizontal(random);
|
||||
angle = random.nextFloat() * 0.2F;
|
||||
pillar = new SDFRotation().setRotation(vec, angle).setSource(pillar);
|
||||
|
||||
BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.getDefaultState();
|
||||
pillar.addPostProcess((info) -> {
|
||||
if (info.getStateUp().isAir() && random.nextFloat() > 0.1F) {
|
||||
return mossy;
|
||||
}
|
||||
return info.getState();
|
||||
}).setReplaceFunction((state) -> {
|
||||
return state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT);
|
||||
}).fillRecursive(world, pos);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -158,10 +158,8 @@ public class RoundCaveFeature extends DefaultFeature {
|
|||
BlockPos down = pos.down(BlocksHelper.downRay(world, pos, 64) + 2);
|
||||
if (isReplaceable(world.getBlockState(down))) {
|
||||
SDF prism = new SDFHexPrism().setHeight(radius * MHelper.randRange(0.6F, 0.75F, random)).setRadius(MHelper.randRange(1.7F, 3F, random)).setBlock(EndBlocks.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);
|
||||
Vector3f vec = MHelper.randomHorizontal(random);
|
||||
prism = new SDFRotation().setRotation(vec, random.nextFloat()).setSource(prism);
|
||||
prism.setReplaceFunction((bState) -> {
|
||||
return bState.getMaterial().isReplaceable()
|
||||
|| bState.isIn(EndTags.GEN_TERRAIN)
|
||||
|
|
|
@ -19,7 +19,7 @@ public class SurfaceVentFeature extends DefaultFeature {
|
|||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
|
||||
if (pos.getY() < 57) {
|
||||
if (!world.getBlockState(pos.down(3)).isIn(EndTags.GEN_TERRAIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue