Removed color provider

This commit is contained in:
paulevsGitch 2021-07-10 16:25:34 +03:00
parent 2c8862a37b
commit 4040597a6d
475 changed files with 5411 additions and 7521 deletions

View file

@ -21,11 +21,11 @@ import ru.betterend.noise.OpenSimplexNoise;
public class BiomeIslandFeature extends DefaultFeature {
private static final MutableBlockPos CENTER = new MutableBlockPos();
private static final SDF ISLAND;
private static OpenSimplexNoise simplexNoise = new OpenSimplexNoise(412L);
private static BlockState topBlock = Blocks.GRASS_BLOCK.defaultBlockState();
private static BlockState underBlock = Blocks.DIRT.defaultBlockState();
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final BlockPos pos = featureConfig.origin();
@ -45,13 +45,11 @@ public class BiomeIslandFeature extends DefaultFeature {
ISLAND.fillRecursive(world, pos.below());
return true;
}
private static SDF createSDFIsland() {
SDF sdfCone = new SDFCappedCone().setRadius1(0).setRadius2(6).setHeight(4).setBlock(pos -> {
if (pos.getY() > CENTER.getY())
return AIR;
if (pos.getY() == CENTER.getY())
return topBlock;
if (pos.getY() > CENTER.getY()) return AIR;
if (pos.getY() == CENTER.getY()) return topBlock;
return underBlock;
});
sdfCone = new SDFTranslate().setTranslate(0, -2, 0).setSource(sdfCone);
@ -59,14 +57,12 @@ public class BiomeIslandFeature extends DefaultFeature {
float deltaX = Math.abs(pos.x());
float deltaY = Math.abs(pos.y());
float deltaZ = Math.abs(pos.z());
if (deltaY < 2.0f && (deltaX < 3.0f || deltaZ < 3.0F))
return 0.0f;
if (deltaY < 2.0f && (deltaX < 3.0f || deltaZ < 3.0F)) return 0.0f;
return (float) simplexNoise.eval(CENTER.getX() + pos.x(), CENTER.getY() + pos.y(), CENTER.getZ() + pos.z());
}).setSource(sdfCone)
.setReplaceFunction(state -> BlocksHelper.isFluid(state) || state.getMaterial().isReplaceable());
}).setSource(sdfCone).setReplaceFunction(state -> BlocksHelper.isFluid(state) || state.getMaterial().isReplaceable());
return sdfCone;
}
static {
ISLAND = createSDFIsland();
}

View file

@ -11,18 +11,18 @@ import java.util.Random;
public class BlueVineFeature extends ScatterFeature {
private boolean small;
public BlueVineFeature() {
super(5);
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F + random.nextFloat() * 0.4F;
small = d > 0.5F;
return EndBlocks.BLUE_VINE_SEED.canSurvive(AIR, world, blockPos);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (small) {

View file

@ -18,19 +18,16 @@ public class CavePumpkinFeature extends DefaultFeature {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.above()).is(TagAPI.GEN_TERRAIN) || !world.isEmptyBlock(pos)
|| !world.isEmptyBlock(pos.below())) {
if (!world.getBlockState(pos.above()).is(TagAPI.GEN_TERRAIN) || !world.isEmptyBlock(pos) || !world.isEmptyBlock(pos.below())) {
return false;
}
int age = random.nextInt(4);
BlocksHelper.setWithoutUpdate(world, pos,
EndBlocks.CAVE_PUMPKIN_SEED.defaultBlockState().setValue(EndBlockProperties.AGE, age));
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.CAVE_PUMPKIN_SEED.defaultBlockState().setValue(EndBlockProperties.AGE, age));
if (age > 1) {
BlocksHelper.setWithoutUpdate(world, pos.below(),
EndBlocks.CAVE_PUMPKIN.defaultBlockState().setValue(EndBlockProperties.SMALL, age < 3));
BlocksHelper.setWithoutUpdate(world, pos.below(), EndBlocks.CAVE_PUMPKIN.defaultBlockState().setValue(EndBlockProperties.SMALL, age < 3));
}
return true;
}
}

View file

