Jade caves (WIP)

This commit is contained in:
paulevsGitch 2021-04-29 12:39:15 +03:00
parent c91478ee99
commit d5a93cb730
5 changed files with 97 additions and 5 deletions

View file

@ -38,6 +38,7 @@ import ru.betterend.world.biome.cave.EmptyAuroraCaveBiome;
import ru.betterend.world.biome.cave.EmptyEndCaveBiome; import ru.betterend.world.biome.cave.EmptyEndCaveBiome;
import ru.betterend.world.biome.cave.EmptySmaragdantCaveBiome; import ru.betterend.world.biome.cave.EmptySmaragdantCaveBiome;
import ru.betterend.world.biome.cave.EndCaveBiome; import ru.betterend.world.biome.cave.EndCaveBiome;
import ru.betterend.world.biome.cave.JadeCaveBiome;
import ru.betterend.world.biome.cave.LushAuroraCaveBiome; import ru.betterend.world.biome.cave.LushAuroraCaveBiome;
import ru.betterend.world.biome.cave.LushSmaragdantCaveBiome; import ru.betterend.world.biome.cave.LushSmaragdantCaveBiome;
import ru.betterend.world.biome.land.AmberLandBiome; import ru.betterend.world.biome.land.AmberLandBiome;
@ -111,6 +112,7 @@ public class EndBiomes {
public static final EndCaveBiome LUSH_SMARAGDANT_CAVE = registerCaveBiome(new LushSmaragdantCaveBiome()); public static final EndCaveBiome LUSH_SMARAGDANT_CAVE = registerCaveBiome(new LushSmaragdantCaveBiome());
public static final EndCaveBiome EMPTY_AURORA_CAVE = registerCaveBiome(new EmptyAuroraCaveBiome()); public static final EndCaveBiome EMPTY_AURORA_CAVE = registerCaveBiome(new EmptyAuroraCaveBiome());
public static final EndCaveBiome LUSH_AURORA_CAVE = registerCaveBiome(new LushAuroraCaveBiome()); public static final EndCaveBiome LUSH_AURORA_CAVE = registerCaveBiome(new LushAuroraCaveBiome());
public static final EndCaveBiome JADE_CAVE = registerCaveBiome(new JadeCaveBiome());
public static void register() { public static void register() {
CAVE_BIOMES.rebuild(); CAVE_BIOMES.rebuild();

View file

@ -77,9 +77,9 @@ public class EndBlocks {
public static final StoneMaterial FLAVOLITE = new StoneMaterial("flavolite", MaterialColor.SAND); public static final StoneMaterial FLAVOLITE = new StoneMaterial("flavolite", MaterialColor.SAND);
public static final StoneMaterial VIOLECITE = new StoneMaterial("violecite", MaterialColor.COLOR_PURPLE); public static final StoneMaterial VIOLECITE = new StoneMaterial("violecite", MaterialColor.COLOR_PURPLE);
public static final StoneMaterial SULPHURIC_ROCK = new StoneMaterial("sulphuric_rock", MaterialColor.COLOR_BROWN); public static final StoneMaterial SULPHURIC_ROCK = new StoneMaterial("sulphuric_rock", MaterialColor.COLOR_BROWN);
public static final StoneMaterial VIRID_jADESTONE = new StoneMaterial("virid_jadestone", MaterialColor.COLOR_GREEN); public static final StoneMaterial VIRID_JADESTONE = new StoneMaterial("virid_jadestone", MaterialColor.COLOR_GREEN);
public static final StoneMaterial AZURE_jADESTONE = new StoneMaterial("azure_jadestone", MaterialColor.COLOR_LIGHT_BLUE); public static final StoneMaterial AZURE_JADESTONE = new StoneMaterial("azure_jadestone", MaterialColor.COLOR_LIGHT_BLUE);
public static final StoneMaterial SANDY_jADESTONE = new StoneMaterial("sandy_jadestone", MaterialColor.COLOR_YELLOW); public static final StoneMaterial SANDY_JADESTONE = new StoneMaterial("sandy_jadestone", MaterialColor.COLOR_YELLOW);
public static final Block BRIMSTONE = registerBlock("brimstone", new BrimstoneBlock()); public static final Block BRIMSTONE = registerBlock("brimstone", new BrimstoneBlock());
public static final Block SULPHUR_CRYSTAL = registerBlock("sulphur_crystal", new SulphurCrystalBlock()); public static final Block SULPHUR_CRYSTAL = registerBlock("sulphur_crystal", new SulphurCrystalBlock());
public static final Block MISSING_TILE = registerBlock("missing_tile", new MissingTileBlock()); public static final Block MISSING_TILE = registerBlock("missing_tile", new MissingTileBlock());

View file

@ -56,4 +56,8 @@ public class EndCaveBiome extends EndBiome {
public BlockState getCeil(BlockPos pos) { public BlockState getCeil(BlockPos pos) {
return null; return null;
} }
public BlockState getWall(BlockPos pos) {
return null;
}
} }

View file

@ -0,0 +1,35 @@
package ru.betterend.world.biome.cave;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndSounds;
import ru.betterend.world.biome.BiomeDefinition;
public class JadeCaveBiome extends EndCaveBiome {
private static final OpenSimplexNoise WALL_NOISE = new OpenSimplexNoise("jade_cave".hashCode());
private static final OpenSimplexNoise DEPTH_NOISE = new OpenSimplexNoise("depth_noise".hashCode());
private static final BlockState[] JADE = new BlockState[3];
public JadeCaveBiome() {
super(new BiomeDefinition("jade_cave")
.setFogColor(118, 150, 112)
.setFogDensity(2.0F)
.setWaterAndFogColor(95, 223, 255)
.setMusic(EndSounds.MUSIC_FOREST)
);
JADE[0] = EndBlocks.VIRID_JADESTONE.stone.defaultBlockState();
JADE[1] = EndBlocks.AZURE_JADESTONE.stone.defaultBlockState();
JADE[2] = EndBlocks.SANDY_JADESTONE.stone.defaultBlockState();
}
@Override
public BlockState getWall(BlockPos pos) {
double depth = DEPTH_NOISE.eval(pos.getX() * 0.02, pos.getZ() * 0.02) * 0.2 + 0.5;
int index = Mth.floor((pos.getY() + WALL_NOISE.eval(pos.getX() * 0.2, pos.getZ() * 0.2) * 1.5) * depth + 0.5);
index = Mth.abs(index) % 3;
return JADE[index];
}
}

View file

@ -1,13 +1,16 @@
package ru.betterend.world.features.terrain.caves; package ru.betterend.world.features.terrain.caves;
import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
@ -29,6 +32,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
protected static final BlockState CAVE_AIR = Blocks.CAVE_AIR.defaultBlockState(); protected static final BlockState CAVE_AIR = Blocks.CAVE_AIR.defaultBlockState();
protected static final BlockState END_STONE = Blocks.END_STONE.defaultBlockState(); protected static final BlockState END_STONE = Blocks.END_STONE.defaultBlockState();
protected static final BlockState WATER = Blocks.WATER.defaultBlockState(); protected static final BlockState WATER = Blocks.WATER.defaultBlockState();
private static final Vec3i[] SPHERE;
@Override @Override
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, NoneFeatureConfiguration config) { public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, NoneFeatureConfiguration config) {
@ -68,10 +72,10 @@ public abstract class EndCaveFeature extends DefaultFeature {
} }
} }
}); });
BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceBuilderConfig() BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
.getTopMaterial();
placeFloor(world, biome, floorPositions, random, surfaceBlock); placeFloor(world, biome, floorPositions, random, surfaceBlock);
placeCeil(world, biome, ceilPositions, random); placeCeil(world, biome, ceilPositions, random);
placeWalls(world, biome, caveBlocks, random);
} }
fixBlocks(world, caveBlocks); fixBlocks(world, caveBlocks);
} }
@ -109,6 +113,34 @@ public abstract class EndCaveFeature extends DefaultFeature {
} }
}); });
} }
protected void placeWalls(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> positions, Random random) {
Set<BlockPos> placed = Sets.newHashSet();
positions.forEach(pos -> {
if (random.nextInt(4) == 0 && hasOpenSide(pos, positions)) {
BlockState wallBlock = biome.getWall(pos);
if (wallBlock != null) {
for (Vec3i offset: SPHERE) {
BlockPos wallPos = pos.offset(offset);
if (!positions.contains(wallPos) && !placed.contains(wallPos) && world.getBlockState(wallPos).is(EndTags.GEN_TERRAIN)) {
wallBlock = biome.getWall(wallPos);
BlocksHelper.setWithoutUpdate(world, wallPos, wallBlock);
placed.add(wallPos);
}
}
}
}
});
}
private boolean hasOpenSide(BlockPos pos, Set<BlockPos> positions) {
for (Direction dir: BlocksHelper.DIRECTIONS) {
if (!positions.contains(pos.relative(dir))) {
return true;
}
}
return false;
}
protected void setBiomes(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> blocks) { protected void setBiomes(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> blocks) {
blocks.forEach((pos) -> setBiome(world, pos, biome)); blocks.forEach((pos) -> setBiome(world, pos, biome));
@ -202,4 +234,23 @@ public abstract class EndCaveFeature extends DefaultFeature {
} }
return false; return false;
} }
static {
List<Vec3i> prePos = Lists.newArrayList();
int radius = 5;
int r2 = radius * radius;
for (int x = -radius; x <= radius; x++) {
int x2 = x * x;
for (int y = -radius; y <= radius; y++) {
int y2 = y * y;
for (int z = -radius; z <= radius; z++) {
int z2 = z * z;
if (x2 + y2 + z2 < r2) {
prePos.add(new Vec3i(x, y, z));
}
}
}
}
SPHERE = prePos.toArray(new Vec3i[] {});
}
} }