Ice stars update
This commit is contained in:
parent
0ddc5e44eb
commit
a6b778b9d7
2 changed files with 38 additions and 32 deletions
|
@ -5,14 +5,12 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.util.sdf.operator.SDFRotation;
|
||||
|
@ -40,7 +38,7 @@ public class IceStarFeature extends DefaultFeature {
|
|||
int count = MHelper.randRange(minCount, maxCount, random);
|
||||
List<Vector3f> points = getFibonacciPoints(count);
|
||||
SDF sdf = null;
|
||||
SDF spike = new SDFCapedCone().setRadius1(3 + (size - 5) * 0.2F).setRadius2(0).setHeight(size).setBlock(Blocks.ICE);
|
||||
SDF spike = new SDFCapedCone().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;
|
||||
|
@ -60,29 +58,31 @@ public class IceStarFeature extends DefaultFeature {
|
|||
int z1 = (pos.getZ() >> 4) << 4;
|
||||
pos = new BlockPos(x1 + random.nextInt(16), MHelper.randRange(32, 128, random), z1 + random.nextInt(16));
|
||||
|
||||
OpenSimplexNoise noise1 = new OpenSimplexNoise(random.nextLong());
|
||||
OpenSimplexNoise noise2 = new OpenSimplexNoise(random.nextLong());
|
||||
final float ancientRadius = size * 0.45F;
|
||||
final float denseRadius = size * 0.8F;
|
||||
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.getDefaultState();
|
||||
final BlockState dense = EndBlocks.DENSE_EMERALD_ICE.getDefaultState();
|
||||
final BlockState ancient = EndBlocks.ANCIENT_EMERALD_ICE.getDefaultState();
|
||||
final SDF sdfCopy = sdf;
|
||||
|
||||
final boolean hasSnow = random.nextBoolean();
|
||||
BlockState layer = Blocks.SNOW.getDefaultState();
|
||||
BlockState snow = Blocks.SNOW_BLOCK.getDefaultState();
|
||||
BlockState blue = Blocks.BLUE_ICE.getDefaultState();
|
||||
BlockState packed = Blocks.PACKED_ICE.getDefaultState();
|
||||
sdf.setPostProcess((info) -> {
|
||||
BlockPos bpos = info.getPos();
|
||||
|
||||
if (!info.getState().isOf(Blocks.SNOW)) {
|
||||
if (hasSnow && info.getStateUp().isAir()) {
|
||||
info.setBlockPos(bpos.up(), layer.with(Properties.LAYERS, MHelper.randRange(1, 3, random)));
|
||||
return snow;
|
||||
}
|
||||
|
||||
if (noise1.eval(bpos.getX() * 0.1, bpos.getY() * 0.1, bpos.getZ() * 0.1) > 0.3) {
|
||||
return packed;
|
||||
}
|
||||
else if (noise2.eval(bpos.getX() * 0.1, bpos.getY() * 0.1, bpos.getZ() * 0.1) > 0.3) {
|
||||
return blue;
|
||||
}
|
||||
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.1F + random.nextFloat() * randScale;
|
||||
if (distance < ancientRadius) {
|
||||
return ancient;
|
||||
}
|
||||
else if (distance < denseRadius) {
|
||||
return dense;
|
||||
}
|
||||
else if (distance < iceRadius) {
|
||||
return ice;
|
||||
}
|
||||
return info.getState();
|
||||
}).fillRecursive(world, pos);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue