Stalactites
This commit is contained in:
parent
2ac1ec8f5a
commit
7e73d9a31c
39 changed files with 657 additions and 31 deletions
|
@ -14,11 +14,19 @@ public class EmptyAuroraCaveBiome extends EndCaveBiome {
|
|||
.setWaterAndFogColor(186, 77, 237)
|
||||
.setMusic(EndSounds.MUSIC_FOREST)
|
||||
.setParticles(EndParticles.GLOWING_SPHERE, 0.001F));
|
||||
|
||||
this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL, 1);
|
||||
|
||||
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloorDensity() {
|
||||
return 0.01F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCeilDensity() {
|
||||
return 0.1F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ru.betterend.world.biome.cave;
|
||||
|
||||
import ru.betterend.registry.EndFeatures;
|
||||
import ru.betterend.registry.EndSounds;
|
||||
import ru.betterend.world.biome.land.BiomeDefinition;
|
||||
|
||||
|
@ -8,5 +9,18 @@ public class EmptyEndCaveBiome extends EndCaveBiome {
|
|||
super(new BiomeDefinition("empty_end_cave")
|
||||
.setFogDensity(2.0F)
|
||||
.setMusic(EndSounds.MUSIC_FOREST));
|
||||
|
||||
this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE, 1);
|
||||
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloorDensity() {
|
||||
return 0.1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCeilDensity() {
|
||||
return 0.1F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,13 +13,21 @@ public class EmptySmaragdantCaveBiome extends EndCaveBiome {
|
|||
.setPlantsColor(0, 131, 145)
|
||||
.setWaterAndFogColor(31, 167, 212)
|
||||
.setMusic(EndSounds.MUSIC_FOREST)
|
||||
.setParticles(EndParticles.FIREFLY, 0.001F));
|
||||
.setParticles(EndParticles.SMARAGDANT, 0.001F));
|
||||
|
||||
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL, 1);
|
||||
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL_SHARD, 20);
|
||||
|
||||
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloorDensity() {
|
||||
return 0.1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCeilDensity() {
|
||||
return 0.1F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,4 +34,8 @@ public class EndCaveBiome extends EndBiome {
|
|||
public float getFloorDensity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getCeilDensity() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,21 @@ public class LushAuroraCaveBiome extends EndCaveBiome {
|
|||
.setMusic(EndSounds.MUSIC_FOREST)
|
||||
.setParticles(EndParticles.GLOWING_SPHERE, 0.001F)
|
||||
.setSurface(EndBlocks.CAVE_MOSS));
|
||||
|
||||
this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL, 1);
|
||||
this.addFloorFeature(EndFeatures.CAVE_BUSH, 10);
|
||||
this.addFloorFeature(EndFeatures.CAVE_GRASS, 40);
|
||||
|
||||
this.addCeilFeature(EndFeatures.CAVE_BUSH, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloorDensity() {
|
||||
return 0.01F;
|
||||
return 0.1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCeilDensity() {
|
||||
return 0.03F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,14 +14,22 @@ public class LushSmaragdantCaveBiome extends EndCaveBiome {
|
|||
.setPlantsColor(0, 131, 145)
|
||||
.setWaterAndFogColor(31, 167, 212)
|
||||
.setMusic(EndSounds.MUSIC_FOREST)
|
||||
.setParticles(EndParticles.FIREFLY, 0.001F)
|
||||
.setParticles(EndParticles.SMARAGDANT, 0.001F)
|
||||
.setSurface(EndBlocks.CAVE_MOSS));
|
||||
|
||||
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL, 1);
|
||||
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL_SHARD, 20);
|
||||
|
||||
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloorDensity() {
|
||||
return 0.1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCeilDensity() {
|
||||
return 0.1F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,12 @@ public class BushFeature extends DefaultFeature {
|
|||
for (Direction d: Direction.values()) {
|
||||
BlockPos p = pos.offset(d);
|
||||
if (world.isAir(p)) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.getDefaultState().with(LeavesBlock.DISTANCE, 1));
|
||||
if (leaves instanceof LeavesBlock) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.getDefaultState().with(LeavesBlock.DISTANCE, 1));
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,27 +2,36 @@ package ru.betterend.world.features.terrain;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
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.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class SmaragdantCrystalShardFeature extends DefaultFeature {
|
||||
public class SingleBlockFeature extends DefaultFeature {
|
||||
private final Block block;
|
||||
|
||||
public SingleBlockFeature(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockState shard = EndBlocks.SMARAGDANT_CRYSTAL_SHARD.getDefaultState();
|
||||
boolean waterlogged = !world.getFluidState(pos).isEmpty();
|
||||
BlocksHelper.setWithoutUpdate(world, pos, shard.with(Properties.WATERLOGGED, waterlogged));
|
||||
BlockState state = block.getDefaultState();
|
||||
if (block.getStateManager().getProperty("waterlogged") != null) {
|
||||
boolean waterlogged = !world.getFluidState(pos).isEmpty();
|
||||
state = state.with(Properties.WATERLOGGED, waterlogged);
|
||||
}
|
||||
BlocksHelper.setWithoutUpdate(world, pos, state);
|
||||
|
||||
return true;
|
||||
}
|
|
@ -40,13 +40,8 @@ public class SmaragdantCrystalFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, mut, crystal);
|
||||
mut.setY(mut.getY() + 1);
|
||||
}
|
||||
if (random.nextBoolean()) {
|
||||
boolean waterlogged = !world.getFluidState(mut).isEmpty();
|
||||
BlocksHelper.setWithoutUpdate(world, mut, shard.with(Properties.WATERLOGGED, waterlogged));
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, crystal);
|
||||
}
|
||||
boolean waterlogged = !world.getFluidState(mut).isEmpty();
|
||||
BlocksHelper.setWithoutUpdate(world, mut, shard.with(Properties.WATERLOGGED, waterlogged));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package ru.betterend.world.features.terrain;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
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.blocks.basis.StalactiteBlock;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class StalactiteFeature extends DefaultFeature {
|
||||
private final boolean ceiling;
|
||||
private final Block[] ground;
|
||||
private final Block block;
|
||||
|
||||
public StalactiteFeature(boolean ceiling, Block block, Block... ground) {
|
||||
this.ceiling = ceiling;
|
||||
this.ground = ground;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!isGround(world.getBlockState(ceiling ? pos.up() : pos.down()).getBlock())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
int height = random.nextInt(8);
|
||||
int dir = ceiling ? -1 : 1;
|
||||
boolean stalagnate = false;
|
||||
|
||||
for (int i = 1; i <= height; i++) {
|
||||
mut.setY(pos.getY() + i * dir);
|
||||
BlockState state = world.getBlockState(mut);
|
||||
if (!state.isAir()) {
|
||||
stalagnate = state.isIn(EndTags.GEN_TERRAIN);
|
||||
height = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int center = stalagnate ? height >> 1 : 0;
|
||||
for (int i = 0; i < height; i++) {
|
||||
mut.setY(pos.getY() + i * dir);
|
||||
int size = stalagnate ? MathHelper.abs(i - center) + 1 : height - i - 1;
|
||||
BlocksHelper.setWithoutUpdate(world, mut, block.getDefaultState().with(StalactiteBlock.SIZE, size));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isGround(Block block) {
|
||||
for (Block b : ground) {
|
||||
if (b == block) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -52,23 +52,31 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
Set<BlockPos> caveBlocks = generate(world, center, radius, random);
|
||||
if (!caveBlocks.isEmpty()) {
|
||||
if (biome != null) {
|
||||
boolean fillFloor = biome.getFloorDensity() > 0;
|
||||
boolean fillCeil = biome.getCeilDensity() > 0;
|
||||
setBiomes(world, biome, caveBlocks);
|
||||
Set<BlockPos> floorPositions = Sets.newHashSet();
|
||||
Set<BlockPos> ceilPositions = Sets.newHashSet();
|
||||
Mutable mut = new Mutable();
|
||||
caveBlocks.forEach((bpos) -> {
|
||||
mut.set(bpos);
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
mut.setY(bpos.getY() - 1);
|
||||
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
|
||||
floorPositions.add(mut.toImmutable());
|
||||
if (fillFloor || fillCeil) {
|
||||
caveBlocks.forEach((bpos) -> {
|
||||
mut.set(bpos);
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
if (fillFloor) {
|
||||
mut.setY(bpos.getY() - 1);
|
||||
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
|
||||
floorPositions.add(mut.toImmutable());
|
||||
}
|
||||
}
|
||||
if (fillCeil) {
|
||||
mut.setY(bpos.getY() + 1);
|
||||
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
|
||||
ceilPositions.add(mut.toImmutable());
|
||||
}
|
||||
}
|
||||
}
|
||||
mut.setY(bpos.getY() + 1);
|
||||
if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) {
|
||||
ceilPositions.add(mut.toImmutable());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
placeFloor(world, biome, floorPositions, random, surfaceBlock);
|
||||
placeCeil(world, biome, ceilPositions, random);
|
||||
|
@ -100,7 +108,17 @@ public abstract class EndCaveFeature extends DefaultFeature {
|
|||
}
|
||||
|
||||
protected void placeCeil(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> ceilPositions, Random random) {
|
||||
|
||||
float density = biome.getCeilDensity();
|
||||
if (density > 0) {
|
||||
ceilPositions.forEach((pos) -> {
|
||||
if (random.nextFloat() <= density) {
|
||||
Feature<?> feature = biome.getCeilFeature(random);
|
||||
if (feature != null) {
|
||||
feature.generate(world, null, random, pos.down(), null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void setBiomes(StructureWorldAccess world, EndCaveBiome biome, Set<BlockPos> blocks) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue