Start migration

This commit is contained in:
Aleksey 2021-04-08 21:55:07 +03:00
parent 6630ce0cab
commit 47ed597358
491 changed files with 12045 additions and 11953 deletions

View file

@ -2,10 +2,10 @@ package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.chunk.ChunkGenerator;
@ -20,15 +20,16 @@ import ru.betterend.util.sdf.operator.SDFTranslate;
import ru.betterend.util.sdf.primitive.SDFCappedCone;
public class BiomeIslandFeature extends DefaultFeature {
private static final Mutable CENTER = new Mutable();
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.getDefaultState();
private static BlockState underBlock = Blocks.DIRT.getDefaultState();
private static BlockState topBlock = Blocks.GRASS_BLOCK.defaultBlockState();
private static BlockState underBlock = Blocks.DIRT.defaultBlockState();
@Override
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
DefaultFeatureConfig config) {
Biome biome = world.getBiome(pos);
SurfaceConfig surfaceConfig = biome.getGenerationSettings().getSurfaceConfig();
BlockState topMaterial = surfaceConfig.getTopMaterial();
@ -40,14 +41,16 @@ public class BiomeIslandFeature extends DefaultFeature {
underBlock = surfaceConfig.getUnderMaterial();
simplexNoise = new OpenSimplexNoise(world.getSeed());
CENTER.set(pos);
ISLAND.fillRecursive(world, pos.down());
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);
@ -55,11 +58,12 @@ public class BiomeIslandFeature extends DefaultFeature {
float deltaX = Math.abs(pos.getX());
float deltaY = Math.abs(pos.getY());
float deltaZ = Math.abs(pos.getZ());
if (deltaY < 2.0f && (deltaX < 3.0f || deltaZ < 3.0F)) return 0.0f;
return (float) simplexNoise.eval(CENTER.getX() + pos.getX(),
CENTER.getY() + pos.getY(), CENTER.getZ() + pos.getZ());
}).setSource(sdfCone).setReplaceFunction(state -> BlocksHelper.isFluid(state) ||
state.getMaterial().isReplaceable());
if (deltaY < 2.0f && (deltaX < 3.0f || deltaZ < 3.0F))
return 0.0f;
return (float) simplexNoise.eval(CENTER.getX() + pos.getX(), CENTER.getY() + pos.getY(),
CENTER.getZ() + pos.getZ());
}).setSource(sdfCone)
.setReplaceFunction(state -> BlocksHelper.isFluid(state) || state.getMaterial().isReplaceable());
return sdfCone;
}