Lakugrove structure
This commit is contained in:
parent
0f9edccc4e
commit
91b40a3ae6
17 changed files with 301 additions and 64 deletions
|
@ -18,7 +18,8 @@ public class BiomeMegalake extends EndBiome {
|
|||
.setFogDensity(1.75F)
|
||||
.setMusic(EndSounds.MUSIC_MEGALAKE)
|
||||
.setLoop(EndSounds.AMBIENT_MEGALAKE)
|
||||
.setSurface(EndBlocks.ENDSTONE_DUST, EndBlocks.END_MOSS)
|
||||
//.setSurface(EndBlocks.ENDSTONE_DUST, EndBlocks.END_MOSS)
|
||||
.setSurface(EndBlocks.END_MOSS)
|
||||
.addStructureFeature(EndStructures.MEGALAKE)
|
||||
.addStructureFeature(ConfiguredStructureFeatures.END_CITY)
|
||||
.addFeature(EndFeatures.LACUGROVE)
|
||||
|
|
|
@ -5,13 +5,18 @@ import java.util.Random;
|
|||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
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.BlocksHelper;
|
||||
|
@ -19,9 +24,14 @@ import ru.betterend.util.MHelper;
|
|||
import ru.betterend.util.SplineHelper;
|
||||
import ru.betterend.util.sdf.PosInfo;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.util.sdf.operator.SDFDisplacement;
|
||||
import ru.betterend.util.sdf.operator.SDFSubtraction;
|
||||
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||
import ru.betterend.util.sdf.primitive.SDFSphere;
|
||||
|
||||
public class LacugroveFeature extends DefaultFeature {
|
||||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
private static final Function<BlockState, Boolean> IGNORE;
|
||||
private static final Function<PosInfo, BlockState> POST;
|
||||
|
||||
@Override
|
||||
|
@ -31,14 +41,36 @@ public class LacugroveFeature extends DefaultFeature {
|
|||
float size = MHelper.randRange(15, 25, random);
|
||||
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 6);
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);
|
||||
float radius = MHelper.randRange(1.2F, 1.8F, random);
|
||||
|
||||
if (!SplineHelper.canGenerate(spline, pos, world, REPLACE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
/*Vector3f center = null;
|
||||
for (int i = 3; i < 6; i++) {
|
||||
center = spline.get(i);
|
||||
float radius = MathHelper.lerp((i - 3F) / 2F, 6.5F, 3.7F) + MHelper.randRange(-0.5F, 0.5F, random);
|
||||
radius *= (size - 15F) / 20F + 1F;
|
||||
leavesBall(world, pos.add(center.getX(), center.getY(), center.getZ()), radius, random, noise);
|
||||
}*/
|
||||
float radius = MHelper.randRange(6F, 8F, random);
|
||||
radius *= (size - 15F) / 20F + 1F;
|
||||
Vector3f center = spline.get(4);
|
||||
leavesBall(world, pos.add(center.getX(), center.getY(), center.getZ()), radius, random, noise);
|
||||
|
||||
radius = MHelper.randRange(1.2F, 1.8F, random);
|
||||
SDF function = SplineHelper.buildSDF(spline, radius, 0.7F, (bpos) -> {
|
||||
return EndBlocks.LACUGROVE.bark.getDefaultState();
|
||||
});
|
||||
|
||||
function.setReplaceFunction(REPLACE);
|
||||
function.setPostProcess(POST);
|
||||
function.fillRecursive(world, pos);
|
||||
|
||||
spline = spline.subList(4, 6);
|
||||
SplineHelper.fillSpline(spline, world, EndBlocks.LACUGROVE.bark.getDefaultState(), pos, REPLACE);
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
int offset = random.nextInt(2);
|
||||
for (int i = 0; i < 100; i++) {
|
||||
|
@ -79,12 +111,44 @@ public class LacugroveFeature extends DefaultFeature {
|
|||
return true;
|
||||
}
|
||||
|
||||
private void leavesBall(StructureWorldAccess world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.LACUGROVE_LEAVES.getDefaultState().with(LeavesBlock.DISTANCE, 1));
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return random.nextFloat() * 3F - 1.5F; }).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius - 2, 0).setSource(sphere));
|
||||
sphere.fillRecursiveIgnore(world, pos, IGNORE);
|
||||
//sphere.fillArea(world, pos, new Box(pos).expand(radius));
|
||||
|
||||
if (radius > 5) {
|
||||
int count = (int) (radius * 2.5F);
|
||||
for (int i = 0; i < count; i++) {
|
||||
BlockPos p = pos.add(random.nextGaussian() * 1, random.nextGaussian() * 1, random.nextGaussian() * 1);
|
||||
boolean place = true;
|
||||
for (Direction d: Direction.values()) {
|
||||
BlockState state = world.getBlockState(p.offset(d));
|
||||
if (!EndBlocks.LACUGROVE.isTreeLog(state) && !state.isOf(EndBlocks.LACUGROVE_LEAVES)) {
|
||||
place = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (place) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.LACUGROVE.bark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.LACUGROVE.bark);
|
||||
}
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.isIn(EndTags.END_GROUND)) {
|
||||
return true;
|
||||
}
|
||||
if (state.getBlock() == EndBlocks.PYTHADENDRON_LEAVES) {
|
||||
if (EndBlocks.LACUGROVE.isTreeLog(state)) {
|
||||
return true;
|
||||
}
|
||||
if (state.getBlock() == EndBlocks.LACUGROVE_LEAVES) {
|
||||
return true;
|
||||
}
|
||||
if (state.getMaterial().equals(Material.PLANT)) {
|
||||
|
@ -93,6 +157,10 @@ public class LacugroveFeature extends DefaultFeature {
|
|||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
|
||||
IGNORE = (state) -> {
|
||||
return EndBlocks.LACUGROVE.isTreeLog(state);
|
||||
};
|
||||
|
||||
POST = (info) -> {
|
||||
if (EndBlocks.LACUGROVE.isTreeLog(info.getStateUp()) && EndBlocks.LACUGROVE.isTreeLog(info.getStateDown())) {
|
||||
return EndBlocks.LACUGROVE.log.getDefaultState();
|
||||
|
|
|
@ -8,9 +8,7 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
|
@ -48,8 +46,6 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
|||
private static final SDFPrimitive CONE_GLOW;
|
||||
private static final SDFPrimitive ROOTS;
|
||||
|
||||
private static final Mutable POS = new Mutable();
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) {
|
||||
blockPos = getPosOnSurface(world, blockPos);
|
||||
|
@ -75,33 +71,10 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
|||
Vector3f pos = spline.get(spline.size() - 1);
|
||||
float scale = MHelper.randRange(0.75F, 1.1F, random);
|
||||
|
||||
Vector3f vec = spline.get(0);
|
||||
float x1 = blockPos.getX() + vec.getX() * scale;
|
||||
float y1 = blockPos.getY() + vec.getY() * scale;
|
||||
float z1 = blockPos.getZ() + vec.getZ() * scale;
|
||||
for (int i = 1; i < count; i++) {
|
||||
vec = spline.get(i);
|
||||
float x2 = blockPos.getX() + vec.getX() * scale;
|
||||
float y2 = blockPos.getY() + vec.getY() * scale;
|
||||
float z2 = blockPos.getZ() + vec.getZ() * scale;
|
||||
|
||||
for (float py = y1; py < y2; py += 3) {
|
||||
if (py - blockPos.getY() < 10) continue;
|
||||
float lerp = (py - y1) / (y2 - y1);
|
||||
float x = MathHelper.lerp(lerp, x1, x2);
|
||||
float z = MathHelper.lerp(lerp, z1, z2);
|
||||
POS.set(x, py, z);
|
||||
BlockState state = world.getBlockState(POS);
|
||||
boolean generate = state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT);
|
||||
if (!generate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
z1 = z2;
|
||||
if (!SplineHelper.canGenerate(spline, scale, blockPos, world, REPLACE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, AIR);
|
||||
|
||||
CENTER.set(blockPos.getX(), 0, blockPos.getZ());
|
||||
|
|
|
@ -100,7 +100,7 @@ public class LakePiece extends BasePiece {
|
|||
}
|
||||
minY = MathHelper.lerp(lerp, maxY - minY, 56 - minY);
|
||||
pos.setY(maxY);
|
||||
while (chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN)) {
|
||||
while (!chunk.getBlockState(pos).getMaterial().isReplaceable()) {
|
||||
pos.setY(maxY ++);
|
||||
}
|
||||
for (int y = maxY; y >= minY; y--) {
|
||||
|
@ -115,10 +115,19 @@ public class LakePiece extends BasePiece {
|
|||
break;
|
||||
}
|
||||
}
|
||||
pos.setY(MHelper.floor(minY - 1));
|
||||
if (pos.getY() == 57 && chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN)) {
|
||||
BlockState state = world.getBiome(pos.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
chunk.setBlockState(pos, state, false);
|
||||
}
|
||||
if (pos.getY() < 57) {
|
||||
BlockState state = chunk.getBlockState(pos);
|
||||
if (state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)) {
|
||||
chunk.setBlockState(pos, EndBlocks.ENDSTONE_DUST.getDefaultState(), false);
|
||||
state = EndBlocks.ENDSTONE_DUST.getDefaultState();
|
||||
if (pos.getY() == 56 && random.nextBoolean()) {
|
||||
state = world.getBiome(pos.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
}
|
||||
chunk.setBlockState(pos, state, false);
|
||||
pos.setY(pos.getY() - 1);
|
||||
state = chunk.getBlockState(pos);
|
||||
if (state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)) {
|
||||
|
@ -126,7 +135,6 @@ public class LakePiece extends BasePiece {
|
|||
pos.setY(pos.getY() - 1);
|
||||
}
|
||||
if (!chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN)) {
|
||||
|
||||
chunk.setBlockState(pos, Blocks.END_STONE.getDefaultState(), false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue