From 08701bca3c82b9605325d2db9d0317ff2b450913 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 5 Dec 2023 20:22:38 +0300 Subject: [PATCH] Added trees conversion function for old worlds (F9) --- src/frontend/screens.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/frontend/screens.cpp b/src/frontend/screens.cpp index 5de28c4a..6419efc8 100644 --- a/src/frontend/screens.cpp +++ b/src/frontend/screens.cpp @@ -32,6 +32,9 @@ #include "gui/panels.h" #include "menu.h" +#include "../content/Content.h" +#include "../voxels/Block.h" + using std::string; using std::wstring; using glm::vec3; @@ -125,6 +128,23 @@ void LevelScreen::updateHotkeys() { if (Events::jpressed(keycode::F5)) { level->chunks->saveAndClear(); } + + // TODO: remove in v0.16 + if (Events::jpressed(keycode::F9)) { + blockid_t woodid = level->content->require("base:wood")->rt.id; + for (size_t i = 0; i < level->chunks->volume; i++){ + Chunk* chunk = level->chunks->chunks[i].get(); + if (chunk) { + for (uint i = 0; i < CHUNK_VOL; i++) { + auto& vox = chunk->voxels[i]; + if (vox.id == woodid) { + vox.states = BLOCK_DIR_UP; + } + } + } + } + level->chunks->saveAndClear(); + } } void LevelScreen::update(float delta) {