mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 12:31:51 +00:00
add 'on_block_present' event
This commit is contained in:
parent
1c81f8b7ad
commit
ca3bc45d0f
7 changed files with 113 additions and 41 deletions
|
|
@ -15,6 +15,7 @@
|
|||
#include "voxels/Chunks.hpp"
|
||||
#include "voxels/GlobalChunks.hpp"
|
||||
#include "world/Level.hpp"
|
||||
#include "world/LevelEvents.hpp"
|
||||
#include "world/World.hpp"
|
||||
#include "world/generator/WorldGenerator.hpp"
|
||||
|
||||
|
|
@ -172,13 +173,12 @@ void ChunksController::createChunk(const Player& player, int x, int z) const {
|
|||
auto chunk = level.chunks->create(x, z);
|
||||
player.chunks->putChunk(chunk);
|
||||
auto& chunkFlags = chunk->flags;
|
||||
|
||||
if (!chunkFlags.loaded) {
|
||||
generator->generate(chunk->voxels, x, z);
|
||||
chunkFlags.unsaved = true;
|
||||
}
|
||||
chunk->updateHeights();
|
||||
|
||||
level.events->trigger(LevelEventType::CHUNK_PRESENT, chunk.get());
|
||||
if (!chunkFlags.loadedLights) {
|
||||
Lighting::prebuildSkyLight(*chunk, *level.content.getIndices());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -675,6 +675,8 @@ void scripting::load_content_script(
|
|||
register_event(env, "on_block_tick", prefix + ".blocktick");
|
||||
funcsset.onblockstick =
|
||||
register_event(env, "on_blocks_tick", prefix + ".blockstick");
|
||||
funcsset.onblockpresent =
|
||||
register_event(env, "on_block_present", prefix + ".blockpresent");
|
||||
}
|
||||
|
||||
void scripting::load_content_script(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue