Structure fix

This commit is contained in:
paulevsGitch 2020-09-30 10:50:47 +03:00
parent 310369cbb3
commit 2d53cedb90
8 changed files with 35 additions and 83 deletions

View file

@ -33,6 +33,7 @@ import ru.betterend.util.sdf.operator.SDFSubtraction;
import ru.betterend.util.sdf.operator.SDFTranslate;
import ru.betterend.util.sdf.operator.SDFUnion;
import ru.betterend.util.sdf.primitive.SDFCapedCone;
import ru.betterend.util.sdf.primitive.SDFPrimitive;
import ru.betterend.util.sdf.primitive.SDFSphere;
public class MossyGlowshroomFeature extends DefaultFeature {
@ -41,7 +42,12 @@ public class MossyGlowshroomFeature extends DefaultFeature {
private static final Vector3f CENTER = new Vector3f();
private static final SDFBinary FUNCTION;
private static final SDFTranslate HEAD_POS;
private static final SDFFlatWave ROOTS;
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 generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) {
@ -53,6 +59,11 @@ public class MossyGlowshroomFeature extends DefaultFeature {
return false;
}
CONE1.setBlock(BlockRegistry.MOSSY_GLOWSHROOM_CAP);
CONE2.setBlock(BlockRegistry.MOSSY_GLOWSHROOM_CAP);
CONE_GLOW.setBlock(BlockRegistry.MOSSY_GLOWSHROOM_HYMENOPHORE);
ROOTS.setBlock(BlockRegistry.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);
@ -63,7 +74,7 @@ public class MossyGlowshroomFeature extends DefaultFeature {
Vector3f pos = spline.get(spline.size() - 1);
CENTER.set(blockPos.getX(), 0, blockPos.getZ());
HEAD_POS.setTranslate(pos.getX(), pos.getY(), pos.getZ());
ROOTS.setAngle(random.nextFloat() * MHelper.PI2);
ROOTS_ROT.setAngle(random.nextFloat() * MHelper.PI2);
FUNCTION.setSourceA(sdf);
Set<BlockPos> blocks = new SDFScale()
.setScale(MHelper.randRange(0.75F, 1.1F, random))
@ -101,19 +112,23 @@ public class MossyGlowshroomFeature extends DefaultFeature {
}
static {
SDFCapedCone cone1 = new SDFCapedCone(BlockRegistry.MOSSY_GLOWSHROOM_CAP).setHeight(2.5F).setRadius1(1.5F).setRadius2(2.5F);
SDFCapedCone cone2 = new SDFCapedCone(BlockRegistry.MOSSY_GLOWSHROOM_CAP).setHeight(3F).setRadius1(2.5F).setRadius2(13F);
SDFCapedCone cone1 = new SDFCapedCone().setHeight(2.5F).setRadius1(1.5F).setRadius2(2.5F);
SDFCapedCone cone2 = new SDFCapedCone().setHeight(3F).setRadius1(2.5F).setRadius2(13F);
SDF posedCone2 = new SDFTranslate().setTranslate(0, 5, 0).setSource(cone2);
SDF posedCone3 = new SDFTranslate().setTranslate(0, 7F, 0).setSource(cone2);
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 SDFCapedCone(BlockRegistry.MOSSY_GLOWSHROOM_HYMENOPHORE).setHeight(3F).setRadius1(2F).setRadius2(12.5F);
SDF glowCone = new SDFCapedCone().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);
@ -128,11 +143,12 @@ public class MossyGlowshroomFeature extends DefaultFeature {
HEAD_POS = (SDFTranslate) new SDFTranslate().setSource(new SDFTranslate().setTranslate(0, 2.5F, 0).setSource(cones));
SDF roots = new SDFSphere(BlockRegistry.MOSSY_GLOWSHROOM.bark).setRadius(4F);
SDF roots = new SDFSphere().setRadius(4F);
ROOTS = (SDFPrimitive) roots;
roots = new SDFScale3D().setScale(1, 0.7F, 1).setSource(roots);
ROOTS = (SDFFlatWave) new SDFFlatWave().setRaysCount(5).setIntensity(1.5F).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));
FUNCTION = new SDFSmoothUnion().setRadius(4).setSourceB(new SDFUnion().setSourceA(HEAD_POS).setSourceB(ROOTS_ROT));
REPLACE = (state) -> {
if (state.getBlock() != Blocks.END_STONE && state.isIn(BlockTagRegistry.END_GROUND)) {