Lake fixes
This commit is contained in:
parent
21f8cb54c0
commit
f7482ec811
5 changed files with 146 additions and 20 deletions
|
@ -15,6 +15,7 @@ import ru.betterend.world.structures.features.StructureEternalPortal;
|
|||
import ru.betterend.world.structures.features.StructureGiantIceStar;
|
||||
import ru.betterend.world.structures.features.StructureGiantMossyGlowshroom;
|
||||
import ru.betterend.world.structures.features.StructureMegaLake;
|
||||
import ru.betterend.world.structures.features.StructureMegaLakeSmall;
|
||||
import ru.betterend.world.structures.features.StructureMountain;
|
||||
import ru.betterend.world.structures.features.StructurePaintedMountain;
|
||||
import ru.betterend.world.structures.piece.CavePiece;
|
||||
|
@ -34,6 +35,7 @@ public class EndStructures {
|
|||
|
||||
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_SMALL = new EndStructureFeature("megalake_small", new StructureMegaLakeSmall(), Feature.RAW_GENERATION, 4, 1);
|
||||
public static final EndStructureFeature MOUNTAIN = new EndStructureFeature("mountain", new StructureMountain(), Feature.RAW_GENERATION, 3, 2);
|
||||
public static final EndStructureFeature PAINTED_MOUNTAIN = new EndStructureFeature("painted_mountain", new StructurePaintedMountain(), Feature.RAW_GENERATION, 3, 2);
|
||||
public static final EndStructureFeature ETERNAL_PORTAL = new EndStructureFeature("eternal_portal", new StructureEternalPortal(), Feature.SURFACE_STRUCTURES, 16, 6);
|
||||
|
|
|
@ -19,7 +19,7 @@ public class BiomeMegalakeGrove extends EndBiome {
|
|||
.setMusic(EndSounds.MUSIC_WATER)
|
||||
.setLoop(EndSounds.AMBIENT_MEGALAKE_GROVE)
|
||||
.setSurface(EndBlocks.END_MOSS)
|
||||
.addStructureFeature(EndStructures.MEGALAKE)
|
||||
.addStructureFeature(EndStructures.MEGALAKE_SMALL)
|
||||
.addFeature(EndFeatures.LACUGROVE)
|
||||
.addFeature(EndFeatures.END_LOTUS)
|
||||
.addFeature(EndFeatures.END_LOTUS_LEAF)
|
||||
|
|
|
@ -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.LakePiece;
|
||||
import ru.betterend.world.structures.piece.LakePiece2;
|
||||
|
||||
public class StructureMegaLake extends StructureFeatureBase {
|
||||
|
@ -31,9 +30,8 @@ public class StructureMegaLake extends StructureFeatureBase {
|
|||
int z = (chunkZ << 4) | MHelper.randRange(4, 12, random);
|
||||
int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG);
|
||||
if (y > 5) {
|
||||
float radius = MHelper.randRange(64, 96, random);
|
||||
float depth = MHelper.randRange(8, 25, random);
|
||||
//LakePiece piece = new LakePiece(new BlockPos(x, y - 3, z), radius, depth, random, biome);
|
||||
float radius = MHelper.randRange(32, 64, random);
|
||||
float depth = MHelper.randRange(7, 15, random);
|
||||
LakePiece2 piece = new LakePiece2(new BlockPos(x, y, z), radius, depth, random, biome);
|
||||
this.children.add(piece);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package ru.betterend.world.structures.features;
|
||||
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.structure.StructureStart;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
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.LakePiece2;
|
||||
|
||||
public class StructureMegaLakeSmall extends StructureFeatureBase {
|
||||
@Override
|
||||
public StructureFeature.StructureStartFactory<DefaultFeatureConfig> getStructureStartFactory() {
|
||||
return SDFStructureStart::new;
|
||||
}
|
||||
|
||||
public static class SDFStructureStart extends StructureStart<DefaultFeatureConfig> {
|
||||
public SDFStructureStart(StructureFeature<DefaultFeatureConfig> feature, int chunkX, int chunkZ, BlockBox box, int references, long seed) {
|
||||
super(feature, chunkX, chunkZ, box, references, seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, StructureManager manager, int chunkX, int chunkZ, Biome biome, DefaultFeatureConfig config) {
|
||||
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) {
|
||||
float radius = MHelper.randRange(20, 40, random);
|
||||
float depth = MHelper.randRange(5, 10, random);
|
||||
LakePiece2 piece = new LakePiece2(new BlockPos(x, y, z), radius, depth, random, biome);
|
||||
this.children.add(piece);
|
||||
}
|
||||
this.setBoundingBoxFromChildren();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import com.google.common.collect.Maps;
|
|||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtHelper;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
|
@ -15,17 +16,20 @@ import net.minecraft.util.math.BlockBox;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.EndBiomes;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndStructures;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class LakePiece2 extends BasePiece {
|
||||
|
@ -90,42 +94,117 @@ public class LakePiece2 extends BasePiece {
|
|||
mut.setX(x);
|
||||
int wx = x | sx;
|
||||
double nx = wx * 0.1;
|
||||
int x2 = MHelper.pow2(wx - center.getX());
|
||||
int x2 = wx - center.getX();
|
||||
for (int z = 0; z < 16; z++) {
|
||||
mut.setZ(z);
|
||||
int wz = z | sz;
|
||||
double nz = wz * 0.1;
|
||||
int z2 = MHelper.pow2(wz - center.getZ());
|
||||
int z2 = wz - center.getZ();
|
||||
float clamp = getHeightClamp(world, 8, wx, wz);
|
||||
if (clamp < 0.01) continue;
|
||||
|
||||
double n = noise.eval(nx, nz) * 1.5 + 1.5;
|
||||
double x3 = MHelper.pow2(x2 + noise.eval(nx, nz, 100) * 10);
|
||||
double z3 = MHelper.pow2(z2 + noise.eval(nx, nz, -100) * 10);
|
||||
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
mut.setY(y);
|
||||
double ny = y * 0.1;
|
||||
mut.setY((int) (y + n));
|
||||
double y2 = MHelper.pow2((y - center.getY()) * aspect);
|
||||
double r2 = (noise.eval(nx, ny, nz) * 10 + radius) * clamp;
|
||||
double r2 = radius * clamp;
|
||||
double r3 = r2 + 8;
|
||||
r2 *= r2;
|
||||
r3 *= r3;
|
||||
double dist = x2 + y2 + z2;
|
||||
r3 = r3 * r3 + 100;
|
||||
double dist = x3 + y2 + z3;
|
||||
if (dist < r2) {
|
||||
BlockState state = chunk.getBlockState(mut);
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) || state.getMaterial().isReplaceable()) {
|
||||
state = y < center.getY() ? WATER : AIR;
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) || state.isAir()) {
|
||||
state = mut.getY() < center.getY() ? WATER : AIR;
|
||||
chunk.setBlockState(mut, state, false);
|
||||
}
|
||||
}
|
||||
else if (dist < r3 && y < center.getY()) {
|
||||
else if (dist <= r3 && mut.getY() < center.getY()) {
|
||||
BlockState state = chunk.getBlockState(mut);
|
||||
BlockPos worldPos = mut.add(sx, 0, sz);
|
||||
if (!state.isFullCube(world, worldPos) || !state.isSolidBlock(world, worldPos)) {
|
||||
chunk.setBlockState(mut, ENDSTONE, false);
|
||||
if (!state.isFullCube(world, worldPos) && !state.isSolidBlock(world, worldPos)) {
|
||||
state = chunk.getBlockState(mut.up());
|
||||
if (state.isAir()) {
|
||||
state = random.nextBoolean() ? ENDSTONE : world.getBiome(worldPos).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
}
|
||||
else {
|
||||
state = state.getFluidState().isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.getDefaultState();
|
||||
}
|
||||
chunk.setBlockState(mut, state, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fixWater(world, chunk, mut, random, sx, sz);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void fixWater(StructureWorldAccess world, Chunk chunk, Mutable mut, Random random, int sx, int sz) {
|
||||
int minY = this.boundingBox.minY;
|
||||
int maxY = this.boundingBox.maxY;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
mut.setX(x);
|
||||
for (int z = 0; z < 16; z++) {
|
||||
mut.setZ(z);
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
mut.setY(y);
|
||||
FluidState state = chunk.getFluidState(mut);
|
||||
if (!state.isEmpty()) {
|
||||
mut.setY(y - 1);
|
||||
if (chunk.getBlockState(mut).isAir()) {
|
||||
mut.setY(y + 1);
|
||||
|
||||
BlockState bState = chunk.getBlockState(mut);
|
||||
if (bState.isAir()) {
|
||||
bState = random.nextBoolean() ? ENDSTONE : world.getBiome(mut.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
}
|
||||
else {
|
||||
bState = bState.getFluidState().isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.getDefaultState();
|
||||
}
|
||||
|
||||
mut.setY(y);
|
||||
|
||||
makeEndstonePillar(chunk, mut, bState);
|
||||
}
|
||||
else if (x > 1 && x < 15 && z > 1 && z < 15) {
|
||||
mut.setY(y);
|
||||
for (Direction dir: BlocksHelper.HORIZONTAL) {
|
||||
BlockPos wPos = mut.add(dir.getOffsetX(), 0, dir.getOffsetZ());
|
||||
if (chunk.getBlockState(wPos).isAir()) {
|
||||
mut.setY(y + 1);
|
||||
BlockState bState = chunk.getBlockState(mut);
|
||||
if (bState.isAir()) {
|
||||
bState = random.nextBoolean() ? ENDSTONE : world.getBiome(mut.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
}
|
||||
else {
|
||||
bState = bState.getFluidState().isEmpty() ? ENDSTONE : EndBlocks.ENDSTONE_DUST.getDefaultState();
|
||||
}
|
||||
mut.setY(y);
|
||||
makeEndstonePillar(chunk, mut, bState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (chunk.getBlockState(mut.move(Direction.UP)).isAir()) {
|
||||
chunk.getFluidTickScheduler().schedule(mut.move(Direction.DOWN), state.getFluid(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
private void makeEndstonePillar(Chunk chunk, Mutable mut, BlockState terrain) {
|
||||
chunk.setBlockState(mut, terrain, false);
|
||||
mut.setY(mut.getY() - 1);
|
||||
while (!chunk.getFluidState(mut).isEmpty()) {
|
||||
chunk.setBlockState(mut, ENDSTONE, false);
|
||||
mut.setY(mut.getY() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private int getHeight(StructureWorldAccess world, BlockPos pos) {
|
||||
|
@ -140,6 +219,12 @@ public class LakePiece2 extends BasePiece {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*h = world.getTopY(Type.WORLD_SURFACE, pos.getX(), pos.getZ());
|
||||
if (!world.getBlockState(new BlockPos(pos.getX(), h - 1, pos.getZ())).getFluidState().isEmpty()) {
|
||||
heightmap.put(p, (byte) 0);
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
h = world.getTopY(Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
|
||||
h = MathHelper.abs(h - center.getY());
|
||||
h = h < 8 ? 1 : 0;
|
||||
|
@ -175,7 +260,7 @@ public class LakePiece2 extends BasePiece {
|
|||
int minY = MHelper.floor(center.getX() - depth - 8);
|
||||
int minZ = MHelper.floor(center.getZ() - radius - 8);
|
||||
int maxX = MHelper.floor(center.getX() + radius + 8);
|
||||
int maxY = MHelper.floor(center.getY() + depth + 8);
|
||||
int maxY = MHelper.floor(center.getY() + depth);
|
||||
int maxZ = MHelper.floor(center.getZ() + radius + 8);
|
||||
this.boundingBox = new BlockBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue