3 Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "util/string.h"
29 class ManualMapVoxelManipulator;
31 /////////////////// Ore generation flags
33 // Use absolute value of height to determine ore placement
34 #define OREFLAG_ABSHEIGHT 0x01
35 #define OREFLAG_USE_NOISE 0x08
37 #define ORE_RANGE_ACTUAL 1
38 #define ORE_RANGE_MIRROR 2
48 extern FlagDesc flagdesc_ore[];
50 class Ore : public GenElement, public NodeResolver {
52 static const bool NEEDS_NOISE = false;
54 content_t c_ore; // the node to place
55 std::vector<content_t> c_wherein; // the nodes to be placed in
56 u32 clust_scarcity; // ore cluster has a 1-in-clust_scarcity chance of appearing at a node
57 s16 clust_num_ores; // how many ore nodes are in a chunk
58 s16 clust_size; // how large (in nodes) a chunk of ore is
61 u8 ore_param2; // to set node-specific attributes
62 u32 flags; // attributes for this ore
63 float nthresh; // threshhold for noise at which an ore is placed
64 NoiseParams np; // noise for distribution of clusters (NULL for uniform scattering)
70 virtual void resolveNodeNames(NodeResolveInfo *nri);
72 size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
73 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
74 u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;
77 class OreScatter : public Ore {
79 static const bool NEEDS_NOISE = false;
81 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
82 u32 blockseed, v3s16 nmin, v3s16 nmax);
85 class OreSheet : public Ore {
87 static const bool NEEDS_NOISE = true;
89 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
90 u32 blockseed, v3s16 nmin, v3s16 nmax);
93 class OreBlob : public Ore {
95 static const bool NEEDS_NOISE = true;
97 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
98 u32 blockseed, v3s16 nmin, v3s16 nmax);
101 class OreVein : public Ore {
103 static const bool NEEDS_NOISE = true;
110 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
111 u32 blockseed, v3s16 nmin, v3s16 nmax);
114 class OreManager : public GenElementManager {
116 static const char *ELEMENT_TITLE;
117 static const size_t ELEMENT_LIMIT = 0x10000;
119 OreManager(IGameDef *gamedef);
122 Ore *create(int type)
125 case ORE_TYPE_SCATTER:
126 return new OreScatter;
140 size_t placeAllOres(Mapgen *mg, u32 seed, v3s16 nmin, v3s16 nmax);