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

@ -33,31 +33,27 @@ public class OldBulbisTreeFeature extends DefaultFeature {
private static final List<Vector3f> ROOT;
private static final List<Vector3f> LEAF;
private static final List<Vector3f> SIDE;
@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(4)).is(TagAPI.GEN_TERRAIN))
return false;
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) return false;
if (!world.getBlockState(pos.below(4)).is(TagAPI.GEN_TERRAIN)) return false;
BlockState stem = Integrations.BYG.getDefaultState("bulbis_stem");
BlockState wood = Integrations.BYG.getDefaultState("bulbis_wood");
BlockState cap = Integrations.BYG
.getDefaultState(random.nextBoolean() ? "bulbis_shell" : "purple_bulbis_shell");
BlockState cap = Integrations.BYG.getDefaultState(random.nextBoolean() ? "bulbis_shell" : "purple_bulbis_shell");
BlockState glow = Integrations.BYG.getDefaultState("purple_shroomlight");
Function<BlockState, Boolean> replacement = (state) -> {
if (state.equals(stem) || state.equals(wood) || state.is(TagAPI.END_GROUND)
|| state.getMaterial().equals(Material.PLANT)) {
if (state.equals(stem) || state.equals(wood) || state.is(TagAPI.END_GROUND) || state.getMaterial().equals(Material.PLANT)) {
return true;
}
return state.getMaterial().isReplaceable();
};
float size = MHelper.randRange(10, 20, random);
float addSize = MHelper.randRange(1, 1.7F, random);
float addRad = addSize * 0.5F + 0.5F;
@ -80,50 +76,48 @@ public class OldBulbisTreeFeature extends DefaultFeature {
SDF branch = SplineHelper.buildSDF(spline, 2.3F * addRad, 1.3F * addRad, (bpos) -> {
return stem;
});
Vector3f vec = spline.get(spline.size() - 1);
float radius = (size + MHelper.randRange(0, size * 0.5F, random)) * 0.35F;
bigSphere(world, pos.offset(vec.x(), vec.y(), vec.z()), radius, cap, glow, wood, replacement, random);
vec = SplineHelper.getPos(spline, 0.3F);
makeRoots(world, pos.offset(vec.x(), vec.y(), vec.z()), size * 0.4F + 5, random, wood, replacement);
sdf = (sdf == null) ? branch : new SDFUnion().setSourceA(sdf).setSourceB(branch);
}
sdf.setReplaceFunction(replacement).addPostProcess((info) -> {
if (info.getState().equals(stem)
&& (!info.getStateUp().equals(stem) || !info.getStateDown().equals(stem))) {
if (info.getState().equals(stem) && (!info.getStateUp().equals(stem) || !info.getStateDown().equals(stem))) {
return wood;
}
return info.getState();
}).fillArea(world, pos, limits);
return true;
}
private void bigSphere(WorldGenLevel world, BlockPos pos, float radius, BlockState cap, BlockState glow,
BlockState wood, Function<BlockState, Boolean> replacement, Random random) {
private void bigSphere(WorldGenLevel world, BlockPos pos, float radius, BlockState cap, BlockState glow, BlockState wood, Function<BlockState, Boolean> replacement, Random random) {
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
SDF sphere = new SDFSphere().setRadius(radius).setBlock(cap);
SDF sphereInner = new SDFSphere().setRadius(radius * 0.53F).setBlock(Blocks.AIR);
sphereInner = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1);
}).setSource(sphereInner);
SDF sphereGlow = new SDFSphere().setRadius(radius * 0.6F).setBlock(glow);
sphereGlow = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1) * 2F;
}).setSource(sphereGlow);
sphereGlow = new SDFSubtraction().setSourceA(sphereGlow).setSourceB(sphereInner);
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sphereGlow);
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(sphereInner);
float offsetY = radius * 1.7F;
sphere = new SDFUnion().setSourceA(sphere).setSourceB(sphereGlow);
sphere = new SDFTranslate().setTranslate(0, offsetY, 0).setSource(sphere);
int leafCount = (int) (radius * 0.5F) + 2;
for (int i = 0; i < 4; i++) {
float angle = (float) i / 4 * MHelper.PI2;
@ -131,13 +125,13 @@ public class OldBulbisTreeFeature extends DefaultFeature {
SplineHelper.rotateSpline(spline, angle);
SplineHelper.scale(spline, radius * 1.4F);
SplineHelper.fillSplineForce(spline, world, wood, pos, replacement);
for (int j = 0; j < leafCount; j++) {
float delta = ((float) j / (float) (leafCount - 1));
float scale = (float) Math.sin(delta * Math.PI) * 0.8F + 0.2F;
float index = Mth.lerp(delta, 1F, 3.9F);
Vector3f point = SplineHelper.getPos(spline, index);
List<Vector3f> side = SplineHelper.copySpline(SIDE);
SplineHelper.rotateSpline(side, angle);
SplineHelper.scale(side, scale * radius);
@ -145,17 +139,16 @@ public class OldBulbisTreeFeature extends DefaultFeature {
SplineHelper.fillSplineForce(side, world, wood, p, replacement);
}
}
sphere.fillArea(world, pos, new AABB(pos.above((int) offsetY)).inflate(radius * 1.3F));
}
private void makeRoots(WorldGenLevel world, BlockPos pos, float radius, Random random, BlockState wood,
Function<BlockState, Boolean> replacement) {
private void makeRoots(WorldGenLevel world, BlockPos pos, float radius, Random random, BlockState wood, Function<BlockState, Boolean> replacement) {
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);
@ -165,20 +158,15 @@ public class OldBulbisTreeFeature 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(0F, 1F, 0), 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(0F, 1F, 0), 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));
LEAF = Lists.newArrayList(new Vector3f(0.00F, 0.0F, 0), new Vector3f(0.10F, 0.4F, 0),
new Vector3f(0.40F, 0.8F, 0), new Vector3f(0.75F, 0.9F, 0), new Vector3f(1.00F, 0.8F, 0));
SIDE = Lists.newArrayList(new Vector3f(0, -0.3F, -0.5F), new Vector3f(0, -0.1F, -0.3F),
new Vector3f(0, 0.0F, 0.0F), new Vector3f(0, -0.1F, 0.3F), new Vector3f(0, -0.3F, 0.5F));
LEAF = Lists.newArrayList(new Vector3f(0.00F, 0.0F, 0), new Vector3f(0.10F, 0.4F, 0), new Vector3f(0.40F, 0.8F, 0), new Vector3f(0.75F, 0.9F, 0), new Vector3f(1.00F, 0.8F, 0));
SIDE = Lists.newArrayList(new Vector3f(0, -0.3F, -0.5F), new Vector3f(0, -0.1F, -0.3F), new Vector3f(0, 0.0F, 0.0F), new Vector3f(0, -0.1F, 0.3F), new Vector3f(0, -0.3F, 0.5F));
}
}