@ -6,7 +6,7 @@ public class CharniaFeature extends UnderwaterPlantFeature {
public CharniaFeature(Block plant) {
super(plant, 6);
}
@Override
protected int getChance() {
return 3;

View file

@ -30,7 +30,7 @@ public class CrashedShipFeature extends NBTStructureFeature {
private static final StructureProcessor REPLACER;
private static final String STRUCTURE_PATH = "/data/minecraft/structures/end_city/ship.nbt";
private StructureTemplate structure;
@Override
protected StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, Random random) {
if (structure == null) {
@ -41,7 +41,7 @@ public class CrashedShipFeature extends NBTStructureFeature {
}
return structure;
}
@Override
protected boolean canSpawn(WorldGenLevel world, BlockPos pos, Random random) {
long x = pos.getX() >> 4;
@ -51,29 +51,29 @@ public class CrashedShipFeature extends NBTStructureFeature {
}
return pos.getY() > 5 && world.getBlockState(pos.below()).is(TagAPI.GEN_TERRAIN);
}
@Override
protected Rotation getRotation(WorldGenLevel world, BlockPos pos, Random random) {
return Rotation.getRandom(random);
}
@Override
protected Mirror getMirror(WorldGenLevel world, BlockPos pos, Random random) {
return Mirror.values()[random.nextInt(3)];
}
@Override
protected int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, Random random) {
int min = structure.getSize().getY() >> 3;
int max = structure.getSize().getY() >> 2;
return -MHelper.randRange(min, max, random);
}
@Override
protected TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, Random random) {
return TerrainMerge.NONE;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -82,11 +82,11 @@ public class CrashedShipFeature extends NBTStructureFeature {
center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8);
center = getGround(world, center);
BoundingBox bounds = makeBox(center);
if (!canSpawn(world, center, random)) {
return false;
}
StructureTemplate structure = getStructure(world, center, random);
Rotation rotation = getRotation(world, center, random);
Mirror mirror = getMirror(world, center, random);
@ -94,37 +94,35 @@ public class CrashedShipFeature extends NBTStructureFeature {
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0);
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror);
center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
BoundingBox structB = structure.getBoundingBox(placementData, center);
bounds = StructureHelper.intersectBoxes(bounds, structB);
addStructureData(placementData);
structure.placeInWorld(world, center, center, placementData.setBoundingBox(bounds), random, 2);
StructureHelper.erodeIntense(world, bounds, random);
BlockFixer.fixBlocks(world, new BlockPos(bounds.minX(), bounds.minY(), bounds.minZ()), new BlockPos(bounds.maxX(), bounds.maxY(), bounds.maxZ()));
return true;
}
@Override
protected void addStructureData(StructurePlaceSettings data) {
data.addProcessor(BlockIgnoreProcessor.STRUCTURE_AND_AIR).addProcessor(REPLACER).setIgnoreEntities(true);
}
static {
REPLACER = new StructureProcessor() {
@Override
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos,
StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2,
StructurePlaceSettings structurePlacementData) {
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlacementData) {
BlockState state = structureBlockInfo2.state;
if (state.is(Blocks.SPAWNER) || state.getMaterial().equals(Material.WOOL)) {
return new StructureBlockInfo(structureBlockInfo2.pos, AIR, null);
}
return structureBlockInfo2;
}
@Override
protected StructureProcessorType<?> getType() {
return StructureProcessorType.NOP;

View file

@ -14,20 +14,20 @@ public class DoublePlantFeature extends ScatterFeature {
private final Block smallPlant;
private final Block largePlant;
private Block plant;
public DoublePlantFeature(Block smallPlant, Block largePlant, int radius) {
super(radius);
this.smallPlant = smallPlant;
this.largePlant = largePlant;
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
float d = MHelper.length(center.getX() - blockPos.getX(), center.getZ() - blockPos.getZ()) / radius * 0.6F + random.nextFloat() * 0.4F;
plant = d < 0.5F ? largePlant : smallPlant;
return plant.canSurvive(plant.defaultBlockState(), world, blockPos);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (plant instanceof BaseDoublePlantBlock) {

View file

@ -11,13 +11,13 @@ public class EndLilyFeature extends UnderwaterPlantScatter {
public EndLilyFeature(int radius) {
super(radius);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
EndLilySeedBlock seed = (EndLilySeedBlock) EndBlocks.END_LILY_SEED;
seed.grow(world, random, blockPos);
}
@Override
protected int getChance() {
return 15;

View file

@ -11,13 +11,13 @@ public class EndLotusFeature extends UnderwaterPlantScatter {
public EndLotusFeature(int radius) {
super(radius);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
EndLotusSeedBlock seed = (EndLotusSeedBlock) EndBlocks.END_LOTUS_SEED;
seed.grow(world, random, blockPos);
}
@Override
protected int getChance() {
return 15;

View file

@ -17,24 +17,24 @@ public class EndLotusLeafFeature extends ScatterFeature {
public EndLotusLeafFeature(int radius) {
super(radius);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (canGenerate(world, blockPos)) {
generateLeaf(world, blockPos);
}
}
@Override
protected int getChance() {
return 15;
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return getPosOnSurface(world, pos);
}
private void generateLeaf(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos();
BlockState leaf = EndBlocks.END_LOTUS_LEAF.defaultBlockState();
@ -48,7 +48,7 @@ public class EndLotusLeafFeature extends ScatterFeature {
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(d1).move(d2), leaf.setValue(EndLotusLeafBlock.HORIZONTAL_FACING, d1).setValue(EndLotusLeafBlock.SHAPE, TripleShape.TOP));
}
}
private boolean canGenerate(WorldGenLevel world, BlockPos pos) {
MutableBlockPos p = new MutableBlockPos();
p.setY(pos.getY());
@ -57,13 +57,12 @@ public class EndLotusLeafFeature extends ScatterFeature {
p.setX(pos.getX() + x);
for (int z = -1; z < 2; z++) {
p.setZ(pos.getZ() + z);
if (world.isEmptyBlock(p) && world.getBlockState(p.below()).is(Blocks.WATER))
count++;
if (world.isEmptyBlock(p) && world.getBlockState(p.below()).is(Blocks.WATER)) count++;
}
}
return count == 9;
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return world.isEmptyBlock(blockPos) && world.getBlockState(blockPos.below()).is(Blocks.WATER);

View file

@ -17,7 +17,7 @@ public class FilaluxFeature extends SkyScatterFeature {
public FilaluxFeature() {
super(10);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
BlockState vine = EndBlocks.FILALUX.defaultBlockState();

View file

@ -15,16 +15,15 @@ import java.util.Random;
public abstract class FullHeightScatterFeature extends DefaultFeature {
private static final MutableBlockPos POS = new MutableBlockPos();
private final int radius;
public FullHeightScatterFeature(int radius) {
this.radius = radius;
}
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos,
float radius);
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -42,13 +41,12 @@ public abstract class FullHeightScatterFeature extends DefaultFeature {
float theta = random.nextFloat() * MHelper.PI2;
float x = pr * (float) Math.cos(theta);
float z = pr * (float) Math.sin(theta);
POS.set(center.getX() + x, y + 5, center.getZ() + z);
int down = BlocksHelper.downRay(world, POS, 16);
if (down > 10)
continue;
if (down > 10) continue;
POS.setY(POS.getY() - down);
if (canGenerate(world, random, center, POS, r)) {
generate(world, random, POS);
}

View file

@ -11,18 +11,18 @@ public class GlowPillarFeature extends ScatterFeature {
public GlowPillarFeature() {
super(9);
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return EndBlocks.GLOWING_PILLAR_SEED.canSurvive(AIR, world, blockPos);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.GLOWING_PILLAR_SEED);
seed.growAdult(world, random, blockPos);
}
@Override
protected int getChance() {
return 10;

View file

@ -11,13 +11,13 @@ public class HydraluxFeature extends UnderwaterPlantScatter {
public HydraluxFeature(int radius) {
super(radius);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
HydraluxSaplingBlock seed = (HydraluxSaplingBlock) EndBlocks.HYDRALUX_SAPLING;
seed.grow(world, random, blockPos);
}
@Override
protected int getChance() {
return 15;

View file

@ -15,16 +15,15 @@ import java.util.Random;
public abstract class InvertedScatterFeature extends DefaultFeature {
private static final MutableBlockPos POS = new MutableBlockPos();
private final int radius;
public InvertedScatterFeature(int radius) {
this.radius = radius;
}
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos,
float radius);
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -42,13 +41,12 @@ public abstract class InvertedScatterFeature extends DefaultFeature {
float theta = random.nextFloat() * MHelper.PI2;
float x = pr * (float) Math.cos(theta);
float z = pr * (float) Math.sin(theta);
POS.set(center.getX() + x, center.getY() - 7, center.getZ() + z);
int up = BlocksHelper.upRay(world, POS, 16);
if (up > 14)
continue;
if (up > 14) continue;
POS.setY(POS.getY() + up);
if (canGenerate(world, random, center, POS, r)) {
generate(world, random, POS);
}

View file

@ -11,18 +11,18 @@ public class LanceleafFeature extends ScatterFeature {
public LanceleafFeature() {
super(7);
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return EndBlocks.LANCELEAF_SEED.canSurvive(AIR, world, blockPos);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.LANCELEAF_SEED);
seed.growAdult(world, random, blockPos);
}
@Override
protected int getChance() {
return 5;

View file

@ -12,11 +12,11 @@ import java.util.function.Function;
public class MengerSpongeFeature extends UnderwaterPlantScatter {
private static final Function<BlockState, Boolean> REPLACE;
public MengerSpongeFeature(int radius) {
super(radius);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.MENGER_SPONGE_WET);
@ -29,7 +29,7 @@ public class MengerSpongeFeature extends UnderwaterPlantScatter {
}
}
}
static {
REPLACE = (state) -> {
if (state.is(EndBlocks.END_LOTUS_STEM)) {

View file

@ -21,10 +21,10 @@ public class NeonCactusFeature extends DefaultFeature {
if (!ground.is(EndBlocks.ENDSTONE_DUST) && !ground.is(EndBlocks.END_MOSS)) {
return false;
}
NeonCactusPlantBlock cactus = ((NeonCactusPlantBlock) EndBlocks.NEON_CACTUS);
cactus.growPlant(world, pos, random);
return true;
}
}

View file

@ -15,20 +15,19 @@ import java.util.Random;
public abstract class ScatterFeature extends DefaultFeature {
private static final MutableBlockPos POS = new MutableBlockPos();
private final int radius;
public ScatterFeature(int radius) {
this.radius = radius;
}
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos,
float radius);
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return getPosOnSurfaceWG(world, pos);
}
protected boolean canSpawn(WorldGenLevel world, BlockPos pos) {
if (pos.getY() < 5) {
return false;
@ -38,7 +37,7 @@ public abstract class ScatterFeature extends DefaultFeature {
}
return true;
}
protected boolean getGroundPlant(WorldGenLevel world, MutableBlockPos pos) {
int down = BlocksHelper.downRay(world, pos, 16);
if (down > Math.abs(getYOffset() * 2)) {
@ -47,26 +46,26 @@ public abstract class ScatterFeature extends DefaultFeature {
pos.setY(pos.getY() - down);
return true;
}
protected int getYOffset() {
return 5;
}
protected int getChance() {
return 1;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
BlockPos center = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
center = getCenterGround(world, center);
if (!canSpawn(world, center)) {
return false;
}
float r = MHelper.randRange(radius * 0.5F, radius, random);
int count = MHelper.floor(r * r * MHelper.randRange(1.5F, 3F, random));
for (int i = 0; i < count; i++) {
@ -74,14 +73,13 @@ public abstract class ScatterFeature extends DefaultFeature {
float theta = random.nextFloat() * MHelper.PI2;
float x = pr * (float) Math.cos(theta);
float z = pr * (float) Math.sin(theta);
POS.set(center.getX() + x, center.getY() + getYOffset(), center.getZ() + z);
if (getGroundPlant(world, POS) && canGenerate(world, random, center, POS, r)
&& (getChance() < 2 || random.nextInt(getChance()) == 0)) {
if (getGroundPlant(world, POS) && canGenerate(world, random, center, POS, r) && (getChance() < 2 || random.nextInt(getChance()) == 0)) {
generate(world, random, POS);
}
}
return true;
}
}

View file

@ -19,7 +19,7 @@ import java.util.Random;
public class SilkMothNestFeature extends DefaultFeature {
private static final MutableBlockPos POS = new MutableBlockPos();
private boolean canGenerate(WorldGenLevel world, BlockPos pos) {
BlockState state = world.getBlockState(pos.above());
if (state.is(BlockTags.LEAVES) || state.is(BlockTags.LOGS)) {
@ -32,7 +32,7 @@ public class SilkMothNestFeature extends DefaultFeature {
}
return false;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -45,11 +45,9 @@ public class SilkMothNestFeature extends DefaultFeature {
POS.setY(y);
if (canGenerate(world, POS)) {
Direction dir = BlocksHelper.randomHorizontal(random);
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.defaultBlockState()
.setValue(BlockStateProperties.HORIZONTAL_FACING, dir).setValue(BlockProperties.ACTIVE, false));
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.defaultBlockState().setValue(BlockStateProperties.HORIZONTAL_FACING, dir).setValue(BlockProperties.ACTIVE, false));
POS.setY(y - 1);
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.defaultBlockState()
.setValue(BlockStateProperties.HORIZONTAL_FACING, dir));
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.SILK_MOTH_NEST.defaultBlockState().setValue(BlockStateProperties.HORIZONTAL_FACING, dir));
return true;
}
}

View file

@ -13,12 +13,12 @@ import java.util.Random;
public class SingleInvertedScatterFeature extends InvertedScatterFeature {
private final Block block;
public SingleInvertedScatterFeature(Block block, int radius) {
super(radius);
this.block = block;
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
if (!world.isEmptyBlock(blockPos)) {
@ -30,7 +30,7 @@ public class SingleInvertedScatterFeature extends InvertedScatterFeature {
}
return state.canSurvive(world, blockPos);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
BlockState state = block.defaultBlockState();

View file

@ -15,40 +15,40 @@ public class SinglePlantFeature extends ScatterFeature {
private final Block plant;
private final boolean rawHeightmap;
private final int chance;
public SinglePlantFeature(Block plant, int radius) {
this(plant, radius, true, 1);
}
public SinglePlantFeature(Block plant, int radius, int chance) {
this(plant, radius, true, chance);
}
public SinglePlantFeature(Block plant, int radius, boolean rawHeightmap) {
this(plant, radius, rawHeightmap, 1);
}
public SinglePlantFeature(Block plant, int radius, boolean rawHeightmap, int chance) {
super(radius);
this.plant = plant;
this.rawHeightmap = rawHeightmap;
this.chance = chance;
}
protected int getChance() {
return chance;
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return rawHeightmap ? getPosOnSurfaceWG(world, pos) : getPosOnSurface(world, pos);
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return plant.canSurvive(plant.defaultBlockState(), world, blockPos);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (plant instanceof BaseDoublePlantBlock) {

View file

@ -13,40 +13,40 @@ public abstract class SkyScatterFeature extends ScatterFeature {
public SkyScatterFeature(int radius) {
super(radius);
}
@Override
protected int getChance() {
return 10;
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
if (!world.isEmptyBlock(blockPos)) {
return false;
}
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (!world.isEmptyBlock(blockPos.relative(dir))) {
return false;
}
}
int maxD = getYOffset() + 2;
int maxV = getYOffset() - 2;
return BlocksHelper.upRay(world, blockPos, maxD) > maxV && BlocksHelper.downRay(world, blockPos, maxD) > maxV;
}
@Override
protected boolean canSpawn(WorldGenLevel world, BlockPos pos) {
return true;
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
return new BlockPos(pos.getX(), MHelper.randRange(32, 192, world.getRandom()), pos.getZ());
}
protected boolean getGroundPlant(WorldGenLevel world, MutableBlockPos pos) {
pos.setY(pos.getY() + MHelper.randRange(-getYOffset(), getYOffset(), world.getRandom()));
return true;

View file

@ -11,17 +11,17 @@ import java.util.Random;
public class UnderwaterPlantFeature extends UnderwaterPlantScatter {
private final Block plant;
public UnderwaterPlantFeature(Block plant, int radius) {
super(radius);
this.plant = plant;
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return super.canSpawn(world, blockPos) && plant.canSurvive(plant.defaultBlockState(), world, blockPos);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
if (plant instanceof BaseDoublePlantBlock) {

View file

@ -9,11 +9,11 @@ import java.util.Random;
public abstract class UnderwaterPlantScatter extends ScatterFeature {
private static final MutableBlockPos POS = new MutableBlockPos();
public UnderwaterPlantScatter(int radius) {
super(radius);
}
@Override
protected BlockPos getCenterGround(WorldGenLevel world, BlockPos pos) {
POS.setX(pos.getX());
@ -21,32 +21,32 @@ public abstract class UnderwaterPlantScatter extends ScatterFeature {
POS.setY(0);
return getGround(world, POS).immutable();
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
return world.getBlockState(blockPos).is(Blocks.WATER);
}
@Override
protected boolean canSpawn(WorldGenLevel world, BlockPos pos) {
return world.getBlockState(pos).is(Blocks.WATER);
}
@Override
protected boolean getGroundPlant(WorldGenLevel world, MutableBlockPos pos) {
return getGround(world, pos).getY() < 128;
}
@Override
protected int getYOffset() {
return -5;
}
@Override
protected int getChance() {
return 5;
}
private BlockPos getGround(WorldGenLevel world, MutableBlockPos pos) {
while (pos.getY() < 128 && world.getFluidState(pos).isEmpty()) {
pos.setY(pos.getY() + 1);

View file

@ -15,20 +15,20 @@ public class VineFeature extends InvertedScatterFeature {
private final Block vineBlock;
private final int maxLength;
private final boolean vine;
public VineFeature(Block vineBlock, int maxLength) {
super(6);
this.vineBlock = vineBlock;
this.maxLength = maxLength;
this.vine = vineBlock instanceof BaseVineBlock;
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
BlockState state = world.getBlockState(blockPos);
return state.getMaterial().isReplaceable() && canPlaceBlock(state, world, blockPos);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
int h = BlocksHelper.downRay(world, blockPos, random.nextInt(maxLength)) - 1;
@ -43,7 +43,7 @@ public class VineFeature extends InvertedScatterFeature {
BlocksHelper.setWithoutUpdate(world, blockPos.below(h), bottom);
}
}
private boolean canPlaceBlock(BlockState state, WorldGenLevel world, BlockPos blockPos) {
if (vine) {
return ((BaseVineBlock) vineBlock).canGenerate(state, world, blockPos);
@ -52,17 +52,17 @@ public class VineFeature extends InvertedScatterFeature {
return vineBlock.canSurvive(state, world, blockPos);
}
}
private BlockState getTopState() {
BlockState state = vineBlock.defaultBlockState();
return vine ? state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP) : state;
}
private BlockState getMiggleState() {
BlockState state = vineBlock.defaultBlockState();
return vine ? state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE) : state;
}
private BlockState getBottomState() {
BlockState state = vineBlock.defaultBlockState();
return vine ? state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM) : state;

View file

@ -14,12 +14,12 @@ import java.util.Random;
public class WallPlantFeature extends WallScatterFeature {
private final Block block;
public WallPlantFeature(Block block, int radius) {
super(radius);
this.block = block;
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos pos, Direction dir) {
if (block instanceof BaseWallPlantBlock) {
@ -32,7 +32,7 @@ public class WallPlantFeature extends WallScatterFeature {
}
return block.canSurvive(block.defaultBlockState(), world, pos);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos pos, Direction dir) {
BlockState state = block.defaultBlockState();

View file

@ -13,7 +13,7 @@ public class WallPlantOnLogFeature extends WallPlantFeature {
public WallPlantOnLogFeature(Block block, int radius) {
super(block, radius);
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos pos, Direction dir) {
BlockPos blockPos = pos.relative(dir.getOpposite());

View file

@ -16,15 +16,15 @@ import java.util.Random;
public abstract class WallScatterFeature extends DefaultFeature {
private static final Direction[] DIR = BlocksHelper.makeHorizontal();
private final int radius;
public WallScatterFeature(int radius) {
this.radius = radius;
}
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos pos, Direction dir);
public abstract void generate(WorldGenLevel world, Random random, BlockPos pos, Direction dir);
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -36,7 +36,7 @@ public abstract class WallScatterFeature extends DefaultFeature {
return false;
}
int py = MHelper.randRange(minY, maxY, random);
MutableBlockPos mut = new MutableBlockPos();
for (int x = -radius; x <= radius; x++) {
mut.setX(center.getX() + x);
@ -56,10 +56,10 @@ public abstract class WallScatterFeature extends DefaultFeature {
}
}
}
return true;
}
private void shuffle(Random random) {
for (int i = 0; i < 4; i++) {
int j = random.nextInt(4);

View file

@ -28,21 +28,20 @@ public class BushFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private final Block leaves;
private final Block stem;
public BushFeature(Block leaves, Block stem) {
this.leaves = leaves;
this.stem = stem;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)
&& !world.getBlockState(pos.above()).is(TagAPI.END_GROUND))
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND) && !world.getBlockState(pos.above()).is(TagAPI.END_GROUND))
return false;
float radius = MHelper.randRange(1.8F, 3.5F, random);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
SDF sphere = new SDFSphere().setRadius(radius).setBlock(this.leaves);
@ -53,8 +52,7 @@ public class BushFeature extends DefaultFeature {
sphere = new SDFDisplacement().setFunction((vec) -> {
return MHelper.randRange(-2F, 2F, random);
}).setSource(sphere);
sphere = new SDFSubtraction().setSourceA(sphere)
.setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
sphere.setReplaceFunction(REPLACE);
sphere.addPostProcess((info) -> {
if (info.getState().getBlock() instanceof LeavesBlock) {
@ -74,18 +72,17 @@ public class BushFeature extends DefaultFeature {
BlockPos p = pos.relative(d);
if (world.isEmptyBlock(p)) {
if (leaves instanceof LeavesBlock) {
BlocksHelper.setWithoutUpdate(world, p,
leaves.defaultBlockState().setValue(LeavesBlock.DISTANCE, 1));
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState().setValue(LeavesBlock.DISTANCE, 1));
}
else {
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState());
}
}
}
return true;
}
static {
REPLACE = (state) -> {
if (state.getMaterial().equals(Material.PLANT)) {

View file

@ -31,22 +31,21 @@ public class BushWithOuterFeature extends DefaultFeature {
private final Block outer_leaves;
private final Block leaves;
private final Block stem;
public BushWithOuterFeature(Block leaves, Block outer_leaves, Block stem) {
this.outer_leaves = outer_leaves;
this.leaves = leaves;
this.stem = stem;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)
&& !world.getBlockState(pos.above()).is(TagAPI.END_GROUND))
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND) && !world.getBlockState(pos.above()).is(TagAPI.END_GROUND))
return false;
float radius = MHelper.randRange(1.8F, 3.5F, random);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
SDF sphere = new SDFSphere().setRadius(radius).setBlock(this.leaves);
@ -57,8 +56,7 @@ public class BushWithOuterFeature extends DefaultFeature {
sphere = new SDFDisplacement().setFunction((vec) -> {
return MHelper.randRange(-2F, 2F, random);
}).setSource(sphere);
sphere = new SDFSubtraction().setSourceA(sphere)
.setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
sphere.setReplaceFunction(REPLACE);
sphere.addPostProcess((info) -> {
if (info.getState().getBlock() instanceof LeavesBlock) {
@ -76,8 +74,7 @@ public class BushWithOuterFeature extends DefaultFeature {
MHelper.shuffle(DIRECTIONS, random);
for (Direction dir : DIRECTIONS) {
if (info.getState(dir).isAir()) {
info.setBlockPos(info.getPos().relative(dir),
outer_leaves.defaultBlockState().setValue(BlockStateProperties.FACING, dir));
info.setBlockPos(info.getPos().relative(dir), outer_leaves.defaultBlockState().setValue(BlockStateProperties.FACING, dir));
}
}
}
@ -89,18 +86,17 @@ public class BushWithOuterFeature extends DefaultFeature {
BlockPos p = pos.relative(d);
if (world.isEmptyBlock(p)) {
if (leaves instanceof LeavesBlock) {
BlocksHelper.setWithoutUpdate(world, p,
leaves.defaultBlockState().setValue(LeavesBlock.DISTANCE, 1));
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState().setValue(LeavesBlock.DISTANCE, 1));
}
else {
BlocksHelper.setWithoutUpdate(world, p, leaves.defaultBlockState());
}
}
}
return true;
}
static {
REPLACE = (state) -> {
if (state.getMaterial().equals(Material.PLANT)) {

View file

@ -23,9 +23,8 @@ public class LargeAmaranitaFeature extends DefaultFeature {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND))
return false;
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) return false;
MutableBlockPos mut = new MutableBlockPos().set(pos);
int height = MHelper.randRange(2, 3, random);
for (int i = 1; i < height; i++) {
@ -35,16 +34,14 @@ public class LargeAmaranitaFeature extends DefaultFeature {
}
}
mut.set(pos);
BlockState state = EndBlocks.LARGE_AMARANITA_MUSHROOM.defaultBlockState();
BlocksHelper.setWithUpdate(world, mut, state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
if (height > 2) {
BlocksHelper.setWithUpdate(world, mut.move(Direction.UP),
state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
BlocksHelper.setWithUpdate(world, mut.move(Direction.UP), state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
}
BlocksHelper.setWithUpdate(world, mut.move(Direction.UP),
state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
BlocksHelper.setWithUpdate(world, mut.move(Direction.UP), state.setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
return true;
}
}

View file

@ -23,9 +23,8 @@ public class Lumecorn extends DefaultFeature {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND))
return false;
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) return false;
int height = MHelper.randRange(4, 7, random);
MutableBlockPos mut = new MutableBlockPos().set(pos);
for (int i = 1; i < height; i++) {
@ -35,30 +34,23 @@ public class Lumecorn extends DefaultFeature {
}
}
mut.set(pos);
BlockState topMiddle = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE,
LumecornShape.LIGHT_TOP_MIDDLE);
BlockState middle = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE,
LumecornShape.LIGHT_MIDDLE);
BlockState bottom = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE,
LumecornShape.LIGHT_BOTTOM);
BlockState topMiddle = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP_MIDDLE);
BlockState middle = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.LIGHT_MIDDLE);
BlockState bottom = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.LIGHT_BOTTOM);
BlockState top = EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.LIGHT_TOP);
if (height == 4) {
BlocksHelper.setWithoutUpdate(world, mut,
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), bottom);
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), topMiddle);
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), top);
return true;
}
if (random.nextBoolean()) {
BlocksHelper.setWithoutUpdate(world, mut,
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_SMALL));
}
else {
BlocksHelper.setWithoutUpdate(world, mut,
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_BIG));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP),
EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.MIDDLE));
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.BOTTOM_BIG));
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), EndBlocks.LUMECORN.defaultBlockState().setValue(LumecornBlock.SHAPE, LumecornShape.MIDDLE));
height--;
}
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), bottom);

View file

@ -33,29 +33,25 @@ import java.util.function.Function;
public class TenaneaBushFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private static final Direction[] DIRECTIONS = Direction.values();
public TenaneaBushFeature() {
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND))
return false;
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) return false;
float radius = MHelper.randRange(1.8F, 3.5F, random);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
BlockState leaves = EndBlocks.TENANEA_LEAVES.defaultBlockState();
SDF sphere = new SDFSphere().setRadius(radius).setBlock(leaves);
sphere = new SDFScale3D().setScale(1, 0.75F, 1).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) ->
(float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) ->
MHelper.randRange(-2F, 2F, random)).setSource(sphere);
sphere = new SDFSubtraction().setSourceA(sphere)
.setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
sphere = new SDFDisplacement().setFunction((vec) -> (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> MHelper.randRange(-2F, 2F, random)).setSource(sphere);
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
sphere.setReplaceFunction(REPLACE);
List<BlockPos> support = Lists.newArrayList();
sphere.addPostProcess((info) -> {
@ -66,15 +62,14 @@ public class TenaneaBushFeature extends DefaultFeature {
BlockPos d = info.getPos().below();
support.add(d);
}
MHelper.shuffle(DIRECTIONS, random);
for (Direction d : DIRECTIONS) {
if (info.getState(d).isAir()) {
info.setBlockPos(info.getPos().relative(d),
EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState().setValue(FurBlock.FACING, d));
info.setBlockPos(info.getPos().relative(d), EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState().setValue(FurBlock.FACING, d));
}
}
return info.getState().setValue(LeavesBlock.DISTANCE, distance);
}
else {
@ -92,14 +87,11 @@ public class TenaneaBushFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, p, leaves.setValue(LeavesBlock.DISTANCE, 1));
}
}
MutableBlockPos mut = new MutableBlockPos();
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.TOP);
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.MIDDLE);
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.BOTTOM);
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE);
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM);
support.forEach((bpos) -> {
BlockState state = world.getBlockState(bpos);
if (state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) {
@ -120,10 +112,10 @@ public class TenaneaBushFeature extends DefaultFeature {
}
}
});
return true;
}
static {
REPLACE = (state) -> {
if (state.getMaterial().equals(Material.PLANT)) {

View file

@ -25,26 +25,24 @@ public class BigAuroraCrystalFeature extends DefaultFeature {
final WorldGenLevel world = featureConfig.level();
int maxY = pos.getY() + BlocksHelper.upRay(world, pos, 16);
int minY = pos.getY() - BlocksHelper.downRay(world, pos, 16);
if (maxY - minY < 10) {
return false;
}
int y = MHelper.randRange(minY, maxY, random);
pos = new BlockPos(pos.getX(), y, pos.getZ());
int height = MHelper.randRange(5, 25, random);
SDF prism = new SDFHexPrism().setHeight(height).setRadius(MHelper.randRange(1.7F, 3F, random))
.setBlock(EndBlocks.AURORA_CRYSTAL);
SDF prism = new SDFHexPrism().setHeight(height).setRadius(MHelper.randRange(1.7F, 3F, random)).setBlock(EndBlocks.AURORA_CRYSTAL);
Vector3f vec = MHelper.randomHorizontal(random);
prism = new SDFRotation().setRotation(vec, random.nextFloat()).setSource(prism);
prism.setReplaceFunction((bState) -> {
return bState.getMaterial().isReplaceable() || bState.is(TagAPI.GEN_TERRAIN)
|| bState.getMaterial().equals(Material.PLANT) || bState.getMaterial().equals(Material.LEAVES);
return bState.getMaterial().isReplaceable() || bState.is(TagAPI.GEN_TERRAIN) || bState.getMaterial().equals(Material.PLANT) || bState.getMaterial().equals(Material.LEAVES);
});
prism.fillRecursive(world, pos);
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.AURORA_CRYSTAL);
return true;
}
}

View file

@ -23,7 +23,7 @@ public class DesertLakeFeature extends DefaultFeature {
private static final BlockState END_STONE = Blocks.END_STONE.defaultBlockState();
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(15152);
private static final MutableBlockPos POS = new MutableBlockPos();
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -35,35 +35,35 @@ public class DesertLakeFeature extends DefaultFeature {
int dist2 = MHelper.floor(radius * 1.5);
int bott = MHelper.floor(depth);
blockPos = getPosOnSurfaceWG(world, blockPos);
if (blockPos.getY() < 10) return false;
int waterLevel = blockPos.getY();
BlockPos pos = getPosOnSurfaceRaycast(world, blockPos.north(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
pos = getPosOnSurfaceRaycast(world, blockPos.south(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
pos = getPosOnSurfaceRaycast(world, blockPos.east(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
pos = getPosOnSurfaceRaycast(world, blockPos.west(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
BlockState state;
int minX = blockPos.getX() - dist2;
int maxX = blockPos.getX() + dist2;
int minZ = blockPos.getZ() - dist2;
int maxZ = blockPos.getZ() + dist2;
int maskMinX = minX - 1;
int maskMinZ = minZ - 1;
boolean[][] mask = new boolean[maxX - minX + 3][maxZ - minZ + 3];
for (int x = minX; x <= maxX; x++) {
POS.setX(x);
@ -89,7 +89,7 @@ public class DesertLakeFeature extends DefaultFeature {
}
}
}
for (int x = minX; x <= maxX; x++) {
POS.setX(x);
int x2 = x - blockPos.getX();
@ -120,8 +120,7 @@ public class DesertLakeFeature extends DefaultFeature {
pos = POS.below();
if (world.getBlockState(pos).is(TagAPI.GEN_TERRAIN)) {
state = world.getBiome(pos).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
if (y > waterLevel + 1)
BlocksHelper.setWithoutUpdate(world, pos, state);
if (y > waterLevel + 1) BlocksHelper.setWithoutUpdate(world, pos, state);
else if (y > waterLevel)
BlocksHelper.setWithoutUpdate(world, pos, random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.defaultBlockState());
else
@ -136,9 +135,9 @@ public class DesertLakeFeature extends DefaultFeature {
}
}
}
double aspect = ((double) radius / (double) depth);
for (int x = blockPos.getX() - dist; x <= blockPos.getX() + dist; x++) {
POS.setX(x);
int x2 = x - blockPos.getX();
@ -197,17 +196,13 @@ public class DesertLakeFeature extends DefaultFeature {
}
}
}
BlockFixer.fixBlocks(world, new BlockPos(minX - 2, waterLevel - 2, minZ - 2), new BlockPos(maxX + 2, blockPos.getY() + 20, maxZ + 2));
return true;
}
private boolean canReplace(BlockState state) {
return state.getMaterial().isReplaceable()
|| state.is(TagAPI.GEN_TERRAIN)
|| state.is(EndBlocks.ENDSTONE_DUST)
|| state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().equals(Material.WATER_PLANT);
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.is(EndBlocks.ENDSTONE_DUST) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.WATER_PLANT);
}
}

View file

@ -23,7 +23,7 @@ public class EndLakeFeature extends DefaultFeature {
private static final BlockState END_STONE = Blocks.END_STONE.defaultBlockState();
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(15152);
private static final MutableBlockPos POS = new MutableBlockPos();
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -35,35 +35,35 @@ public class EndLakeFeature extends DefaultFeature {
int dist2 = MHelper.floor(radius * 1.5);
int bott = MHelper.floor(depth);
blockPos = getPosOnSurfaceWG(world, blockPos);
if (blockPos.getY() < 10) return false;
int waterLevel = blockPos.getY();
BlockPos pos = getPosOnSurfaceRaycast(world, blockPos.north(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
pos = getPosOnSurfaceRaycast(world, blockPos.south(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
pos = getPosOnSurfaceRaycast(world, blockPos.east(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
pos = getPosOnSurfaceRaycast(world, blockPos.west(dist).above(10), 20);
if (Math.abs(blockPos.getY() - pos.getY()) > 5) return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
BlockState state;
int minX = blockPos.getX() - dist2;
int maxX = blockPos.getX() + dist2;
int minZ = blockPos.getZ() - dist2;
int maxZ = blockPos.getZ() + dist2;
int maskMinX = minX - 1;
int maskMinZ = minZ - 1;
boolean[][] mask = new boolean[maxX - minX + 3][maxZ - minZ + 3];
for (int x = minX; x <= maxX; x++) {
POS.setX(x);
@ -89,7 +89,7 @@ public class EndLakeFeature extends DefaultFeature {
}
}
}
for (int x = minX; x <= maxX; x++) {
POS.setX(x);
int x2 = x - blockPos.getX();
@ -120,8 +120,7 @@ public class EndLakeFeature extends DefaultFeature {
pos = POS.below();
if (world.getBlockState(pos).is(TagAPI.GEN_TERRAIN)) {
state = world.getBiome(pos).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
if (y > waterLevel + 1)
BlocksHelper.setWithoutUpdate(world, pos, state);
if (y > waterLevel + 1) BlocksHelper.setWithoutUpdate(world, pos, state);
else if (y > waterLevel)
BlocksHelper.setWithoutUpdate(world, pos, random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.defaultBlockState());
else
@ -136,9 +135,9 @@ public class EndLakeFeature extends DefaultFeature {
}
}
}
double aspect = ((double) radius / (double) depth);
for (int x = blockPos.getX() - dist; x <= blockPos.getX() + dist; x++) {
POS.setX(x);
int x2 = x - blockPos.getX();
@ -191,17 +190,13 @@ public class EndLakeFeature extends DefaultFeature {
}
}
}
BlockFixer.fixBlocks(world, new BlockPos(minX - 2, waterLevel - 2, minZ - 2), new BlockPos(maxX + 2, blockPos.getY() + 20, maxZ + 2));
return true;
}
private boolean canReplace(BlockState state) {
return state.getMaterial().isReplaceable()
|| state.is(TagAPI.GEN_TERRAIN)
|| state.is(EndBlocks.ENDSTONE_DUST)
|| state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().equals(Material.WATER_PLANT);
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.is(EndBlocks.ENDSTONE_DUST) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.WATER_PLANT);
}
}

View file

@ -27,16 +27,14 @@ public class FallenPillarFeature extends DefaultFeature {
final Random random = featureConfig.random();
BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
pos = getPosOnSurface(world,
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
if (!world.getBlockState(pos.below(5)).is(TagAPI.GEN_TERRAIN)) {
return false;
}
float height = MHelper.randRange(20F, 40F, random);
float radius = MHelper.randRange(2F, 4F, random);
SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F)
.setBlock(Blocks.OBSIDIAN);
SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F).setBlock(Blocks.OBSIDIAN);
pillar = new SDFTranslate().setTranslate(0, radius * 0.5F - 2, 0).setSource(pillar);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
pillar = new SDFDisplacement().setFunction((vec) -> {
@ -45,7 +43,7 @@ public class FallenPillarFeature extends DefaultFeature {
Vector3f vec = MHelper.randomHorizontal(random);
float angle = (float) random.nextGaussian() * 0.05F + (float) Math.PI;
pillar = new SDFRotation().setRotation(vec, angle).setSource(pillar);
BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.defaultBlockState();
pillar.addPostProcess((info) -> {
if (info.getStateUp().isAir() && random.nextFloat() > 0.1F) {
@ -53,10 +51,9 @@ public class FallenPillarFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN)
|| state.getMaterial().equals(Material.PLANT);
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT);
}).fillRecursive(world, pos);
return true;
}
}

View file

@ -28,13 +28,12 @@ public class FloatingSpireFeature extends SpireFeature {
final WorldGenLevel world = featureConfig.level();
final ChunkGenerator chunkGenerator = featureConfig.chunkGenerator();
int minY = getYOnSurface(world, pos.getX(), pos.getZ());
int y = minY > 57 ? MHelper.floor(MHelper.randRange(minY, minY * 2, random) * 0.5F + 32)
: MHelper.randRange(64, 192, random);
int y = minY > 57 ? MHelper.floor(MHelper.randRange(minY, minY * 2, random) * 0.5F + 32) : MHelper.randRange(64, 192, random);
pos = new BlockPos(pos.getX(), y, pos.getZ());
SDF sdf = new SDFSphere().setRadius(MHelper.randRange(2, 3, random)).setBlock(Blocks.END_STONE);
int count = MHelper.randRange(3, 5, random);
for (int i = 0; i < count; i++) {
float rMin = (i * 1.3F) + 2.5F;
sdf = addSegment(sdf, MHelper.randRange(rMin, rMin + 1.5F, random), random);
@ -43,11 +42,10 @@ public class FloatingSpireFeature extends SpireFeature {
float rMin = (i * 1.3F) + 2.5F;
sdf = addSegment(sdf, MHelper.randRange(rMin, rMin + 1.5F, random), random);
}
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
sdf = new SDFDisplacement().setFunction((vec) -> {
return (float) (Math.abs(noise.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1)) * 3F
+ Math.abs(noise.eval(vec.x() * 0.3, vec.y() * 0.3 + 100, vec.z() * 0.3)) * 1.3F);
return (float) (Math.abs(noise.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1)) * 3F + Math.abs(noise.eval(vec.x() * 0.3, vec.y() * 0.3 + 100, vec.z() * 0.3)) * 1.3F);
}).setSource(sdf);
final BlockPos center = pos;
List<BlockPos> support = Lists.newArrayList();
@ -59,19 +57,18 @@ public class FloatingSpireFeature extends SpireFeature {
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
}
else if (info.getState(Direction.UP, 3).isAir()) {
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig()
.getUnderMaterial();
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getUnderMaterial();
}
return info.getState();
});
sdf.fillRecursive(world, center);
support.forEach((bpos) -> {
if (BiomeAPI.getFromBiome(world.getBiome(bpos)) == EndBiomes.BLOSSOMING_SPIRES) {
EndFeatures.TENANEA_BUSH.getFeature().place(new FeaturePlaceContext<>(world, chunkGenerator, random, bpos, null));
}
});
return true;
}
}

View file

@ -45,18 +45,18 @@ public class GeyserFeature extends DefaultFeature {
protected static final Function<BlockState, Boolean> REPLACE2;
private static final Function<BlockState, Boolean> IGNORE;
private static final Direction[] HORIZONTAL = BlocksHelper.makeHorizontal();
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final WorldGenLevel world = featureConfig.level();
final BlockPos pos = getPosOnSurfaceWG(world, featureConfig.origin());
final ChunkGenerator chunkGenerator = featureConfig.chunkGenerator();
if (pos.getY() < 10) {
return false;
}
MutableBlockPos bpos = new MutableBlockPos().set(pos);
bpos.setY(bpos.getY() - 1);
BlockState state = world.getBlockState(bpos);
@ -64,105 +64,102 @@ public class GeyserFeature extends DefaultFeature {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
if (pos.getY() - bpos.getY() < 25) {
return false;
}
int halfHeight = MHelper.randRange(10, 20, random);
float radius1 = halfHeight * 0.5F;
float radius2 = halfHeight * 0.1F + 0.5F;
SDF sdf = new SDFCappedCone().setHeight(halfHeight).setRadius1(radius1).setRadius2(radius2)
.setBlock(EndBlocks.SULPHURIC_ROCK.stone);
SDF sdf = new SDFCappedCone().setHeight(halfHeight).setRadius1(radius1).setRadius2(radius2).setBlock(EndBlocks.SULPHURIC_ROCK.stone);
sdf = new SDFTranslate().setTranslate(0, halfHeight - 3, 0).setSource(sdf);
int count = halfHeight;
for (int i = 0; i < count; i++) {
int py = i << 1;
float delta = (float) i / (float) (count - 1);
float radius = Mth.lerp(delta, radius1, radius2) * 1.3F;
SDF bowl = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius)
.setBlock(EndBlocks.SULPHURIC_ROCK.stone);
SDF brimstone = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius)
.setBlock(EndBlocks.BRIMSTONE);
SDF bowl = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius).setBlock(EndBlocks.SULPHURIC_ROCK.stone);
SDF brimstone = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius).setBlock(EndBlocks.BRIMSTONE);
brimstone = new SDFTranslate().setTranslate(0, 2F, 0).setSource(brimstone);
bowl = new SDFSubtraction().setSourceA(bowl).setSourceB(brimstone);
bowl = new SDFUnion().setSourceA(brimstone).setSourceB(bowl);
SDF water = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius).setBlock(Blocks.WATER);
water = new SDFTranslate().setTranslate(0, 4, 0).setSource(water);
bowl = new SDFSubtraction().setSourceA(bowl).setSourceB(water);
bowl = new SDFUnion().setSourceA(water).setSourceB(bowl);
final OpenSimplexNoise noise1 = new OpenSimplexNoise(random.nextLong());
final OpenSimplexNoise noise2 = new OpenSimplexNoise(random.nextLong());
bowl = new SDFCoordModify().setFunction((vec) -> {
float dx = (float) noise1.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1);
float dz = (float) noise2.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1);
vec.set(vec.x() + dx, vec.y(), vec.z() + dz);
}).setSource(bowl);
SDF cut = new SDFFlatland().setBlock(Blocks.AIR);
cut = new SDFInvert().setSource(cut);
cut = new SDFTranslate().setTranslate(0, radius - 2, 0).setSource(cut);
bowl = new SDFSubtraction().setSourceA(bowl).setSourceB(cut);
bowl = new SDFTranslate().setTranslate(radius, py - radius, 0).setSource(bowl);
bowl = new SDFRotation().setRotation(Vector3f.YP, i * 4F).setSource(bowl);
sdf = new SDFUnion().setSourceA(sdf).setSourceB(bowl);
}
sdf.setReplaceFunction(REPLACE2).fillRecursive(world, pos);
radius2 = radius2 * 0.5F;
if (radius2 < 0.7F) {
radius2 = 0.7F;
}
final OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
SDFPrimitive obj1;
SDFPrimitive obj2;
obj1 = new SDFCappedCone().setHeight(halfHeight + 5).setRadius1(radius1 * 0.5F).setRadius2(radius2);
sdf = new SDFTranslate().setTranslate(0, halfHeight - 13, 0).setSource(obj1);
sdf = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.3F, vec.y() * 0.3F, vec.z() * 0.3F) * 0.5F;
}).setSource(sdf);
obj2 = new SDFSphere().setRadius(radius1);
SDF cave = new SDFScale3D().setScale(1.5F, 1, 1.5F).setSource(obj2);
cave = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.1F, vec.y() * 0.1F, vec.z() * 0.1F) * 2F;
}).setSource(cave);
cave = new SDFTranslate().setTranslate(0, -halfHeight - 10, 0).setSource(cave);
sdf = new SDFSmoothUnion().setRadius(5).setSourceA(cave).setSourceB(sdf);
obj1.setBlock(WATER);
obj2.setBlock(WATER);
sdf.setReplaceFunction(REPLACE2);
sdf.fillRecursive(world, pos);
obj1.setBlock(EndBlocks.BRIMSTONE);
obj2.setBlock(EndBlocks.BRIMSTONE);
new SDFDisplacement().setFunction((vec) -> {
return -2F;
}).setSource(sdf).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE);
obj1.setBlock(EndBlocks.SULPHURIC_ROCK.stone);
obj2.setBlock(EndBlocks.SULPHURIC_ROCK.stone);
new SDFDisplacement().setFunction((vec) -> {
return -4F;
}).setSource(cave).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE);
obj1.setBlock(Blocks.END_STONE);
obj2.setBlock(Blocks.END_STONE);
new SDFDisplacement().setFunction((vec) -> {
return -6F;
}).setSource(cave).setReplaceFunction(REPLACE1).fillRecursiveIgnore(world, pos, IGNORE);
BlocksHelper.setWithoutUpdate(world, pos, WATER);
MutableBlockPos mut = new MutableBlockPos().set(pos);
count = getYOnSurface(world, pos.getX(), pos.getZ()) - pos.getY();
@ -173,10 +170,9 @@ public class GeyserFeature extends DefaultFeature {
}
mut.setY(mut.getY() + 1);
}
for (int i = 0; i < 150; i++) {
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 4 + 0.5), -halfHeight - 10,
MHelper.floor(random.nextGaussian() * 4 + 0.5));
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 4 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 4 + 0.5));
float distRaw = MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ());
int dist = MHelper.floor(6 - distRaw) + random.nextInt(2);
if (dist >= 0) {
@ -185,22 +181,19 @@ public class GeyserFeature extends DefaultFeature {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.is(TagAPI.GEN_TERRAIN)
&& !world.getBlockState(mut.above()).is(EndBlocks.HYDROTHERMAL_VENT)) {
if (state.is(TagAPI.GEN_TERRAIN) && !world.getBlockState(mut.above()).is(EndBlocks.HYDROTHERMAL_VENT)) {
for (int j = 0; j <= dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
MHelper.shuffle(HORIZONTAL, random);
for (Direction dir : HORIZONTAL) {
BlockPos p = mut.relative(dir);
if (random.nextBoolean() && world.getBlockState(p).is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState()
.setValue(HorizontalDirectionalBlock.FACING, dir));
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, dir));
}
}
mut.setY(mut.getY() + 1);
}
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.ACTIVATED,
distRaw < 2);
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.ACTIVATED, distRaw < 2);
BlocksHelper.setWithoutUpdate(world, mut, state);
mut.setY(mut.getY() + 1);
state = world.getBlockState(mut);
@ -212,10 +205,9 @@ public class GeyserFeature extends DefaultFeature {
}
}
}
for (int i = 0; i < 10; i++) {
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 0.7 + 0.5), -halfHeight - 10,
MHelper.floor(random.nextGaussian() * 0.7 + 0.5));
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 0.7 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 0.7 + 0.5));
float distRaw = MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ());
int dist = MHelper.floor(6 - distRaw) + random.nextInt(2);
if (dist >= 0) {
@ -229,8 +221,7 @@ public class GeyserFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
mut.setY(mut.getY() + 1);
}
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.ACTIVATED,
distRaw < 2);
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.ACTIVATED, distRaw < 2);
BlocksHelper.setWithoutUpdate(world, mut, state);
mut.setY(mut.getY() + 1);
state = world.getBlockState(mut);
@ -242,22 +233,22 @@ public class GeyserFeature extends DefaultFeature {
}
}
}
EndFeatures.SULPHURIC_LAKE.getFeature().place(new FeaturePlaceContext<>(world, chunkGenerator, random, pos, null));
double distance = radius1 * 1.7;
BlockPos start = pos.offset(-distance, -halfHeight - 15 - distance, -distance);
BlockPos end = pos.offset(distance, -halfHeight - 5 + distance, distance);
BlockFixer.fixBlocks(world, start, end);
return true;
}
static {
REPLACE1 = (state) -> {
return state.isAir() || (state.is(TagAPI.GEN_TERRAIN));
};
REPLACE2 = (state) -> {
if (state.is(TagAPI.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT) || state.is(EndBlocks.SULPHUR_CRYSTAL)) {
return true;
@ -267,7 +258,7 @@ public class GeyserFeature extends DefaultFeature {
}
return state.getMaterial().isReplaceable();
};
IGNORE = (state) -> {
return state.is(Blocks.WATER) || state.is(Blocks.CAVE_AIR) || state.is(EndBlocks.SULPHURIC_ROCK.stone) || state.is(EndBlocks.BRIMSTONE);
};

View file

@ -24,14 +24,14 @@ public class IceStarFeature extends DefaultFeature {
private final float maxSize;
private final int minCount;
private final int maxCount;
public IceStarFeature(float minSize, float maxSize, int minCount, int maxCount) {
this.minSize = minSize;
this.maxSize = maxSize;
this.minCount = minCount;
this.maxCount = maxCount;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -41,8 +41,7 @@ public class IceStarFeature extends DefaultFeature {
int count = MHelper.randRange(minCount, maxCount, random);
List<Vector3f> points = getFibonacciPoints(count);
SDF sdf = null;
SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F).setRadius2(0).setHeight(size)
.setBlock(EndBlocks.DENSE_SNOW);
SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F).setRadius2(0).setHeight(size).setBlock(EndBlocks.DENSE_SNOW);
spike = new SDFTranslate().setTranslate(0, size - 0.5F, 0).setSource(spike);
for (Vector3f point : points) {
SDF rotated = spike;
@ -57,29 +56,28 @@ public class IceStarFeature extends DefaultFeature {
}
sdf = (sdf == null) ? rotated : new SDFUnion().setSourceA(sdf).setSourceB(rotated);
}
int x1 = (pos.getX() >> 4) << 4;
int z1 = (pos.getZ() >> 4) << 4;
pos = new BlockPos(x1 + random.nextInt(16), MHelper.randRange(32, 128, random), z1 + random.nextInt(16));
final float ancientRadius = size * 0.7F;
final float denseRadius = size * 0.9F;
final float iceRadius = size < 7 ? size * 5 : size * 1.3F;
final float randScale = size * 0.3F;
final BlockPos center = pos;
final BlockState ice = EndBlocks.EMERALD_ICE.defaultBlockState();
final BlockState dense = EndBlocks.DENSE_EMERALD_ICE.defaultBlockState();
final BlockState ancient = EndBlocks.ANCIENT_EMERALD_ICE.defaultBlockState();
final SDF sdfCopy = sdf;
sdf.addPostProcess((info) -> {
BlockPos bpos = info.getPos();
float px = bpos.getX() - center.getX();
float py = bpos.getY() - center.getY();
float pz = bpos.getZ() - center.getZ();
float distance = MHelper.length(px, py, pz) + sdfCopy.getDistance(px, py, pz) * 0.4F
+ random.nextFloat() * randScale;
float distance = MHelper.length(px, py, pz) + sdfCopy.getDistance(px, py, pz) * 0.4F + random.nextFloat() * randScale;
if (distance < ancientRadius) {
return ancient;
}
@ -91,10 +89,10 @@ public class IceStarFeature extends DefaultFeature {
}
return info.getState();
}).fillRecursive(world, pos);
return true;
}
private List<Vector3f> getFibonacciPoints(int count) {
float max = count - 1;
List<Vector3f> result = new ArrayList<Vector3f>(count);

View file

@ -25,27 +25,25 @@ public class ObsidianBoulderFeature extends DefaultFeature {
final Random random = featureConfig.random();
BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
pos = getPosOnSurface(world,
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) {
return false;
}
int count = MHelper.randRange(1, 5, random);
for (int i = 0; i < count; i++) {
BlockPos p = getPosOnSurface(world,
new BlockPos(pos.getX() + random.nextInt(16) - 8, pos.getY(), pos.getZ() + random.nextInt(16) - 8));
BlockPos p = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16) - 8, pos.getY(), pos.getZ() + random.nextInt(16) - 8));
makeBoulder(world, p, random);
}
return true;
}
private void makeBoulder(WorldGenLevel world, BlockPos pos, Random random) {
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) {
return;
}
float radius = MHelper.randRange(1F, 5F, random);
SDF sphere = new SDFSphere().setRadius(radius).setBlock(Blocks.OBSIDIAN);
float sx = MHelper.randRange(0.7F, 1.3F, random);
@ -56,7 +54,7 @@ public class ObsidianBoulderFeature extends DefaultFeature {
sphere = new SDFDisplacement().setFunction((vec) -> {
return (float) (noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 1.5F);
}).setSource(sphere);
BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.defaultBlockState();
sphere.addPostProcess((info) -> {
if (info.getStateUp().isAir() && random.nextFloat() > 0.1F) {
@ -64,8 +62,7 @@ public class ObsidianBoulderFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN)
|| state.getMaterial().equals(Material.PLANT);
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT);
}).fillRecursive(world, pos);
}
}

View file

@ -33,7 +33,7 @@ public class ObsidianPillarBasementFeature extends DefaultFeature {
if (!world.getBlockState(pos.below(5)).is(TagAPI.GEN_TERRAIN)) {
return false;
}
float height = MHelper.randRange(10F, 35F, random);
float radius = MHelper.randRange(2F, 5F, random);
SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F).setBlock(Blocks.OBSIDIAN);
@ -60,7 +60,7 @@ public class ObsidianPillarBasementFeature extends DefaultFeature {
}).setReplaceFunction((state) -> {
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT);
}).fillRecursive(world, pos);
return true;
}
}

View file

@ -20,20 +20,20 @@ public class OreLayerFeature extends DefaultFeature {
private static final SDFSphere SPHERE;
private static final SDFCoordModify NOISE;
private static final SDF FUNCTION;
private final BlockState state;
private final float radius;
private final int minY;
private final int maxY;
private OpenSimplexNoise noise;
public OreLayerFeature(BlockState state, float radius, int minY, int maxY) {
this.state = state;
this.radius = radius;
this.minY = minY;
this.maxY = maxY;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -44,11 +44,11 @@ public class OreLayerFeature extends DefaultFeature {
int posX = MHelper.randRange(Math.max(r - 16, 0), Math.min(31 - r, 15), random) + pos.getX();
int posZ = MHelper.randRange(Math.max(r - 16, 0), Math.min(31 - r, 15), random) + pos.getZ();
int posY = MHelper.randRange(minY, maxY, random);
if (noise == null) {
noise = new OpenSimplexNoise(world.getSeed());
}
SPHERE.setRadius(radius).setBlock(state);
NOISE.setFunction((vec) -> {
double x = (vec.x() + pos.getX()) * 0.1;
@ -59,18 +59,18 @@ public class OreLayerFeature extends DefaultFeature {
FUNCTION.fillRecursive(world, new BlockPos(posX, posY, posZ));
return true;
}
static {
SPHERE = new SDFSphere();
NOISE = new SDFCoordModify();
SDF body = SPHERE;
body = new SDFScale3D().setScale(1, 0.2F, 1).setSource(body);
body = NOISE.setSource(body);
body.setReplaceFunction((state) -> {
return state.is(Blocks.END_STONE);
});
FUNCTION = body;
}
}

View file

@ -15,11 +15,11 @@ import java.util.Random;
public class SingleBlockFeature extends DefaultFeature {
private final Block block;
public SingleBlockFeature(Block block) {
this.block = block;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -28,14 +28,14 @@ public class SingleBlockFeature extends DefaultFeature {
if (!world.getBlockState(pos.below()).is(TagAPI.GEN_TERRAIN)) {
return false;
}
BlockState state = block.defaultBlockState();
if (block.getStateDefinition().getProperty("waterlogged") != null) {
boolean waterlogged = !world.getFluidState(pos).isEmpty();
state = state.setValue(BlockStateProperties.WATERLOGGED, waterlogged);
}
BlocksHelper.setWithoutUpdate(world, pos, state);
return true;
}
}

View file

@ -24,16 +24,14 @@ public class SmaragdantCrystalFeature extends DefaultFeature {
if (!world.getBlockState(pos.below()).is(TagAPI.GEN_TERRAIN)) {
return false;
}
MutableBlockPos mut = new MutableBlockPos();
int count = MHelper.randRange(15, 30, random);
BlockState crystal = EndBlocks.SMARAGDANT_CRYSTAL.defaultBlockState();
BlockState shard = EndBlocks.SMARAGDANT_CRYSTAL_SHARD.defaultBlockState();
for (int i = 0; i < count; i++) {
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5,
MHelper.floor(random.nextGaussian() * 2 + 0.5));
int dist = MHelper.floor(1.5F - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ()))
+ random.nextInt(3);
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, MHelper.floor(random.nextGaussian() * 2 + 0.5));
int dist = MHelper.floor(1.5F - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(3);
if (dist > 0) {
BlockState state = world.getBlockState(mut);
for (int n = 0; n < 10 && state.isAir(); n++) {
@ -46,12 +44,11 @@ public class SmaragdantCrystalFeature extends DefaultFeature {
mut.setY(mut.getY() + 1);
}
boolean waterlogged = !world.getFluidState(mut).isEmpty();
BlocksHelper.setWithoutUpdate(world, mut,
shard.setValue(BlockStateProperties.WATERLOGGED, waterlogged));
BlocksHelper.setWithoutUpdate(world, mut, shard.setValue(BlockStateProperties.WATERLOGGED, waterlogged));
}
}
}
return true;
}
}

View file

@ -30,7 +30,7 @@ import java.util.function.Function;
public class SpireFeature extends DefaultFeature {
protected static final Function<BlockState, Boolean> REPLACE;
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -38,11 +38,10 @@ public class SpireFeature extends DefaultFeature {
final WorldGenLevel world = featureConfig.level();
final ChunkGenerator chunkGenerator = featureConfig.chunkGenerator();
pos = getPosOnSurfaceWG(world, pos);
if (pos.getY() < 10 || !world.getBlockState(pos.below(3)).is(TagAPI.GEN_TERRAIN)
|| !world.getBlockState(pos.below(6)).is(TagAPI.GEN_TERRAIN)) {
if (pos.getY() < 10 || !world.getBlockState(pos.below(3)).is(TagAPI.GEN_TERRAIN) || !world.getBlockState(pos.below(6)).is(TagAPI.GEN_TERRAIN)) {
return false;
}
SDF sdf = new SDFSphere().setRadius(MHelper.randRange(2, 3, random)).setBlock(Blocks.END_STONE);
int count = MHelper.randRange(3, 7, random);
for (int i = 0; i < count; i++) {
@ -51,8 +50,7 @@ public class SpireFeature extends DefaultFeature {
}
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
sdf = new SDFDisplacement().setFunction((vec) -> {
return (float) (Math.abs(noise.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1)) * 3F
+ Math.abs(noise.eval(vec.x() * 0.3, vec.y() * 0.3 + 100, vec.z() * 0.3)) * 1.3F);
return (float) (Math.abs(noise.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1)) * 3F + Math.abs(noise.eval(vec.x() * 0.3, vec.y() * 0.3 + 100, vec.z() * 0.3)) * 1.3F);
}).setSource(sdf);
final BlockPos center = pos;
List<BlockPos> support = Lists.newArrayList();
@ -64,28 +62,26 @@ public class SpireFeature extends DefaultFeature {
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
}
else if (info.getState(Direction.UP, 3).isAir()) {
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig()
.getUnderMaterial();
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getUnderMaterial();
}
return info.getState();
}).fillRecursive(world, center);
support.forEach((bpos) -> {
if (BiomeAPI.getFromBiome(world.getBiome(bpos)) == EndBiomes.BLOSSOMING_SPIRES) {
EndFeatures.TENANEA_BUSH.getFeature().place(new FeaturePlaceContext<>(world, chunkGenerator, random, bpos, null));
}
});
return true;
}
protected SDF addSegment(SDF sdf, float radius, Random random) {
SDF sphere = new SDFSphere().setRadius(radius).setBlock(Blocks.END_STONE);
SDF offseted = new SDFTranslate().setTranslate(0, radius + random.nextFloat() * 0.25F * radius, 0)
.setSource(sdf);
SDF offseted = new SDFTranslate().setTranslate(0, radius + random.nextFloat() * 0.25F * radius, 0).setSource(sdf);
return new SDFSmoothUnion().setRadius(radius * 0.5F).setSourceA(sphere).setSourceB(offseted);
}
static {
REPLACE = (state) -> {
if (state.is(TagAPI.END_GROUND)) {

View file

@ -20,13 +20,13 @@ 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 place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -35,12 +35,12 @@ public class StalactiteFeature extends DefaultFeature {
if (!isGround(world.getBlockState(ceiling ? pos.above() : pos.below()).getBlock())) {
return false;
}
MutableBlockPos mut = new MutableBlockPos().set(pos);
int height = random.nextInt(16);
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);
@ -50,26 +50,24 @@ public class StalactiteFeature extends DefaultFeature {
break;
}
}
if (!stalagnate && height > 7) {
height = random.nextInt(8);
}
float center = height * 0.5F;
for (int i = 0; i < height; i++) {
mut.setY(pos.getY() + i * dir);
int size = stalagnate ? Mth.clamp((int) (Mth.abs(i - center) + 1), 1, 7) : height - i - 1;
boolean waterlogged = !world.getFluidState(mut).isEmpty();
BlockState base = block.defaultBlockState().setValue(StalactiteBlock.SIZE, size)
.setValue(BlockStateProperties.WATERLOGGED, waterlogged);
BlockState state = stalagnate ? base.setValue(StalactiteBlock.IS_FLOOR, dir > 0 ? i < center : i > center)
: base.setValue(StalactiteBlock.IS_FLOOR, dir > 0);
BlockState base = block.defaultBlockState().setValue(StalactiteBlock.SIZE, size).setValue(BlockStateProperties.WATERLOGGED, waterlogged);
BlockState state = stalagnate ? base.setValue(StalactiteBlock.IS_FLOOR, dir > 0 ? i < center : i > center) : base.setValue(StalactiteBlock.IS_FLOOR, dir > 0);
BlocksHelper.setWithoutUpdate(world, mut, state);
}
return true;
}
private boolean isGround(Block block) {
for (Block b : ground) {
if (b == block) {

View file

@ -27,7 +27,7 @@ public class SulphurHillFeature extends DefaultFeature {
if (pos.getY() < 57 || pos.getY() > 70) {
return false;
}
int count = MHelper.randRange(5, 13, random);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
for (int i = 0; i < count; i++) {
@ -41,7 +41,7 @@ public class SulphurHillFeature extends DefaultFeature {
}
return true;
}
private void makeCircle(WorldGenLevel world, BlockPos pos, OpenSimplexNoise noise, Random random) {
int radius = MHelper.randRange(5, 9, random);
int min = -radius - 3;

View file

@ -29,20 +29,20 @@ public class SulphuricCaveFeature extends DefaultFeature {
private static final BlockState CAVE_AIR = Blocks.CAVE_AIR.defaultBlockState();
private static final BlockState WATER = Blocks.WATER.defaultBlockState();
private static final Direction[] HORIZONTAL = BlocksHelper.makeHorizontal();
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
int radius = MHelper.randRange(10, 30, random);
int top = world.getHeight(Heightmap.Types.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
MutableBlockPos bpos = new MutableBlockPos();
bpos.setX(pos.getX());
bpos.setZ(pos.getZ());
bpos.setY(top - 1);
BlockState state = world.getBlockState(bpos);
while (!state.is(TagAPI.GEN_TERRAIN) && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
@ -52,32 +52,32 @@ public class SulphuricCaveFeature extends DefaultFeature {
return false;
}
top = (int) (bpos.getY() - (radius * 1.3F + 5));
while (state.is(TagAPI.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
int bottom = (int) (bpos.getY() + radius * 1.3F + 5);
if (top <= bottom) {
return false;
}
MutableBlockPos mut = new MutableBlockPos();
pos = new BlockPos(pos.getX(), MHelper.randRange(bottom, top, random), pos.getZ());
OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, pos.getX(), pos.getZ()));
int x1 = pos.getX() - radius - 5;
int z1 = pos.getZ() - radius - 5;
int x2 = pos.getX() + radius + 5;
int z2 = pos.getZ() + radius + 5;
int y1 = MHelper.floor(pos.getY() - (radius + 5) / 1.6);
int y2 = MHelper.floor(pos.getY() + (radius + 5) / 1.6);
double hr = radius * 0.75;
double nr = radius * 0.25;
Set<BlockPos> brimstone = Sets.newHashSet();
BlockState rock = EndBlocks.SULPHURIC_ROCK.stone.defaultBlockState();
int waterLevel = pos.getY() + MHelper.randRange(MHelper.floor(radius * 0.8), radius, random);
@ -106,8 +106,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
else if (dist < r2 * r2) {
state = world.getBlockState(mut);
if (state.is(TagAPI.GEN_TERRAIN) || state.is(Blocks.AIR)) {
double v = noise.eval(x * 0.1, y * 0.1, z * 0.1)
+ noise.eval(x * 0.03, y * 0.03, z * 0.03) * 0.5;
double v = noise.eval(x * 0.1, y * 0.1, z * 0.1) + noise.eval(x * 0.03, y * 0.03, z * 0.03) * 0.5;
if (v > 0.4) {
brimstone.add(mut.immutable());
}
@ -122,30 +121,26 @@ public class SulphuricCaveFeature extends DefaultFeature {
brimstone.forEach((blockPos) -> {
placeBrimstone(world, blockPos, random);
});
if (random.nextInt(4) == 0) {
int count = MHelper.randRange(5, 20, random);
for (int i = 0; i < count; i++) {
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 0,
MHelper.floor(random.nextGaussian() * 2 + 0.5));
int dist = MHelper.floor(3 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ()))
+ random.nextInt(2);
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 0, MHelper.floor(random.nextGaussian() * 2 + 0.5));
int dist = MHelper.floor(3 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(2);
if (dist > 0) {
state = world.getBlockState(mut);
while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.WATER_PLANT)) {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.is(TagAPI.GEN_TERRAIN)
&& !world.getBlockState(mut.above()).is(EndBlocks.HYDROTHERMAL_VENT)) {
if (state.is(TagAPI.GEN_TERRAIN) && !world.getBlockState(mut.above()).is(EndBlocks.HYDROTHERMAL_VENT)) {
for (int j = 0; j <= dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
MHelper.shuffle(HORIZONTAL, random);
for (Direction dir : HORIZONTAL) {
BlockPos p = mut.relative(dir);
if (random.nextBoolean() && world.getBlockState(p).is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState()
.setValue(HorizontalDirectionalBlock.FACING, dir));
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, dir));
}
}
mut.setY(mut.getY() + 1);
@ -155,8 +150,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
state = world.getBlockState(mut);
while (state.is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.defaultBlockState());
world.getBlockTicks().scheduleTick(mut, EndBlocks.VENT_BUBBLE_COLUMN,
MHelper.randRange(8, 32, random));
world.getBlockTicks().scheduleTick(mut, EndBlocks.VENT_BUBBLE_COLUMN, MHelper.randRange(8, 32, random));
mut.setY(mut.getY() + 1);
state = world.getBlockState(mut);
}
@ -164,19 +158,16 @@ public class SulphuricCaveFeature extends DefaultFeature {
}
}
}
BlockFixer.fixBlocks(world, new BlockPos(x1, y1, z1), new BlockPos(x2, y2, z2));
return true;
}
private boolean isReplaceable(BlockState state) {
return state.is(TagAPI.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT)
|| state.is(EndBlocks.VENT_BUBBLE_COLUMN) || state.is(EndBlocks.SULPHUR_CRYSTAL)
|| state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().equals(Material.WATER_PLANT) || state.getMaterial().equals(Material.LEAVES);
return state.is(TagAPI.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT) || state.is(EndBlocks.VENT_BUBBLE_COLUMN) || state.is(EndBlocks.SULPHUR_CRYSTAL) || state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.WATER_PLANT) || state.getMaterial().equals(Material.LEAVES);
}
private void placeBrimstone(WorldGenLevel world, BlockPos pos, Random random) {
BlockState state = getBrimstone(world, pos);
BlocksHelper.setWithoutUpdate(world, pos, state);
@ -184,7 +175,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
makeShards(world, pos, random);
}
}
private BlockState getBrimstone(WorldGenLevel world, BlockPos pos) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (world.getBlockState(pos.relative(dir)).is(Blocks.WATER)) {
@ -193,14 +184,12 @@ public class SulphuricCaveFeature extends DefaultFeature {
}
return EndBlocks.BRIMSTONE.defaultBlockState();
}
private void makeShards(WorldGenLevel world, BlockPos pos, Random random) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
BlockPos side;
if (random.nextInt(16) == 0 && world.getBlockState((side = pos.relative(dir))).is(Blocks.WATER)) {
BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState()
.setValue(SulphurCrystalBlock.WATERLOGGED, true).setValue(SulphurCrystalBlock.FACING, dir)
.setValue(SulphurCrystalBlock.AGE, random.nextInt(3));
BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState().setValue(SulphurCrystalBlock.WATERLOGGED, true).setValue(SulphurCrystalBlock.FACING, dir).setValue(SulphurCrystalBlock.AGE, random.nextInt(3));
BlocksHelper.setWithoutUpdate(world, side, state);
}
}

View file

@ -25,26 +25,26 @@ import java.util.Set;
public class SulphuricLakeFeature extends DefaultFeature {
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(15152);
private static final MutableBlockPos POS = new MutableBlockPos();
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
BlockPos blockPos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
blockPos = getPosOnSurfaceWG(world, blockPos);
if (blockPos.getY() < 57) {
return false;
}
double radius = MHelper.randRange(10.0, 20.0, random);
int dist2 = MHelper.floor(radius * 1.5);
int minX = blockPos.getX() - dist2;
int maxX = blockPos.getX() + dist2;
int minZ = blockPos.getZ() - dist2;
int maxZ = blockPos.getZ() + dist2;
Set<BlockPos> brimstone = Sets.newHashSet();
for (int x = minX; x <= maxX; x++) {
POS.setX(x);
@ -135,14 +135,14 @@ public class SulphuricLakeFeature extends DefaultFeature {
}
}
}
brimstone.forEach((bpos) -> {
placeBrimstone(world, bpos, random);
});
return true;
}
private boolean isBorder(WorldGenLevel world, BlockPos pos) {
int y = pos.getY() + 1;
for (Direction dir : BlocksHelper.DIRECTIONS) {
@ -152,7 +152,7 @@ public class SulphuricLakeFeature extends DefaultFeature {
}
return false;
}
private boolean isAbsoluteBorder(WorldGenLevel world, BlockPos pos) {
int y = pos.getY() - 2;
for (Direction dir : BlocksHelper.DIRECTIONS) {
@ -162,19 +162,17 @@ public class SulphuricLakeFeature extends DefaultFeature {
}
return false;
}
private boolean isDeepWater(WorldGenLevel world, BlockPos pos) {
int y = pos.getY() + 1;
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (getYOnSurface(world, pos.getX() + dir.getStepX(), pos.getZ() + dir.getStepZ()) < y
|| getYOnSurface(world, pos.getX() + dir.getStepX() * 2, pos.getZ() + dir.getStepZ() * 2) < y
|| getYOnSurface(world, pos.getX() + dir.getStepX() * 3, pos.getZ() + dir.getStepZ() * 3) < y) {
if (getYOnSurface(world, pos.getX() + dir.getStepX(), pos.getZ() + dir.getStepZ()) < y || getYOnSurface(world, pos.getX() + dir.getStepX() * 2, pos.getZ() + dir.getStepZ() * 2) < y || getYOnSurface(world, pos.getX() + dir.getStepX() * 3, pos.getZ() + dir.getStepZ() * 3) < y) {
return false;
}
}
return true;
}
private void placeBrimstone(WorldGenLevel world, BlockPos pos, Random random) {
BlockState state = getBrimstone(world, pos);
BlocksHelper.setWithoutUpdate(world, pos, state);
@ -182,7 +180,7 @@ public class SulphuricLakeFeature extends DefaultFeature {
makeShards(world, pos, random);
}
}
private BlockState getBrimstone(WorldGenLevel world, BlockPos pos) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (world.getBlockState(pos.relative(dir)).is(Blocks.WATER)) {
@ -191,14 +189,12 @@ public class SulphuricLakeFeature extends DefaultFeature {
}
return EndBlocks.BRIMSTONE.defaultBlockState();
}
private void makeShards(WorldGenLevel world, BlockPos pos, Random random) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
BlockPos side;
if (random.nextInt(16) == 0 && world.getBlockState((side = pos.relative(dir))).is(Blocks.WATER)) {
BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState()
.setValue(SulphurCrystalBlock.WATERLOGGED, true).setValue(SulphurCrystalBlock.FACING, dir)
.setValue(SulphurCrystalBlock.AGE, random.nextInt(3));
BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState().setValue(SulphurCrystalBlock.WATERLOGGED, true).setValue(SulphurCrystalBlock.FACING, dir).setValue(SulphurCrystalBlock.AGE, random.nextInt(3));
BlocksHelper.setWithoutUpdate(world, side, state);
}
}

View file

@ -21,12 +21,11 @@ public class SurfaceVentFeature extends DefaultFeature {
final Random random = featureConfig.random();
BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
pos = getPosOnSurface(world,
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
if (!world.getBlockState(pos.below(3)).is(TagAPI.GEN_TERRAIN)) {
return false;
}
MutableBlockPos mut = new MutableBlockPos();
int count = MHelper.randRange(15, 30, random);
BlockState vent = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.WATERLOGGED, false);
@ -39,8 +38,7 @@ public class SurfaceVentFeature extends DefaultFeature {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.is(TagAPI.GEN_TERRAIN)
&& !world.getBlockState(mut.above()).is(EndBlocks.HYDROTHERMAL_VENT)) {
if (state.is(TagAPI.GEN_TERRAIN) && !world.getBlockState(mut.above()).is(EndBlocks.HYDROTHERMAL_VENT)) {
for (int j = 0; j <= dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
mut.setY(mut.getY() + 1);
@ -49,7 +47,7 @@ public class SurfaceVentFeature extends DefaultFeature {
}
}
}
return true;
}
}

View file

@ -22,11 +22,11 @@ import java.util.function.Supplier;
public class CaveChunkPopulatorFeature extends DefaultFeature {
private Supplier<EndCaveBiome> supplier;
public CaveChunkPopulatorFeature(Supplier<EndCaveBiome> biome) {
this.supplier = biome;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -46,9 +46,8 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
BlockFixer.fixBlocks(world, min, max);
return true;
}
protected void fillSets(int sx, int sz, ChunkAccess chunk, Set<BlockPos> floorPositions,
Set<BlockPos> ceilPositions, MutableBlockPos min, MutableBlockPos max) {
protected void fillSets(int sx, int sz, ChunkAccess chunk, Set<BlockPos> floorPositions, Set<BlockPos> ceilPositions, MutableBlockPos min, MutableBlockPos max) {
MutableBlockPos mut = new MutableBlockPos();
MutableBlockPos mut2 = new MutableBlockPos();
MutableBlockPos mut3 = new MutableBlockPos();
@ -80,7 +79,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
}
}
}
private void updateMin(BlockPos pos, MutableBlockPos min) {
if (pos.getX() < min.getX()) {
min.setX(pos.getX());
@ -92,7 +91,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
min.setZ(pos.getZ());
}
}
private void updateMax(BlockPos pos, MutableBlockPos max) {
if (pos.getX() > max.getX()) {
max.setX(pos.getX());
@ -104,9 +103,8 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
max.setZ(pos.getZ());
}
}
protected void placeFloor(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random,
BlockState surfaceBlock) {
protected void placeFloor(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random, BlockState surfaceBlock) {
float density = biome.getFloorDensity();
floorPositions.forEach((pos) -> {
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
@ -118,7 +116,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
}
});
}
protected void placeCeil(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> ceilPositions, Random random) {
float density = biome.getCeilDensity();
ceilPositions.forEach((pos) -> {

View file

@ -34,7 +34,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
protected static final BlockState END_STONE = Blocks.END_STONE.defaultBlockState();
protected static final BlockState WATER = Blocks.WATER.defaultBlockState();
private static final Vec3i[] SPHERE;
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -43,18 +43,18 @@ public abstract class EndCaveFeature extends DefaultFeature {
if (pos.getX() * pos.getX() + pos.getZ() * pos.getZ() <= 2500) {
return false;
}
if (biomeMissingCaves(world, pos)) {
return false;
}
int radius = MHelper.randRange(10, 30, random);
BlockPos center = findPos(world, pos, radius, random);
if (center == null) {
return false;
}
EndCaveBiome biome = EndBiomes.getCaveBiome(pos.getX(), pos.getZ());
Set<BlockPos> caveBlocks = generate(world, center, radius, random);
if (!caveBlocks.isEmpty()) {
@ -81,12 +81,12 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
fixBlocks(world, caveBlocks);
}
return true;
}
protected abstract Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random);
protected void placeFloor(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random, BlockState surfaceBlock) {
float density = biome.getFloorDensity();
floorPositions.forEach((pos) -> {
@ -101,7 +101,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
});
}
protected void placeCeil(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> ceilPositions, Random random) {
float density = biome.getCeilDensity();
ceilPositions.forEach((pos) -> {
@ -117,7 +117,7 @@ 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 -> {
@ -136,7 +136,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
});
}
private boolean hasOpenSide(BlockPos pos, Set<BlockPos> positions) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (!positions.contains(pos.relative(dir))) {
@ -145,11 +145,11 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
return false;
}
protected void setBiomes(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> blocks) {
blocks.forEach((pos) -> setBiome(world, pos, biome));
}
protected void setBiome(WorldGenLevel world, BlockPos pos, EndCaveBiome biome) {
IBiomeArray array = (IBiomeArray) world.getChunk(pos).getBiomes();
if (array != null) {
@ -157,14 +157,14 @@ public abstract class EndCaveFeature extends DefaultFeature {
array.be_setBiome(bio, pos);
}
}
private BlockPos findPos(WorldGenLevel world, BlockPos pos, int radius, Random random) {
int top = world.getHeight(Heightmap.Types.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
MutableBlockPos bpos = new MutableBlockPos();
bpos.setX(pos.getX());
bpos.setZ(pos.getZ());
bpos.setY(top - 1);
BlockState state = world.getBlockState(bpos);
while (!state.is(TagAPI.GEN_TERRAIN) && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
@ -174,20 +174,20 @@ public abstract class EndCaveFeature extends DefaultFeature {
return null;
}
top = (int) (bpos.getY() - (radius * 1.3F + 5));
while (state.is(TagAPI.GEN_TERRAIN) || !state.getFluidState().isEmpty() && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
int bottom = (int) (bpos.getY() + radius * 1.3F + 5);
if (top <= bottom) {
return null;
}
return new BlockPos(pos.getX(), MHelper.randRange(bottom, top, random), pos.getZ());
}
protected void fixBlocks(WorldGenLevel world, Set<BlockPos> caveBlocks) {
BlockPos pos = caveBlocks.iterator().next();
MutableBlockPos start = new MutableBlockPos().set(pos);
@ -199,14 +199,14 @@ public abstract class EndCaveFeature extends DefaultFeature {
if (bpos.getX() > end.getX()) {
end.setX(bpos.getX());
}
if (bpos.getY() < start.getY()) {
start.setY(bpos.getY());
}
if (bpos.getY() > end.getY()) {
end.setY(bpos.getY());
}
if (bpos.getZ() < start.getZ()) {
start.setZ(bpos.getZ());
}
@ -216,7 +216,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
});
BlockFixer.fixBlocks(world, start.offset(-2, -2, -2), end.offset(2, 2, 2));
}
protected boolean isWaterNear(WorldGenLevel world, BlockPos pos) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (!world.getFluidState(pos.relative(dir, 5)).isEmpty()) {
@ -225,7 +225,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
return false;
}
protected boolean biomeMissingCaves(WorldGenLevel world, BlockPos pos) {
for (int x = -2; x < 3; x++) {
for (int z = -2; z < 3; z++) {
@ -239,7 +239,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
return false;
}
static {
List<Vec3i> prePos = Lists.newArrayList();
int radius = 5;

View file

@ -19,17 +19,17 @@ public class RoundCaveFeature extends EndCaveFeature {
@Override
protected Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random) {
OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
int x1 = center.getX() - radius - 5;
int z1 = center.getZ() - radius - 5;
int x2 = center.getX() + radius + 5;
int z2 = center.getZ() + radius + 5;
int y1 = MHelper.floor(center.getY() - (radius + 5) / 1.6);
int y2 = MHelper.floor(center.getY() + (radius + 5) / 1.6);
double hr = radius * 0.75;
double nr = radius * 0.25;
int dx = x2 - x1 + 1;
int dz = z2 - z1 + 1;
int count = dx * dz;
@ -53,12 +53,12 @@ public class RoundCaveFeature extends EndCaveFeature {
state = world.getBlockState(bpos);
if (isReplaceable(state) && !isWaterNear(world, bpos)) {
blocks.add(bpos.immutable());
while (state.getMaterial().equals(Material.LEAVES)) {
bpos.setY(bpos.getY() + 1);
state = world.getBlockState(bpos);
}
bpos.setY(y - 1);
while (state.getMaterial().equals(Material.LEAVES)) {
bpos.setY(bpos.getY() - 1);
@ -69,14 +69,11 @@ public class RoundCaveFeature extends EndCaveFeature {
}
});
blocks.forEach(bpos -> BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR));
return blocks;
}
private boolean isReplaceable(BlockState state) {
return state.is(TagAPI.GEN_TERRAIN)
|| state.getMaterial().isReplaceable()
|| state.getMaterial().equals(Material.PLANT)
|| state.getMaterial().equals(Material.LEAVES);
return state.is(TagAPI.GEN_TERRAIN) || state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.LEAVES);
}
}

View file

@ -35,24 +35,24 @@ public class TunelCaveFeature extends EndCaveFeature {
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 z2 = z1 + 16;
Random rand = new Random(world.getSeed());
OpenSimplexNoise noiseH = new OpenSimplexNoise(rand.nextInt());
OpenSimplexNoise noiseV = new OpenSimplexNoise(rand.nextInt());
OpenSimplexNoise noiseD = new OpenSimplexNoise(rand.nextInt());
Set<BlockPos> positions = Sets.newConcurrentHashSet();
float a = hasCaves(world, new BlockPos(x1, 0, z1)) ? 1F : 0F;
float b = hasCaves(world, new BlockPos(x2, 0, z1)) ? 1F : 0F;
float c = hasCaves(world, new BlockPos(x1, 0, z2)) ? 1F : 0F;
float d = hasCaves(world, new BlockPos(x2, 0, z2)) ? 1F : 0F;
ChunkAccess chunk = world.getChunk(cx, cz);
IntStream.range(0, 256).parallel().forEach(index -> {
MutableBlockPos pos = new MutableBlockPos();
@ -84,10 +84,10 @@ public class TunelCaveFeature extends EndCaveFeature {
}
});
positions.forEach(bpos -> BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR));
return positions;
}
private boolean noWaterNear(WorldGenLevel world, BlockPos pos) {
BlockPos above1 = pos.above();
BlockPos above2 = pos.above(2);
@ -104,7 +104,7 @@ public class TunelCaveFeature extends EndCaveFeature {
}
return true;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -113,16 +113,16 @@ public class TunelCaveFeature extends EndCaveFeature {
if (pos.getX() * pos.getX() + pos.getZ() * pos.getZ() <= 2500) {
return false;
}
if (biomeMissingCaves(world, pos)) {
return false;
}
Set<BlockPos> caveBlocks = generate(world, pos, random);
if (caveBlocks.isEmpty()) {
return false;
}
Map<EndCaveBiome, Set<BlockPos>> floorSets = Maps.newHashMap();
Map<EndCaveBiome, Set<BlockPos>> ceilSets = Maps.newHashMap();
MutableBlockPos mut = new MutableBlockPos();
@ -157,11 +157,11 @@ public class TunelCaveFeature extends EndCaveFeature {
}
});
caveBlocks.removeAll(remove);
if (caveBlocks.isEmpty()) {
return true;
}
floorSets.forEach((biome, floorPositions) -> {
BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
placeFloor(world, biome, floorPositions, random, surfaceBlock);
@ -172,15 +172,15 @@ public class TunelCaveFeature extends EndCaveFeature {
EndCaveBiome biome = EndBiomes.getCaveBiome(pos.getX(), pos.getZ());
placeWalls(world, biome, caveBlocks, random);
fixBlocks(world, caveBlocks);
return true;
}
@Override
protected Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random) {
return null;
}
@Override
protected void placeFloor(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random, BlockState surfaceBlock) {
float density = biome.getFloorDensity() * 0.2F;
@ -196,7 +196,7 @@ public class TunelCaveFeature extends EndCaveFeature {
}
});
}
@Override
protected void placeCeil(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> ceilPositions, Random random) {
float density = biome.getCeilDensity() * 0.2F;
@ -213,14 +213,11 @@ public class TunelCaveFeature extends EndCaveFeature {
}
});
}
protected boolean hasCaves(WorldGenLevel world, BlockPos pos) {
return hasCavesInBiome(world, pos.offset(-8, 0, -8)) &&
hasCavesInBiome(world, pos.offset(8, 0, -8)) &&
hasCavesInBiome(world, pos.offset(-8, 0, 8)) &&
hasCavesInBiome(world, pos.offset(8, 0, 8));
return hasCavesInBiome(world, pos.offset(-8, 0, -8)) && hasCavesInBiome(world, pos.offset(8, 0, -8)) && hasCavesInBiome(world, pos.offset(-8, 0, 8)) && hasCavesInBiome(world, pos.offset(8, 0, 8));
}
protected boolean hasCavesInBiome(WorldGenLevel world, BlockPos pos) {
Biome biome = world.getBiome(pos);
BCLBiome endBiome = BiomeAPI.getFromBiome(biome);

View file

@ -39,61 +39,60 @@ public class DragonTreeFeature extends DefaultFeature {
private static final List<Vector3f> SIDE1;
private static final List<Vector3f> SIDE2;
private static final List<Vector3f> ROOT;
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND))
return false;
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) return false;
float size = MHelper.randRange(10, 25, random);
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 6);
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);
if (!SplineHelper.canGenerate(spline, pos, world, REPLACE)) {
return false;
}
BlocksHelper.setWithoutUpdate(world, pos, AIR);
Vector3f last = SplineHelper.getPos(spline, 3.5F);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
float radius = size * MHelper.randRange(0.5F, 0.7F, random);
makeCap(world, pos.offset(last.x(), last.y(), last.z()), radius, random, noise);
last = spline.get(0);
makeRoots(world, pos.offset(last.x(), last.y(), last.z()), radius, random);
radius = MHelper.randRange(1.2F, 2.3F, random);
SDF function = SplineHelper.buildSDF(spline, radius, 1.2F, (bpos) -> {
return EndBlocks.DRAGON_TREE.bark.defaultBlockState();
});
function.setReplaceFunction(REPLACE);
function.addPostProcess(POST);
function.fillRecursiveIgnore(world, pos, IGNORE);
return true;
}
private void makeCap(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
int count = (int) radius;
int offset = (int) (BRANCH.get(BRANCH.size() - 1).y() * radius);
for (int i = 0; i < count; i++) {
float angle = (float) i / (float) count * MHelper.PI2;
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
List<Vector3f> branch = SplineHelper.copySpline(BRANCH);
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE);
branch = SplineHelper.copySpline(SIDE1);
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
SplineHelper.fillSpline(branch, world, EndBlocks.DRAGON_TREE.bark.defaultBlockState(), pos, REPLACE);
branch = SplineHelper.copySpline(SIDE2);
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
@ -101,13 +100,13 @@ public class DragonTreeFeature extends DefaultFeature {
}
leavesBall(world, pos.above(offset), radius * 1.15F + 2, random, noise);
}
private void makeRoots(WorldGenLevel world, BlockPos pos, float radius, Random random) {
int count = (int) (radius * 1.5F);
for (int i = 0; i < count; i++) {
float angle = (float) i / (float) count * MHelper.PI2;
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
List<Vector3f> branch = SplineHelper.copySpline(ROOT);
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
@ -117,10 +116,9 @@ public class DragonTreeFeature extends DefaultFeature {
}
}
}
private void leavesBall(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.DRAGON_TREE_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.DRAGON_TREE_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
SDF sub = new SDFScale().setScale(5).setSource(sphere);
sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub);
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
@ -167,12 +165,11 @@ public class DragonTreeFeature extends DefaultFeature {
return info.getState();
});
sphere.fillRecursiveIgnore(world, pos, IGNORE);
if (radius > 5) {
int count = (int) (radius * 2.5F);
for (int i = 0; i < count; i++) {
BlockPos p = pos.offset(random.nextGaussian() * 1, random.nextGaussian() * 1,
random.nextGaussian() * 1);
BlockPos p = pos.offset(random.nextGaussian() * 1, random.nextGaussian() * 1, random.nextGaussian() * 1);
boolean place = true;
for (Direction d : Direction.values()) {
BlockState state = world.getBlockState(p.relative(d));
@ -186,10 +183,10 @@ public class DragonTreeFeature extends DefaultFeature {
}
}
}
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.DRAGON_TREE.bark);
}
static {
REPLACE = (state) -> {
if (state.is(TagAPI.END_GROUND)) {
@ -203,36 +200,33 @@ public class DragonTreeFeature extends DefaultFeature {
}
return state.getMaterial().isReplaceable();
};
IGNORE = (state) -> {
return EndBlocks.DRAGON_TREE.isTreeLog(state);
};
POST = (info) -> {
if (EndBlocks.DRAGON_TREE.isTreeLog(info.getStateUp())
&& EndBlocks.DRAGON_TREE.isTreeLog(info.getStateDown())) {
if (EndBlocks.DRAGON_TREE.isTreeLog(info.getStateUp()) && EndBlocks.DRAGON_TREE.isTreeLog(info.getStateDown())) {
return EndBlocks.DRAGON_TREE.log.defaultBlockState();
}
return info.getState();
};
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), new Vector3f(0.1F, 0.3F, 0), new Vector3f(0.4F, 0.6F, 0),
new Vector3f(0.8F, 0.8F, 0), new Vector3f(1, 1, 0));
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), new Vector3f(0.1F, 0.3F, 0), new Vector3f(0.4F, 0.6F, 0), new Vector3f(0.8F, 0.8F, 0), new Vector3f(1, 1, 0));
SIDE1 = Lists.newArrayList(new Vector3f(0.4F, 0.6F, 0), new Vector3f(0.8F, 0.8F, 0), new Vector3f(1, 1, 0));
SIDE2 = SplineHelper.copySpline(SIDE1);
Vector3f offset1 = new Vector3f(-0.4F, -0.6F, 0);
Vector3f offset2 = new Vector3f(0.4F, 0.6F, 0);
SplineHelper.offset(SIDE1, offset1);
SplineHelper.offset(SIDE2, offset1);
SplineHelper.rotateSpline(SIDE1, 0.5F);
SplineHelper.rotateSpline(SIDE2, -0.5F);
SplineHelper.offset(SIDE1, offset2);
SplineHelper.offset(SIDE2, offset2);
ROOT = Lists.newArrayList(new Vector3f(0F, 1F, 0), new Vector3f(0.1F, 0.7F, 0), new Vector3f(0.3F, 0.3F, 0),
new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.2F, 0));
ROOT = Lists.newArrayList(new Vector3f(0F, 1F, 0), new Vector3f(0.1F, 0.7F, 0), new Vector3f(0.3F, 0.3F, 0), new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.2F, 0));
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
}
}

View file

@ -30,43 +30,42 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private static final Function<BlockState, Boolean> IGNORE;
private static final Function<PosInfo, BlockState> POST;
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND))
return false;
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) return false;
float size = MHelper.randRange(5, 10, random);
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 5);
SplineHelper.offsetParts(spline, random, 0.7F, 0, 0.7F);
if (!SplineHelper.canGenerate(spline, pos, world, REPLACE)) {
return false;
}
BlocksHelper.setWithoutUpdate(world, pos, AIR);
float radius = size * 0.17F;// MHelper.randRange(0.8F, 1.2F, random);
SDF function = SplineHelper.buildSDF(spline, radius, 0.2F, (bpos) -> EndBlocks.AMARANITA_STEM.defaultBlockState());
Vector3f capPos = spline.get(spline.size() - 1);
makeHead(world, pos.offset(capPos.x() + 0.5F, capPos.y() + 1.5F, capPos.z() + 0.5F), Mth.floor(size / 1.6F));
function.setReplaceFunction(REPLACE);
function.addPostProcess(POST);
function.fillRecursiveIgnore(world, pos, IGNORE);
for (int i = 0; i < 3; i++) {
List<Vector3f> copy = SplineHelper.copySpline(spline);
SplineHelper.offsetParts(copy, random, 0.2F, 0, 0.2F);
SplineHelper.fillSplineForce(copy, world, EndBlocks.AMARANITA_HYPHAE.defaultBlockState(), pos, REPLACE);
}
return true;
}
private void makeHead(WorldGenLevel world, BlockPos pos, int radius) {
MutableBlockPos mut = new MutableBlockPos();
if (radius < 2) {
@ -97,13 +96,12 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_LANTERN);
mut.move(Direction.DOWN);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState()
.setValue(BaseAttachedBlock.FACING, Direction.DOWN));
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState().setValue(BaseAttachedBlock.FACING, Direction.DOWN));
}
}
}
}
int h = radius + 1;
for (int y = 0; y < h; y++) {
mut.setY(pos.getY() + y + 1);
@ -117,7 +115,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
}
}
}
mut.setY(pos.getY() + h + 1);
for (int x = -1; x < 2; x++) {
mut.setX(pos.getX() + x);
@ -161,21 +159,18 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
int distance = axis == Axis.X ? x < 0 ? -1 : 1 : z < 0 ? -1 : 1;
BlockPos offseted = mut.relative(axis, distance);
if (world.getBlockState(offseted).getMaterial().isReplaceable()) {
Direction dir = Direction.fromAxisAndDirection(axis,
distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
BlocksHelper.setWithoutUpdate(world, offseted, EndBlocks.AMARANITA_FUR
.defaultBlockState().setValue(BaseAttachedBlock.FACING, dir));
Direction dir = Direction.fromAxisAndDirection(axis, distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
BlocksHelper.setWithoutUpdate(world, offseted, EndBlocks.AMARANITA_FUR.defaultBlockState().setValue(BaseAttachedBlock.FACING, dir));
}
mut.move(Direction.DOWN);
}
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState()
.setValue(BaseAttachedBlock.FACING, Direction.DOWN));
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState().setValue(BaseAttachedBlock.FACING, Direction.DOWN));
}
}
}
}
int h = radius - 1;
for (int y = 0; y < h; y++) {
mut.setY(pos.getY() + y + 1);
@ -189,7 +184,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
}
}
}
mut.setY(pos.getY() + h + 1);
for (int x = -1; x < 3; x++) {
mut.setX(pos.getX() + x);
@ -215,7 +210,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.set(pos).move(Direction.SOUTH, 3).move(Direction.EAST, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
@ -228,7 +223,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.set(pos).move(Direction.EAST, 3).move(Direction.NORTH, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
@ -241,7 +236,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
mut.set(pos).move(Direction.WEST, 3).move(Direction.NORTH, i);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
@ -255,15 +250,14 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
}
for (int i = 0; i < 4; i++) {
mut.set(pos).move(Direction.UP).move(BlocksHelper.HORIZONTAL[i], 3)
.move(BlocksHelper.HORIZONTAL[(i + 1) & 3], 3);
mut.set(pos).move(Direction.UP).move(BlocksHelper.HORIZONTAL[i], 3).move(BlocksHelper.HORIZONTAL[(i + 1) & 3], 3);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_HYMENOPHORE);
}
}
for (int x = -2; x < 3; x++) {
for (int z = -2; z < 3; z++) {
mut.set(pos).move(x, 0, z);
@ -276,21 +270,18 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
int distance = axis == Axis.X ? x < 0 ? -1 : 1 : z < 0 ? -1 : 1;
BlockPos offseted = mut.relative(axis, distance);
if (world.getBlockState(offseted).getMaterial().isReplaceable()) {
Direction dir = Direction.fromAxisAndDirection(axis,
distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
BlocksHelper.setWithoutUpdate(world, offseted, EndBlocks.AMARANITA_FUR
.defaultBlockState().setValue(BaseAttachedBlock.FACING, dir));
Direction dir = Direction.fromAxisAndDirection(axis, distance < 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
BlocksHelper.setWithoutUpdate(world, offseted, EndBlocks.AMARANITA_FUR.defaultBlockState().setValue(BaseAttachedBlock.FACING, dir));
}
mut.move(Direction.DOWN);
}
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState()
.setValue(BaseAttachedBlock.FACING, Direction.DOWN));
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_FUR.defaultBlockState().setValue(BaseAttachedBlock.FACING, Direction.DOWN));
}
}
}
}
for (int y = 0; y < 3; y++) {
mut.setY(pos.getY() + y + 1);
for (int x = -2; x < 3; x++) {
@ -303,7 +294,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
}
}
}
int h = radius + 1;
for (int y = 4; y < h; y++) {
mut.setY(pos.getY() + y);
@ -312,14 +303,12 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
for (int z = -2; z < 3; z++) {
mut.setZ(pos.getZ() + z);
if (y < 6) {
if (((x / 2) == 0 || (z / 2) == 0)
&& world.getBlockState(mut).getMaterial().isReplaceable()) {
if (((x / 2) == 0 || (z / 2) == 0) && world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP);
}
}
else {
if ((x == 0 || z == 0) && (Math.abs(x) < 2 && Math.abs(z) < 2)
&& world.getBlockState(mut).getMaterial().isReplaceable()) {
if ((x == 0 || z == 0) && (Math.abs(x) < 2 && Math.abs(z) < 2) && world.getBlockState(mut).getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.AMARANITA_CAP);
}
}
@ -328,7 +317,7 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
}
}
}
static {
REPLACE = (state) -> {
if (state.is(TagAPI.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
@ -336,9 +325,9 @@ public class GiganticAmaranitaFeature extends DefaultFeature {
}
return state.getMaterial().isReplaceable();
};
IGNORE = EndBlocks.DRAGON_TREE::isTreeLog;
POST = (info) -> {
if (!info.getStateUp().is(EndBlocks.AMARANITA_STEM) || !info.getStateDown().is(EndBlocks.AMARANITA_STEM)) {
return EndBlocks.AMARANITA_HYPHAE.defaultBlockState();

View file

@ -31,20 +31,19 @@ import java.util.function.Function;
public class HelixTreeFeature extends DefaultFeature {
private static final Function<PosInfo, BlockState> POST;
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND))
return false;
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) return false;
BlocksHelper.setWithoutUpdate(world, pos, AIR);
float angle = random.nextFloat() * MHelper.PI2;
float radiusRange = MHelper.randRange(4.5F, 6F, random);
float scale = MHelper.randRange(0.5F, 1F, random);
float dx;
float dz;
List<Vector3f> spline = new ArrayList<Vector3f>(10);
@ -59,7 +58,7 @@ public class HelixTreeFeature extends DefaultFeature {
});
SDF rotated = new SDFRotation().setRotation(Vector3f.YP, (float) Math.PI).setSource(sdf);
sdf = new SDFUnion().setSourceA(rotated).setSourceB(sdf);
Vector3f lastPoint = spline.get(spline.size() - 1);
List<Vector3f> spline2 = SplineHelper.makeSpline(0, 0, 0, 0, 20, 0, 5);
SDF stem = SplineHelper.buildSDF(spline2, 1.0F, 0.5F, (p) -> {
@ -67,7 +66,7 @@ public class HelixTreeFeature extends DefaultFeature {
});
stem = new SDFTranslate().setTranslate(lastPoint.x(), lastPoint.y(), lastPoint.z()).setSource(stem);
sdf = new SDFSmoothUnion().setRadius(3).setSourceA(sdf).setSourceB(stem);
sdf = new SDFScale().setScale(scale).setSource(sdf);
dx = 30 * scale;
float dy1 = -20 * scale;
@ -83,11 +82,10 @@ public class HelixTreeFeature extends DefaultFeature {
});
SplineHelper.scale(spline2, scale);
BlockPos leafStart = pos.offset(lastPoint.x() + 0.5, lastPoint.y() + 0.5, lastPoint.z() + 0.5);
SplineHelper.fillSplineForce(spline2, world, EndBlocks.HELIX_TREE.log.defaultBlockState(), leafStart,
(state) -> {
return state.getMaterial().isReplaceable();
});
SplineHelper.fillSplineForce(spline2, world, EndBlocks.HELIX_TREE.log.defaultBlockState(), leafStart, (state) -> {
return state.getMaterial().isReplaceable();
});
spline.clear();
float rad = MHelper.randRange(8F, 11F, random);
int count = MHelper.randRange(20, 30, random);
@ -102,7 +100,7 @@ public class HelixTreeFeature extends DefaultFeature {
dz = (float) Math.cos(i * 0.45F + angle) * radius;
spline.add(new Vector3f(dx, i * scaleM, dz));
}
Vector3f start = new Vector3f();
Vector3f end = new Vector3f();
lastPoint = spline.get(0);
@ -133,7 +131,7 @@ public class HelixTreeFeature extends DefaultFeature {
}
lastPoint = point;
}
leaf = leaf.setValue(HelixTreeLeavesBlock.COLOR, 7);
leafStart = leafStart.offset(0, lastPoint.y(), 0);
if (world.getBlockState(leafStart).isAir()) {
@ -147,12 +145,11 @@ public class HelixTreeFeature extends DefaultFeature {
}
}
}
return true;
}
private void fillLine(Vector3f start, Vector3f end, WorldGenLevel world, BlockState state, BlockPos pos,
int offset) {
private void fillLine(Vector3f start, Vector3f end, WorldGenLevel world, BlockState state, BlockPos pos, int offset) {
float dx = end.x() - start.x();
float dy = end.y() - start.y();
float dz = end.z() - start.z();
@ -164,7 +161,7 @@ public class HelixTreeFeature extends DefaultFeature {
float x = start.x();
float y = start.y();
float z = start.z();
MutableBlockPos bPos = new MutableBlockPos();
for (int i = 0; i < count; i++) {
bPos.set(x + pos.getX(), y + pos.getY(), z + pos.getZ());
@ -182,11 +179,10 @@ public class HelixTreeFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, bPos, state.setValue(HelixTreeLeavesBlock.COLOR, 7));
}
}
static {
POST = (info) -> {
if (EndBlocks.HELIX_TREE.isTreeLog(info.getStateUp())
&& EndBlocks.HELIX_TREE.isTreeLog(info.getStateDown())) {
if (EndBlocks.HELIX_TREE.isTreeLog(info.getStateUp()) && EndBlocks.HELIX_TREE.isTreeLog(info.getStateDown())) {
return EndBlocks.HELIX_TREE.log.defaultBlockState();
}
return info.getState();

View file

@ -30,18 +30,17 @@ import java.util.function.Function;
public class JellyshroomFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private static final List<Vector3f> ROOT;
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND))
return false;
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) return false;
BlockState bark = EndBlocks.JELLYSHROOM.bark.defaultBlockState();
BlockState membrane = EndBlocks.JELLYSHROOM_CAP_PURPLE.defaultBlockState();
int height = MHelper.randRange(5, 8, random);
float radius = height * MHelper.randRange(0.15F, 0.25F, random);
List<Vector3f> spline = SplineHelper.makeSpline(0, -1, 0, 0, height, 0, 3);
@ -49,7 +48,7 @@ public class JellyshroomFeature extends DefaultFeature {
SDF sdf = SplineHelper.buildSDF(spline, radius, 0.8F, (bpos) -> {
return bark;
});
radius = height * MHelper.randRange(0.7F, 0.9F, random);
if (radius < 1.5F) {
radius = 1.5F;
@ -61,8 +60,7 @@ public class JellyshroomFeature extends DefaultFeature {
sdf = new SDFSmoothUnion().setRadius(3F).setSourceA(sdf).setSourceB(cap);
sdf.setReplaceFunction(REPLACE).addPostProcess((info) -> {
if (EndBlocks.JELLYSHROOM.isTreeLog(info.getState())) {
if (EndBlocks.JELLYSHROOM.isTreeLog(info.getStateUp())
&& EndBlocks.JELLYSHROOM.isTreeLog(info.getStateDown())) {
if (EndBlocks.JELLYSHROOM.isTreeLog(info.getStateUp()) && EndBlocks.JELLYSHROOM.isTreeLog(info.getStateDown())) {
return EndBlocks.JELLYSHROOM.log.defaultBlockState();
}
}
@ -77,16 +75,16 @@ public class JellyshroomFeature extends DefaultFeature {
}).fillRecursive(world, pos);
radius = height * 0.5F;
makeRoots(world, pos.offset(0, 2, 0), radius, random, bark);
return true;
}
private void makeRoots(WorldGenLevel world, BlockPos pos, float radius, Random random, BlockState wood) {
int count = (int) (radius * 3.5F);
for (int i = 0; i < count; i++) {
float angle = (float) i / (float) count * MHelper.PI2;
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
List<Vector3f> branch = SplineHelper.copySpline(ROOT);
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
@ -96,29 +94,28 @@ public class JellyshroomFeature extends DefaultFeature {
}
}
}
private SDF makeCap(float radius, Random random, BlockState cap) {
SDF sphere = new SDFSphere().setRadius(radius).setBlock(cap);
SDF sub = new SDFTranslate().setTranslate(0, -4, 0).setSource(sphere);
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere);
sphere = new SDFTranslate().setTranslate(0, 1 - radius * 0.5F, 0).setSource(sphere);
float angle = random.nextFloat() * MHelper.PI2;
int count = (int) MHelper.randRange(radius * 0.5F, radius, random);
if (count < 3) {
count = 3;
}
sphere = new SDFFlatWave().setAngle(angle).setRaysCount(count).setIntensity(0.2F).setSource(sphere);
return sphere;
}
static {
ROOT = Lists.newArrayList(new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0),
new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0));
ROOT = Lists.newArrayList(new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0), new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0));
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
REPLACE = (state) -> {
if (state.is(TagAPI.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
return true;

View file

@ -32,42 +32,41 @@ 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
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND))
return false;
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) return false;
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);
if (!SplineHelper.canGenerate(spline, pos, world, REPLACE)) {
return false;
}
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
float radius = MHelper.randRange(6F, 8F, random);
radius *= (size - 15F) / 20F + 1F;
Vector3f center = spline.get(4);
leavesBall(world, pos.offset(center.x(), center.y(), center.z()), radius, random, noise);
radius = MHelper.randRange(1.2F, 1.8F, random);
SDF function = SplineHelper.buildSDF(spline, radius, 0.7F, (bpos) -> {
return EndBlocks.LACUGROVE.bark.defaultBlockState();
});
function.setReplaceFunction(REPLACE);
function.addPostProcess(POST);
function.fillRecursive(world, pos);
spline = spline.subList(4, 6);
SplineHelper.fillSpline(spline, world, EndBlocks.LACUGROVE.bark.defaultBlockState(), pos, REPLACE);
MutableBlockPos mut = new MutableBlockPos();
int offset = random.nextInt(2);
for (int i = 0; i < 100; i++) {
@ -93,10 +92,8 @@ public class LacugroveFeature extends DefaultFeature {
for (int y = top; y >= minY; y--) {
mut.setY(y);
BlockState state = world.getBlockState(mut);
if (state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT)
|| state.is(TagAPI.END_GROUND)) {
BlocksHelper.setWithoutUpdate(world, mut,
y == top ? EndBlocks.LACUGROVE.bark : EndBlocks.LACUGROVE.log);
if (state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT) || state.is(TagAPI.END_GROUND)) {
BlocksHelper.setWithoutUpdate(world, mut, y == top ? EndBlocks.LACUGROVE.bark : EndBlocks.LACUGROVE.log);
}
else {
break;
@ -106,21 +103,19 @@ public class LacugroveFeature extends DefaultFeature {
}
}
}
return true;
}
private void leavesBall(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.LACUGROVE_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.LACUGROVE_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
sphere = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 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 = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius - 2, 0).setSource(sphere));
MutableBlockPos mut = new MutableBlockPos();
sphere.addPostProcess((info) -> {
if (random.nextInt(5) == 0) {
@ -157,12 +152,11 @@ public class LacugroveFeature extends DefaultFeature {
return info.getState();
});
sphere.fillRecursiveIgnore(world, pos, IGNORE);
if (radius > 5) {
int count = (int) (radius * 2.5F);
for (int i = 0; i < count; i++) {
BlockPos p = pos.offset(random.nextGaussian() * 1, random.nextGaussian() * 1,
random.nextGaussian() * 1);
BlockPos p = pos.offset(random.nextGaussian() * 1, random.nextGaussian() * 1, random.nextGaussian() * 1);
boolean place = true;
for (Direction d : Direction.values()) {
BlockState state = world.getBlockState(p.relative(d));
@ -176,10 +170,10 @@ public class LacugroveFeature extends DefaultFeature {
}
}
}
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.LACUGROVE.bark);
}
static {
REPLACE = (state) -> {
if (state.is(TagAPI.END_GROUND)) {
@ -196,14 +190,13 @@ 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())) {
if (EndBlocks.LACUGROVE.isTreeLog(info.getStateUp()) && EndBlocks.LACUGROVE.isTreeLog(info.getStateDown())) {
return EndBlocks.LACUGROVE.log.defaultBlockState();
}
return info.getState();

View file

@ -39,16 +39,15 @@ public class LucerniaFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> IGNORE;
private static final List<Vector3f> SPLINE;
private static final List<Vector3f> ROOT;
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
final NoneFeatureConfiguration config = featureConfig.config();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND))
return false;
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) return false;
float size = MHelper.randRange(12, 20, random);
int count = (int) (size * 0.3F);
float var = MHelper.PI2 / (float) (count * 3);
@ -65,25 +64,21 @@ public class LucerniaFeature extends DefaultFeature {
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
leavesBall(world, pos.offset(last.x(), last.y(), last.z()), leavesRadius, random, noise, config != null);
}
makeRoots(world, pos.offset(0, MHelper.randRange(3, 5, random), 0), size * 0.35F, random);
return true;
}
private void leavesBall(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise,
boolean natural) {
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.LUCERNIA_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
private void leavesBall(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise, boolean natural) {
SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.LUCERNIA_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
SDF sub = new SDFScale().setScale(5).setSource(sphere);
sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub);
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
sphere = new SDFScale3D().setScale(1, 0.75F, 1).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) ->
(float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 2F).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) ->
MHelper.randRange(-1.5F, 1.5F, random)).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 2F).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> MHelper.randRange(-1.5F, 1.5F, random)).setSource(sphere);
MutableBlockPos mut = new MutableBlockPos();
for (Direction d1 : BlocksHelper.HORIZONTAL) {
BlockPos p = mut.set(pos).move(Direction.UP).move(d1).immutable();
@ -93,14 +88,12 @@ public class LucerniaFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.LUCERNIA.bark.defaultBlockState());
}
}
BlockState top = EndBlocks.FILALUX.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
BlockState middle = EndBlocks.FILALUX.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.MIDDLE);
BlockState bottom = EndBlocks.FILALUX.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.BOTTOM);
BlockState middle = EndBlocks.FILALUX.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE);
BlockState bottom = EndBlocks.FILALUX.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM);
BlockState outer = EndBlocks.LUCERNIA_OUTER_LEAVES.defaultBlockState();
List<BlockPos> support = Lists.newArrayList();
sphere.addPostProcess((info) -> {
if (natural && random.nextInt(6) == 0 && info.getStateDown().isAir()) {
@ -116,14 +109,14 @@ public class LucerniaFeature extends DefaultFeature {
}
info.setState(EndBlocks.LUCERNIA.bark.defaultBlockState());
}
MHelper.shuffle(DIRECTIONS, random);
for (Direction d : DIRECTIONS) {
if (info.getState(d).isAir()) {
info.setBlockPos(info.getPos().relative(d), outer.setValue(FurBlock.FACING, d));
}
}
if (EndBlocks.LUCERNIA.isTreeLog(info.getState())) {
for (int x = -6; x < 7; x++) {
int ax = Math.abs(x);
@ -152,7 +145,7 @@ public class LucerniaFeature extends DefaultFeature {
});
sphere.fillRecursiveIgnore(world, pos, IGNORE);
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.LUCERNIA.bark);
support.forEach((bpos) -> {
BlockState state = world.getBlockState(bpos);
if (state.isAir() || state.is(EndBlocks.LUCERNIA_OUTER_LEAVES)) {
@ -174,13 +167,13 @@ public class LucerniaFeature extends DefaultFeature {
}
});
}
private void makeRoots(WorldGenLevel world, BlockPos pos, float radius, Random random) {
int count = (int) (radius * 1.5F);
for (int i = 0; i < count; i++) {
float angle = (float) i / (float) count * MHelper.PI2;
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
List<Vector3f> branch = SplineHelper.copySpline(ROOT);
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
@ -190,7 +183,7 @@ public class LucerniaFeature extends DefaultFeature {
}
}
}
static {
REPLACE = (state) -> {
if (state.is(TagAPI.END_GROUND)) {
@ -204,15 +197,12 @@ public class LucerniaFeature extends DefaultFeature {
}
return state.getMaterial().isReplaceable();
};
IGNORE = EndBlocks.LUCERNIA::isTreeLog;
SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F),
new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F),
new Vector3f(0.50F, 1.00F, 0.00F));
ROOT = Lists.newArrayList(new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0),
new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0));
SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F), new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F), new Vector3f(0.50F, 1.00F, 0.00F));
ROOT = Lists.newArrayList(new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0), new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0));
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
}
}

