Portal pos finding optimisation, Overworld island feature for portals
This commit is contained in:
parent
2c2757ba8e
commit
f42af8bd67
5 changed files with 30 additions and 6 deletions
|
@ -114,6 +114,11 @@ public class EndFeature {
|
|||
return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured);
|
||||
}
|
||||
|
||||
public static EndFeature makeOverworldIsland(String name, Feature<DefaultFeatureConfig> feature) {
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT);
|
||||
return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured);
|
||||
}
|
||||
|
||||
public Feature<?> getFeature() {
|
||||
return feature;
|
||||
}
|
||||
|
|
|
@ -17,21 +17,31 @@ import ru.betterend.util.sdf.primitive.SDFCapedCone;
|
|||
public class OverworldIslandFeature extends DefaultFeature {
|
||||
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(412);
|
||||
private static final Mutable CENTER = new Mutable();
|
||||
private static final SDF FUNCTION;
|
||||
private static final SDF ISLAND;
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
CENTER.set(pos);
|
||||
FUNCTION.fillRecursive(world, pos.down());
|
||||
ISLAND.fillRecursive(world, pos.down());
|
||||
return true;
|
||||
}
|
||||
|
||||
static {
|
||||
SDF cone = new SDFCapedCone().setRadius1(0).setRadius2(4).setHeight(4).setBlock(Blocks.STONE);
|
||||
SDF cone = new SDFCapedCone().setRadius1(0).setRadius2(6).setHeight(4).setBlock((pos) -> {
|
||||
if (pos.getY() == CENTER.getY()) return Blocks.GRASS_BLOCK.getDefaultState();
|
||||
if (pos.getY() == CENTER.getY() - 1) {
|
||||
return Blocks.DIRT.getDefaultState();
|
||||
} else if (pos.getY() == CENTER.getY() - Math.round(2.0 * Math.random())) {
|
||||
return Blocks.DIRT.getDefaultState();
|
||||
}
|
||||
return Blocks.STONE.getDefaultState();
|
||||
});
|
||||
cone = new SDFTranslate().setTranslate(0, -3, 0).setSource(cone);
|
||||
cone = new SDFDisplacement().setFunction((pos) -> {
|
||||
return (float) NOISE.eval(CENTER.getX() + pos.getX(), CENTER.getY() + pos.getY(), CENTER.getZ() + pos.getZ());
|
||||
}).setSource(cone).setReplaceFunction(state -> {
|
||||
return state.isOf(Blocks.WATER) || state.getMaterial().isReplaceable();
|
||||
});
|
||||
FUNCTION = cone;
|
||||
ISLAND = cone;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue