mirror of
https://github.com/minetest/minetest.git
synced 2024-11-20 14:43:45 +01:00
Fix blockseed for on_generated in mapgen env
This commit is contained in:
parent
a7a719261e
commit
02f40e5b0d
@ -692,7 +692,7 @@ void *EmergeThread::run()
|
|||||||
"EmergeThread: Lua on_generated", SPT_AVG);
|
"EmergeThread: Lua on_generated", SPT_AVG);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m_script->on_generated(&bmdata);
|
m_script->on_generated(&bmdata, m_mapgen->blockseed);
|
||||||
} catch (const LuaError &e) {
|
} catch (const LuaError &e) {
|
||||||
m_server->setAsyncFatalError(e);
|
m_server->setAsyncFatalError(e);
|
||||||
error = true;
|
error = true;
|
||||||
|
@ -50,6 +50,7 @@ class ModApiMapgen;
|
|||||||
// Structure containing inputs/outputs for chunk generation
|
// Structure containing inputs/outputs for chunk generation
|
||||||
struct BlockMakeData {
|
struct BlockMakeData {
|
||||||
MMVManip *vmanip = nullptr;
|
MMVManip *vmanip = nullptr;
|
||||||
|
// Global map seed
|
||||||
u64 seed = 0;
|
u64 seed = 0;
|
||||||
v3s16 blockpos_min;
|
v3s16 blockpos_min;
|
||||||
v3s16 blockpos_max;
|
v3s16 blockpos_max;
|
||||||
|
@ -167,6 +167,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
class Mapgen {
|
class Mapgen {
|
||||||
public:
|
public:
|
||||||
|
// Seed used for noises (truncated from the map seed)
|
||||||
s32 seed = 0;
|
s32 seed = 0;
|
||||||
int water_level = 0;
|
int water_level = 0;
|
||||||
int mapgen_limit = 0;
|
int mapgen_limit = 0;
|
||||||
@ -180,6 +181,7 @@ public:
|
|||||||
EmergeParams *m_emerge = nullptr;
|
EmergeParams *m_emerge = nullptr;
|
||||||
const NodeDefManager *ndef = nullptr;
|
const NodeDefManager *ndef = nullptr;
|
||||||
|
|
||||||
|
// Chunk-specific seed used to place ores and decorations
|
||||||
u32 blockseed;
|
u32 blockseed;
|
||||||
s16 *heightmap = nullptr;
|
s16 *heightmap = nullptr;
|
||||||
biome_t *biomemap = nullptr;
|
biome_t *biomemap = nullptr;
|
||||||
|
@ -45,7 +45,7 @@ void ScriptApiMapgen::on_shutdown()
|
|||||||
runCallbacks(0, RUN_CALLBACKS_MODE_FIRST);
|
runCallbacks(0, RUN_CALLBACKS_MODE_FIRST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptApiMapgen::on_generated(BlockMakeData *bmdata)
|
void ScriptApiMapgen::on_generated(BlockMakeData *bmdata, u32 seed)
|
||||||
{
|
{
|
||||||
SCRIPTAPI_PRECHECKHEADER
|
SCRIPTAPI_PRECHECKHEADER
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ void ScriptApiMapgen::on_generated(BlockMakeData *bmdata)
|
|||||||
lua_pushvalue(L, vmanip);
|
lua_pushvalue(L, vmanip);
|
||||||
push_v3s16(L, minp);
|
push_v3s16(L, minp);
|
||||||
push_v3s16(L, maxp);
|
push_v3s16(L, maxp);
|
||||||
lua_pushnumber(L, bmdata->seed);
|
lua_pushnumber(L, seed);
|
||||||
runCallbacks(4, RUN_CALLBACKS_MODE_FIRST);
|
runCallbacks(4, RUN_CALLBACKS_MODE_FIRST);
|
||||||
lua_pop(L, 1); // return val
|
lua_pop(L, 1); // return val
|
||||||
|
|
||||||
|
@ -35,6 +35,6 @@ public:
|
|||||||
void on_mods_loaded();
|
void on_mods_loaded();
|
||||||
void on_shutdown();
|
void on_shutdown();
|
||||||
|
|
||||||
// Called after generating a piece of map before writing it to the map
|
// Called after generating a piece of map, before writing it to the map
|
||||||
void on_generated(BlockMakeData *bmdata);
|
void on_generated(BlockMakeData *bmdata, u32 seed);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user