}
-void OreScatter::generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) {
+void Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) {
int in_range = 0;
in_range |= (nmin.Y <= height_max && nmax.Y >= height_min);
resolveNodeNames(mg->ndef);
- MapNode n_ore(ore);
- ManualMapVoxelManipulator *vm = mg->vm;
- PseudoRandom pr(blockseed);
int ymin, ymax;
if (in_range & ORE_RANGE_MIRROR) {
if (clust_size >= ymax - ymin + 1)
return;
+ nmin.Y = ymin;
+ nmax.Y = ymax;
+ generate(mg->vm, mg->seed, blockseed, nmin, nmax);
+}
+
+
+void OreScatter::generate(ManualMapVoxelManipulator *vm, int seed,
+ u32 blockseed, v3s16 nmin, v3s16 nmax) {
+ PseudoRandom pr(blockseed);
+ MapNode n_ore(ore, 0, ore_param2);
+
int volume = (nmax.X - nmin.X + 1) *
(nmax.Y - nmin.Y + 1) *
(nmax.Z - nmin.Z + 1);
for (int i = 0; i != nclusters; i++) {
int x0 = pr.range(nmin.X, nmax.X - csize + 1);
- int y0 = pr.range(ymin, ymax - csize + 1);
+ int y0 = pr.range(nmin.Y, nmax.Y - csize + 1);
int z0 = pr.range(nmin.Z, nmax.Z - csize + 1);
- if (np && (NoisePerlin3D(np, x0, y0, z0, mg->seed) < nthresh))
+ if (np && (NoisePerlin3D(np, x0, y0, z0, seed) < nthresh))
continue;
for (int z1 = 0; z1 != csize; z1++)
}
-void OreSheet::generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) {
- int in_range = 0;
-
- in_range |= (nmin.Y <= height_max && nmax.Y >= height_min);
- if (flags & OREFLAG_ABSHEIGHT)
- in_range |= (nmin.Y >= -height_max && nmax.Y <= -height_min) << 1;
- if (!in_range)
- return;
-
- resolveNodeNames(mg->ndef);
-
- MapNode n_ore(ore);
- ManualMapVoxelManipulator *vm = mg->vm;
+void OreSheet::generate(ManualMapVoxelManipulator *vm, int seed,
+ u32 blockseed, v3s16 nmin, v3s16 nmax) {
PseudoRandom pr(blockseed + 4234);
- int ymin, ymax;
-
- if (in_range & ORE_RANGE_MIRROR) {
- ymin = MYMAX(nmin.Y, -height_max);
- ymax = MYMIN(nmax.Y, -height_min);
- } else {
- ymin = MYMAX(nmin.Y, height_min);
- ymax = MYMIN(nmax.Y, height_max);
- }
-
- if (clust_size >= ymax - ymin + 1)
- return;
-
- int x0 = nmin.X;
- int z0 = nmin.Z;
-
- int x1 = nmax.X;
- int z1 = nmax.Z;
+ MapNode n_ore(ore, 0, ore_param2);
int max_height = clust_size;
- int y_start = pr.range(ymin, ymax - max_height);
+ int y_start = pr.range(nmin.Y, nmax.Y - max_height);
if (!noise) {
int sx = nmax.X - nmin.X + 1;
int sz = nmax.Z - nmin.Z + 1;
noise = new Noise(np, 0, sx, sz);
}
- noise->seed = mg->seed + y_start;
- noise->perlinMap2D(x0, z0);
+ noise->seed = seed + y_start;
+ noise->perlinMap2D(nmin.X, nmin.Z);
int index = 0;
- for (int z = z0; z != z1; z++)
- for (int x = x0; x != x1; x++) {
+ for (int z = nmin.Z; z <= nmax.Z; z++)
+ for (int x = nmin.X; x <= nmax.X; x++) {
float noiseval = noise->result[index++];
if (noiseval < nthresh)
continue;
public:
std::string ore_name;
std::string wherein_name;
-
content_t ore;
content_t wherein; // the node to be replaced
u32 clust_scarcity; // ore cluster has a 1-in-clust_scarcity chance of appearing at a node
s16 clust_size; // how large (in nodes) a chunk of ore is
s16 height_min;
s16 height_max;
+ u8 ore_param2; // to set node-specific attributes
u32 flags; // attributes for this ore
float nthresh; // threshhold for noise at which an ore is placed
NoiseParams *np; // noise for distribution of clusters (NULL for uniform scattering)
}
void resolveNodeNames(INodeDefManager *ndef);
- virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;
+ void placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
+ virtual void generate(ManualMapVoxelManipulator *vm, int seed,
+ u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;
};
class OreScatter : public Ore {
- void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
+ virtual void generate(ManualMapVoxelManipulator *vm, int seed,
+ u32 blockseed, v3s16 nmin, v3s16 nmax);
};
class OreSheet : public Ore {
- void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
+ virtual void generate(ManualMapVoxelManipulator *vm, int seed,
+ u32 blockseed, v3s16 nmin, v3s16 nmax);
};
Ore *createOre(OreType type);