View file

@ -41,26 +41,25 @@ public class MossyGlowshroomFeature extends DefaultFeature {
private static final SDFBinary FUNCTION;
private static final SDFTranslate HEAD_POS;
private static final SDFFlatWave ROOTS_ROT;
private static final SDFPrimitive CONE1;
private static final SDFPrimitive CONE2;
private static final SDFPrimitive CONE_GLOW;
private static final SDFPrimitive ROOTS;
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final BlockPos blockPos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
BlockState down = world.getBlockState(blockPos.below());
if (!down.is(EndBlocks.END_MYCELIUM) && !down.is(EndBlocks.END_MOSS))
return false;
if (!down.is(EndBlocks.END_MYCELIUM) && !down.is(EndBlocks.END_MOSS)) return false;
CONE1.setBlock(EndBlocks.MOSSY_GLOWSHROOM_CAP);
CONE2.setBlock(EndBlocks.MOSSY_GLOWSHROOM_CAP);
CONE_GLOW.setBlock(EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE);
ROOTS.setBlock(EndBlocks.MOSSY_GLOWSHROOM.bark);
float height = MHelper.randRange(10F, 25F, random);
int count = MHelper.floor(height / 4);
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, count);
@ -70,59 +69,54 @@ public class MossyGlowshroomFeature extends DefaultFeature {
});
Vector3f pos = spline.get(spline.size() - 1);
float scale = MHelper.randRange(0.75F, 1.1F, random);
if (!SplineHelper.canGenerate(spline, scale, blockPos, world, REPLACE)) {
return false;
}
BlocksHelper.setWithoutUpdate(world, blockPos, AIR);
CENTER.set(blockPos.getX(), 0, blockPos.getZ());
HEAD_POS.setTranslate(pos.x(), pos.y(), pos.z());
ROOTS_ROT.setAngle(random.nextFloat() * MHelper.PI2);
FUNCTION.setSourceA(sdf);
new SDFScale().setScale(scale).setSource(FUNCTION).setReplaceFunction(REPLACE).addPostProcess((info) -> {
if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getState())) {
if (random.nextBoolean() && info.getStateUp().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) {
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState()
.setValue(MossyGlowshroomCapBlock.TRANSITION, true));
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState().setValue(MossyGlowshroomCapBlock.TRANSITION, true));
return info.getState();
}
else if (!EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp())
|| !EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) {
else if (!EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateUp()) || !EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown())) {
info.setState(EndBlocks.MOSSY_GLOWSHROOM.bark.defaultBlockState());
return info.getState();
}
}
else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_CAP) {
if (EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(info.getStateDown().getBlock())) {
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState()
.setValue(MossyGlowshroomCapBlock.TRANSITION, true));
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState().setValue(MossyGlowshroomCapBlock.TRANSITION, true));
return info.getState();
}
info.setState(EndBlocks.MOSSY_GLOWSHROOM_CAP.defaultBlockState());
return info.getState();
}
else if (info.getState().getBlock() == EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (info.getState(dir) == AIR) {
info.setBlockPos(info.getPos().relative(dir),
EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().setValue(FurBlock.FACING, dir));
info.setBlockPos(info.getPos().relative(dir), EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().setValue(FurBlock.FACING, dir));
}
}
if (info.getStateDown().getBlock() != EndBlocks.MOSSY_GLOWSHROOM_HYMENOPHORE) {
info.setBlockPos(info.getPos().below(), EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState()
.setValue(FurBlock.FACING, Direction.DOWN));
info.setBlockPos(info.getPos().below(), EndBlocks.MOSSY_GLOWSHROOM_FUR.defaultBlockState().setValue(FurBlock.FACING, Direction.DOWN));
}
}
return info.getState();
}).fillRecursive(world, blockPos);
return true;
}
static {
SDFCappedCone cone1 = new SDFCappedCone().setHeight(2.5F).setRadius1(1.5F).setRadius2(2.5F);
SDFCappedCone cone2 = new SDFCappedCone().setHeight(3F).setRadius1(2.5F).setRadius2(13F);
@ -131,40 +125,37 @@ public class MossyGlowshroomFeature extends DefaultFeature {
SDF upCone = new SDFSubtraction().setSourceA(posedCone2).setSourceB(posedCone3);
SDF wave = new SDFFlatWave().setRaysCount(12).setIntensity(1.3F).setSource(upCone);
SDF cones = new SDFSmoothUnion().setRadius(3).setSourceA(cone1).setSourceB(wave);
CONE1 = cone1;
CONE2 = cone2;
SDF innerCone = new SDFTranslate().setTranslate(0, 1.25F, 0).setSource(upCone);
innerCone = new SDFScale3D().setScale(1.2F, 1F, 1.2F).setSource(innerCone);
cones = new SDFUnion().setSourceA(cones).setSourceB(innerCone);
SDF glowCone = new SDFCappedCone().setHeight(3F).setRadius1(2F).setRadius2(12.5F);
CONE_GLOW = (SDFPrimitive) glowCone;
glowCone = new SDFTranslate().setTranslate(0, 4.25F, 0).setSource(glowCone);
glowCone = new SDFSubtraction().setSourceA(glowCone).setSourceB(posedCone3);
cones = new SDFUnion().setSourceA(cones).setSourceB(glowCone);
OpenSimplexNoise noise = new OpenSimplexNoise(1234);
cones = new SDFCoordModify().setFunction((pos) -> {
float dist = MHelper.length(pos.x(), pos.z());
float y = pos.y() + (float) noise.eval(pos.x() * 0.1 + CENTER.x(), pos.z() * 0.1 + CENTER.z()) * dist * 0.3F
- dist * 0.15F;
float y = pos.y() + (float) noise.eval(pos.x() * 0.1 + CENTER.x(), pos.z() * 0.1 + CENTER.z()) * dist * 0.3F - dist * 0.15F;
pos.set(pos.x(), y, pos.z());
}).setSource(cones);
HEAD_POS = (SDFTranslate) new SDFTranslate()
.setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones));
HEAD_POS = (SDFTranslate) new SDFTranslate().setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones));
SDF roots = new SDFSphere().setRadius(4F);
ROOTS = (SDFPrimitive) roots;
roots = new SDFScale3D().setScale(1, 0.7F, 1).setSource(roots);
ROOTS_ROT = (SDFFlatWave) new SDFFlatWave().setRaysCount(5).setIntensity(1.5F).setSource(roots);
FUNCTION = new SDFSmoothUnion().setRadius(4)
.setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT));
FUNCTION = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT));
REPLACE = (state) -> {
if (state.is(TagAPI.END_GROUND)) {
return true;

View file

@ -33,7 +33,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private static final Function<BlockState, Boolean> IGNORE;
private static final Function<PosInfo, BlockState> POST;
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -43,56 +43,51 @@ public class PythadendronTreeFeature extends DefaultFeature {
return false;
}
BlocksHelper.setWithoutUpdate(world, pos, AIR);
float size = MHelper.randRange(10, 20, random);
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, size, 0, 4);
SplineHelper.offsetParts(spline, random, 0.7F, 0, 0.7F);
Vector3f last = spline.get(spline.size() - 1);
int depth = MHelper.floor((size - 10F) * 3F / 10F + 1F);
float bsize = (10F - (size - 10F)) / 10F + 1.5F;
branch(last.x(), last.y(), last.z(), size * bsize, MHelper.randRange(0, MHelper.PI2, random), random, depth,
world, pos);
branch(last.x(), last.y(), last.z(), size * bsize, MHelper.randRange(0, MHelper.PI2, random), random, depth, world, pos);
SDF function = SplineHelper.buildSDF(spline, 1.7F, 1.1F, (bpos) -> {
return EndBlocks.PYTHADENDRON.bark.defaultBlockState();
});
function.setReplaceFunction(REPLACE);
function.addPostProcess(POST);
function.fillRecursive(world, pos);
return true;
}
private void branch(float x, float y, float z, float size, float angle, Random random, int depth,
WorldGenLevel world, BlockPos pos) {
if (depth == 0)
return;
private void branch(float x, float y, float z, float size, float angle, Random random, int depth, WorldGenLevel world, BlockPos pos) {
if (depth == 0) return;
float dx = (float) Math.cos(angle) * size * 0.15F;
float dz = (float) Math.sin(angle) * size * 0.15F;
float x1 = x + dx;
float z1 = z + dz;
float x2 = x - dx;
float z2 = z - dz;
List<Vector3f> spline = SplineHelper.makeSpline(x, y, z, x1, y, z1, 5);
SplineHelper.powerOffset(spline, size * MHelper.randRange(1.0F, 2.0F, random), 4);
SplineHelper.offsetParts(spline, random, 0.3F, 0, 0.3F);
Vector3f pos1 = spline.get(spline.size() - 1);
boolean s1 = SplineHelper.fillSpline(spline, world, EndBlocks.PYTHADENDRON.bark.defaultBlockState(), pos,
REPLACE);
boolean s1 = SplineHelper.fillSpline(spline, world, EndBlocks.PYTHADENDRON.bark.defaultBlockState(), pos, REPLACE);
spline = SplineHelper.makeSpline(x, y, z, x2, y, z2, 5);
SplineHelper.powerOffset(spline, size * MHelper.randRange(1.0F, 2.0F, random), 4);
SplineHelper.offsetParts(spline, random, 0.3F, 0, 0.3F);
Vector3f pos2 = spline.get(spline.size() - 1);
boolean s2 = SplineHelper.fillSpline(spline, world, EndBlocks.PYTHADENDRON.bark.defaultBlockState(), pos,
REPLACE);
boolean s2 = SplineHelper.fillSpline(spline, world, EndBlocks.PYTHADENDRON.bark.defaultBlockState(), pos, REPLACE);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
if (depth < 3) {
if (s1) {
@ -102,12 +97,12 @@ public class PythadendronTreeFeature extends DefaultFeature {
leavesBall(world, pos.offset(pos2.x(), pos2.y(), pos2.z()), random, noise);
}
}
float size1 = size * MHelper.randRange(0.75F, 0.95F, random);
float size2 = size * MHelper.randRange(0.75F, 0.95F, random);
float angle1 = angle + (float) Math.PI * 0.5F + MHelper.randRange(-0.1F, 0.1F, random);
float angle2 = angle + (float) Math.PI * 0.5F + MHelper.randRange(-0.1F, 0.1F, random);
if (s1) {
branch(pos1.x(), pos1.y(), pos1.z(), size1, angle1, random, depth - 1, world, pos);
}
@ -115,12 +110,11 @@ public class PythadendronTreeFeature extends DefaultFeature {
branch(pos2.x(), pos2.y(), pos2.z(), size2, angle2, random, depth - 1, world, pos);
}
}
private void leavesBall(WorldGenLevel world, BlockPos pos, Random random, OpenSimplexNoise noise) {
float radius = MHelper.randRange(4.5F, 6.5F, random);
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.PYTHADENDRON_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.PYTHADENDRON_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
sphere = new SDFScale3D().setScale(1, 0.6F, 1).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3;
@ -128,8 +122,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
sphere = new SDFDisplacement().setFunction((vec) -> {
return random.nextFloat() * 3F - 1.5F;
}).setSource(sphere);
sphere = new SDFSubtraction().setSourceA(sphere)
.setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
MutableBlockPos mut = new MutableBlockPos();
sphere.addPostProcess((info) -> {
if (random.nextInt(5) == 0) {
@ -167,7 +160,7 @@ public class PythadendronTreeFeature extends DefaultFeature {
});
sphere.fillRecursiveIgnore(world, pos, IGNORE);
}
static {
REPLACE = (state) -> {
if (state.is(TagAPI.END_GROUND)) {
@ -181,14 +174,13 @@ public class PythadendronTreeFeature extends DefaultFeature {
}
return state.getMaterial().isReplaceable();
};
IGNORE = (state) -> {
return EndBlocks.PYTHADENDRON.isTreeLog(state);
};
POST = (info) -> {
if (EndBlocks.PYTHADENDRON.isTreeLog(info.getStateUp())
&& EndBlocks.PYTHADENDRON.isTreeLog(info.getStateDown())) {
if (EndBlocks.PYTHADENDRON.isTreeLog(info.getStateUp()) && EndBlocks.PYTHADENDRON.isTreeLog(info.getStateDown())) {
return EndBlocks.PYTHADENDRON.log.defaultBlockState();
}
return info.getState();

View file

@ -38,15 +38,14 @@ public class TenaneaFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private static final Function<BlockState, Boolean> IGNORE;
private static final List<Vector3f> SPLINE;
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND))
return false;
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) return false;
float size = MHelper.randRange(7, 10, random);
int count = (int) (size * 0.45F);
float var = MHelper.PI2 / (float) (count * 3);
@ -63,22 +62,19 @@ public class TenaneaFeature extends DefaultFeature {
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
leavesBall(world, pos.offset(last.x(), last.y(), last.z()), leavesRadius, random, noise);
}
return true;
}
private void leavesBall(WorldGenLevel world, BlockPos pos, float radius, Random random, OpenSimplexNoise noise) {
SDF sphere = new SDFSphere().setRadius(radius)
.setBlock(EndBlocks.TENANEA_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
SDF sphere = new SDFSphere().setRadius(radius).setBlock(EndBlocks.TENANEA_LEAVES.defaultBlockState().setValue(LeavesBlock.DISTANCE, 6));
SDF sub = new SDFScale().setScale(5).setSource(sphere);
sub = new SDFTranslate().setTranslate(0, -radius * 5, 0).setSource(sub);
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
sphere = new SDFScale3D().setScale(1, 0.75F, 1).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) ->
(float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 2F).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) ->
MHelper.randRange(-1.5F, 1.5F, random)).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 2F).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> MHelper.randRange(-1.5F, 1.5F, random)).setSource(sphere);
MutableBlockPos mut = new MutableBlockPos();
for (Direction d1 : BlocksHelper.HORIZONTAL) {
BlockPos p = mut.set(pos).move(Direction.UP).move(d1).immutable();
@ -88,15 +84,12 @@ public class TenaneaFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TENANEA.bark.defaultBlockState());
}
}
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.TOP);
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.MIDDLE);
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE,
TripleShape.BOTTOM);
BlockState top = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
BlockState middle = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE);
BlockState bottom = EndBlocks.TENANEA_FLOWERS.defaultBlockState().setValue(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM);
BlockState outer = EndBlocks.TENANEA_OUTER_LEAVES.defaultBlockState();
List<BlockPos> support = Lists.newArrayList();
sphere.addPostProcess((info) -> {
if (random.nextInt(6) == 0 && info.getStateDown().isAir()) {
@ -112,14 +105,14 @@ public class TenaneaFeature extends DefaultFeature {
}
info.setState(EndBlocks.TENANEA.bark.defaultBlockState());
}
MHelper.shuffle(DIRECTIONS, random);
for (Direction d : DIRECTIONS) {
if (info.getState(d).isAir()) {
info.setBlockPos(info.getPos().relative(d), outer.setValue(FurBlock.FACING, d));
}
}
if (EndBlocks.TENANEA.isTreeLog(info.getState())) {
for (int x = -6; x < 7; x++) {
int ax = Math.abs(x);
@ -148,7 +141,7 @@ public class TenaneaFeature extends DefaultFeature {
});
sphere.fillRecursiveIgnore(world, pos, IGNORE);
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.TENANEA.bark);
support.forEach((bpos) -> {
BlockState state = world.getBlockState(bpos);
if (state.isAir() || state.is(EndBlocks.TENANEA_OUTER_LEAVES)) {
@ -170,7 +163,7 @@ public class TenaneaFeature extends DefaultFeature {
}
});
}
static {
REPLACE = (state) -> {
if (state.is(TagAPI.END_GROUND)) {
@ -184,11 +177,9 @@ public class TenaneaFeature extends DefaultFeature {
}
return state.getMaterial().isReplaceable();
};
IGNORE = EndBlocks.TENANEA::isTreeLog;
SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F),
new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F),
new Vector3f(0.50F, 1.00F, 0.00F));
SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F), new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F), new Vector3f(0.50F, 1.00F, 0.00F));
}
}

