More fixes

This commit is contained in:
paulevsGitch 2021-05-03 23:44:49 +03:00
parent 32cd7162f4
commit 3d79aa6050
3 changed files with 22 additions and 7 deletions

View file

@ -11,6 +11,7 @@ import net.minecraft.util.Mth;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.betterend.noise.OpenSimplexNoise; import ru.betterend.noise.OpenSimplexNoise;
@ -24,8 +25,13 @@ public class TunelCaveFeature extends EndCaveFeature {
private static final OpenSimplexNoise BIOME_NOISE_Z = new OpenSimplexNoise("biome_noise_z".hashCode()); private static final OpenSimplexNoise BIOME_NOISE_Z = new OpenSimplexNoise("biome_noise_z".hashCode());
private Set<BlockPos> generate(WorldGenLevel world, BlockPos center, Random random) { private Set<BlockPos> generate(WorldGenLevel world, BlockPos center, Random random) {
int x1 = (center.getX() >> 4) << 4; int cx = center.getX() >> 4;
int z1 = (center.getZ() >> 4) << 4; int cz = center.getZ() >> 4;
if ((long) cx * (long) cx + (long) cz + (long) cz < 256) {
return Sets.newHashSet();
}
int x1 = cx << 4;
int z1 = cz << 4;
int x2 = x1 + 16; int x2 = x1 + 16;
int z2 = z1 + 16; int z2 = z1 + 16;
int y2 = world.getHeight(); int y2 = world.getHeight();
@ -43,12 +49,19 @@ public class TunelCaveFeature extends EndCaveFeature {
for (int y = 0; y < y2; y++) { for (int y = 0; y < y2; y++) {
pos.setY(y); pos.setY(y);
float val = Mth.abs((float) noiseH.eval(x * 0.02, y * 0.01, z * 0.02)); float val = Mth.abs((float) noiseH.eval(x * 0.02, y * 0.01, z * 0.02));
float vert = Mth.sin((y + (float) noiseV.eval(x * 0.01, z * 0.01) * 20) * 0.1F) * 0.9F;//Mth.abs(y - 50 + (float) noiseV.eval(x * 0.01, z * 0.01) * 20) * 0.1F; float vert = Mth.sin((y + (float) noiseV.eval(x * 0.01, z * 0.01) * 20) * 0.1F) * 0.9F;
float dist = (float) noiseD.eval(x * 0.1, y * 0.1, z * 0.1) * 0.12F; float dist = (float) noiseD.eval(x * 0.1, y * 0.1, z * 0.1) * 0.12F;
vert *= vert; vert *= vert;
if (val + vert + dist < 0.15 && world.getBlockState(pos).is(EndTags.GEN_TERRAIN)) { if (val + vert + dist < 0.15 && world.getBlockState(pos).is(EndTags.GEN_TERRAIN)) {
BlocksHelper.setWithoutUpdate(world, pos, AIR); BlocksHelper.setWithoutUpdate(world, pos, AIR);
positions.add(pos.immutable()); positions.add(pos.immutable());
int height = world.getHeight(Types.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
if (height < pos.getY() + 4) {
while (pos.getY() < height) {
pos.setY(pos.getY() + 1);
BlocksHelper.setWithoutUpdate(world, pos, AIR);
}
}
} }
} }
} }
@ -79,7 +92,8 @@ public class TunelCaveFeature extends EndCaveFeature {
mut.set(bpos); mut.set(bpos);
if (world.getBlockState(mut).getMaterial().isReplaceable()) { if (world.getBlockState(mut).getMaterial().isReplaceable()) {
mut.setY(bpos.getY() - 1); mut.setY(bpos.getY() - 1);
if (world.getBlockState(mut).is(EndTags.GEN_TERRAIN)) { int height = world.getHeight(Types.WORLD_SURFACE, pos.getX(), pos.getZ());
if (world.getBlockState(mut).is(EndTags.GEN_TERRAIN) && mut.getY() < height) {
floorPositions.add(mut.immutable()); floorPositions.add(mut.immutable());
} }
mut.setY(bpos.getY() + 1); mut.setY(bpos.getY() + 1);

View file

@ -26,7 +26,7 @@ public class EternalPortalStructure extends FeatureBaseStructure {
private static final StructureTemplate STRUCTURE = StructureHelper.readStructure(STRUCTURE_ID); private static final StructureTemplate STRUCTURE = StructureHelper.readStructure(STRUCTURE_ID);
@Override @Override
protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, WorldgenRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration featureConfig) { protected boolean isFeatureChunk(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, WorldgenRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration featureConfig) {
long x = (long) chunkPos.x * (long) chunkPos.x; long x = (long) chunkPos.x * (long) chunkPos.x;
long z = (long) chunkPos.z * (long) chunkPos.z; long z = (long) chunkPos.z * (long) chunkPos.z;
if (x + z < 1024L) { if (x + z < 1024L) {
@ -35,7 +35,7 @@ public class EternalPortalStructure extends FeatureBaseStructure {
if (chunkGenerator.getBaseHeight((chunkX << 4) | 8, (chunkZ << 4) | 8, Heightmap.Types.WORLD_SURFACE_WG) < 10) { if (chunkGenerator.getBaseHeight((chunkX << 4) | 8, (chunkZ << 4) | 8, Heightmap.Types.WORLD_SURFACE_WG) < 10) {
return false; return false;
} }
return super.shouldStartAt(chunkGenerator, biomeSource, worldSeed, chunkRandom, chunkX, chunkZ, biome, chunkPos, featureConfig); return super.isFeatureChunk(chunkGenerator, biomeSource, worldSeed, chunkRandom, chunkX, chunkZ, biome, chunkPos, featureConfig);
} }
@Override @Override

View file

@ -21,7 +21,8 @@ public abstract class FeatureBaseStructure extends StructureFeature<NoneFeatureC
super(NoneFeatureConfiguration.CODEC); super(NoneFeatureConfiguration.CODEC);
} }
protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, WorldgenRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration featureConfig) { @Override
protected boolean isFeatureChunk(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, WorldgenRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration featureConfig) {
return getGenerationHeight(chunkX, chunkZ, chunkGenerator) >= 20; return getGenerationHeight(chunkX, chunkZ, chunkGenerator) >= 20;
} }