use of net.minecraft.world.gen.stateprovider.BlockStateProvider in project Primeval by devs-immortal.
the class OreClusterFeature method generate.
@Override
public boolean generate(FeatureContext<OreClusterFeatureConfig> context) {
BlockPos blockPos = context.getOrigin();
StructureWorldAccess structureWorldAccess = context.getWorld();
Random random = context.getRandom();
OreClusterFeatureConfig config = context.getConfig();
BlockStateProvider largeState = config.largeState();
BlockStateProvider mediumState = config.mediumState();
BlockStateProvider smallState = config.smallState();
int radius = config.radius().get(random);
int height = config.height().get(random);
float density = config.density().get(random);
float richness = config.richness().get(random);
IntPoint2D[] circleCoords = ShapesUtil.getCoordinatesInCircle(radius);
float oreRichness;
for (IntPoint2D point : circleCoords) {
// for each height step
for (int y = 0; y < height; y++) {
// for each coord in circle
if (random.nextFloat() < density) {
// density check
oreRichness = (richness + ((random.nextFloat() * 2.0f) - 1.0f) * richness);
if (oreRichness > 0.75) {
setBlockIfAble(structureWorldAccess, point.getOffsetBlockPos(blockPos).up(y), largeState, random);
} else if (oreRichness > 0.3) {
setBlockIfAble(structureWorldAccess, point.getOffsetBlockPos(blockPos).up(y), mediumState, random);
} else {
setBlockIfAble(structureWorldAccess, point.getOffsetBlockPos(blockPos).up(y), smallState, random);
}
}
}
}
return true;
}
Aggregations