View file

@ -37,36 +37,32 @@ public class UmbrellaTreeFeature extends DefaultFeature {
private static final Function<BlockState, Boolean> REPLACE;
private static final List<Vector3f> SPLINE;
private static final List<Vector3f> ROOT;
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
final NoneFeatureConfiguration config = featureConfig.config();
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND))
return false;
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) return false;
BlockState wood = EndBlocks.UMBRELLA_TREE.bark.defaultBlockState();
BlockState membrane = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState()
.setValue(UmbrellaTreeMembraneBlock.COLOR, 1);
BlockState center = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState()
.setValue(UmbrellaTreeMembraneBlock.COLOR, 0);
BlockState fruit = EndBlocks.UMBRELLA_TREE_CLUSTER.defaultBlockState()
.setValue(UmbrellaTreeClusterBlock.NATURAL, true);
BlockState membrane = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState().setValue(UmbrellaTreeMembraneBlock.COLOR, 1);
BlockState center = EndBlocks.UMBRELLA_TREE_MEMBRANE.defaultBlockState().setValue(UmbrellaTreeMembraneBlock.COLOR, 0);
BlockState fruit = EndBlocks.UMBRELLA_TREE_CLUSTER.defaultBlockState().setValue(UmbrellaTreeClusterBlock.NATURAL, true);
float size = MHelper.randRange(10, 20, random);
int count = (int) (size * 0.15F);
float var = MHelper.PI2 / (float) (count * 3);
float start = MHelper.randRange(0, MHelper.PI2, random);
SDF sdf = null;
List<Center> centers = Lists.newArrayList();
float scale = 1;
if (config != null) {
scale = MHelper.randRange(1F, 1.7F, random);
}
for (int i = 0; i < count; i++) {
float angle = (float) i / (float) count * MHelper.PI2 + MHelper.randRange(0, var, random) + start;
List<Vector3f> spline = SplineHelper.copySpline(SPLINE);
@ -75,42 +71,40 @@ public class UmbrellaTreeFeature extends DefaultFeature {
// SplineHelper.offset(spline, new Vector3f((20 - size) * 0.2F, 0, 0));
SplineHelper.rotateSpline(spline, angle);
SplineHelper.offsetParts(spline, random, 0.5F, 0, 0.5F);
if (SplineHelper.canGenerate(spline, pos, world, REPLACE)) {
float rScale = (scale - 1) * 0.4F + 1;
SDF branch = SplineHelper.buildSDF(spline, 1.2F * rScale, 0.8F * rScale, (bpos) -> {
return wood;
});
Vector3f vec = spline.get(spline.size() - 1);
float radius = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.4F;
sdf = (sdf == null) ? branch : new SDFUnion().setSourceA(sdf).setSourceB(branch);
SDF mem = makeMembrane(world, radius, random, membrane, center);
float px = MHelper.floor(vec.x()) + 0.5F;
float py = MHelper.floor(vec.y()) + 0.5F;
float pz = MHelper.floor(vec.z()) + 0.5F;
mem = new SDFTranslate().setTranslate(px, py, pz).setSource(mem);
sdf = new SDFSmoothUnion().setRadius(2).setSourceA(sdf).setSourceB(mem);
centers.add(new Center(pos.getX() + (double) (px * scale), pos.getY() + (double) (py * scale),
pos.getZ() + (double) (pz * scale), radius * scale));
centers.add(new Center(pos.getX() + (double) (px * scale), pos.getY() + (double) (py * scale), pos.getZ() + (double) (pz * scale), radius * scale));
vec = spline.get(0);
}
}
if (sdf == null) {
return false;
}
if (scale > 1) {
sdf = new SDFScale().setScale(scale).setSource(sdf);
}
sdf.setReplaceFunction(REPLACE).addPostProcess((info) -> {
if (EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateUp())
&& EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateDown())) {
if (EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateUp()) && EndBlocks.UMBRELLA_TREE.isTreeLog(info.getStateDown())) {
return EndBlocks.UMBRELLA_TREE.log.defaultBlockState();
}
else if (info.getState().equals(membrane)) {
@ -131,7 +125,7 @@ public class UmbrellaTreeFeature extends DefaultFeature {
return info.getState();
}).fillRecursive(world, pos);
makeRoots(world, pos, (size * 0.5F + 3) * scale, random, wood);
for (Center c : centers) {
if (!world.getBlockState(new BlockPos(c.px, c.py, c.pz)).isAir()) {
count = MHelper.floor(MHelper.randRange(5F, 10F, random) * scale);
@ -145,16 +139,16 @@ public class UmbrellaTreeFeature extends DefaultFeature {
}
}
}
return true;
}
private void makeRoots(WorldGenLevel world, BlockPos pos, float radius, Random random, BlockState wood) {
int count = (int) (radius * 1.5F);
for (int i = 0; i < count; i++) {
float angle = (float) i / (float) count * MHelper.PI2;
float scale = radius * MHelper.randRange(0.85F, 1.15F, random);
List<Vector3f> branch = SplineHelper.copySpline(ROOT);
SplineHelper.rotateSpline(branch, angle);
SplineHelper.scale(branch, scale);
@ -164,27 +158,27 @@ public class UmbrellaTreeFeature extends DefaultFeature {
}
}
}
private SDF makeMembrane(WorldGenLevel world, float radius, Random random, BlockState membrane, BlockState center) {
SDF sphere = new SDFSphere().setRadius(radius).setBlock(membrane);
SDF sub = new SDFTranslate().setTranslate(0, -4, 0).setSource(sphere);
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sub);
sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere);
sphere = new SDFTranslate().setTranslate(0, 1 - radius * 0.5F, 0).setSource(sphere);
float angle = random.nextFloat() * MHelper.PI2;
int count = (int) MHelper.randRange(radius, radius * 2, random);
if (count < 5) {
count = 5;
}
sphere = new SDFFlatWave().setAngle(angle).setRaysCount(count).setIntensity(0.6F).setSource(sphere);
SDF cent = new SDFSphere().setRadius(2.5F).setBlock(center);
sphere = new SDFUnion().setSourceA(sphere).setSourceB(cent);
return sphere;
}
private void makeFruits(WorldGenLevel world, double px, double py, double pz, BlockState fruit, float scale) {
MutableBlockPos mut = new MutableBlockPos().set(px, py, pz);
for (int i = 0; i < 8; i++) {
@ -198,38 +192,34 @@ public class UmbrellaTreeFeature extends DefaultFeature {
}
}
}
static {
SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F),
new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F),
new Vector3f(0.50F, 1.00F, 0.00F));
ROOT = Lists.newArrayList(new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0),
new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0));
SPLINE = Lists.newArrayList(new Vector3f(0.00F, 0.00F, 0.00F), new Vector3f(0.10F, 0.35F, 0.00F), new Vector3f(0.20F, 0.50F, 0.00F), new Vector3f(0.30F, 0.55F, 0.00F), new Vector3f(0.42F, 0.70F, 0.00F), new Vector3f(0.50F, 1.00F, 0.00F));
ROOT = Lists.newArrayList(new Vector3f(0.1F, 0.70F, 0), new Vector3f(0.3F, 0.30F, 0), new Vector3f(0.7F, 0.05F, 0), new Vector3f(0.8F, -0.20F, 0));
SplineHelper.offset(ROOT, new Vector3f(0, -0.45F, 0));
REPLACE = (state) -> {
if (state.is(TagAPI.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|| state.is(EndBlocks.UMBRELLA_TREE_MEMBRANE)) {
if (state.is(TagAPI.END_GROUND) || state.getMaterial().equals(Material.PLANT) || state.is(EndBlocks.UMBRELLA_TREE_MEMBRANE)) {
return true;
}
return state.getMaterial().isReplaceable();
};
}
private class Center {
final double px;
final double py;
final double pz;
final float radius;
Center(double x, double y, double z, float radius) {
this.px = x;
this.py = y;
this.pz = z;
this.radius = radius;
}
double distance(float x, float z) {
return MHelper.length(px - x, pz - z);
}