From b12d242335a2c34e1f891df956a76de8aed53124 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 18 Jan 2024 04:41:35 +0300 Subject: [PATCH] Block.scriptName, ItemDef.scriptName --- src/content/ContentLoader.cpp | 6 ++++-- src/items/ItemDef.h | 1 + src/voxels/Block.h | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/content/ContentLoader.cpp b/src/content/ContentLoader.cpp index 20050e58..5fccd3a6 100644 --- a/src/content/ContentLoader.cpp +++ b/src/content/ContentLoader.cpp @@ -172,6 +172,7 @@ void ContentLoader::loadBlock(Block* def, std::string name, fs::path file) { root->flag("sky-light-passing", def->skyLightPassing); root->num("draw-group", def->drawGroup); root->str("picking-item", def->pickingItem); + root->str("script-name", def->scriptName); } void ContentLoader::loadCustomBlockModel(Block* def, dynamic::Map* primitives) { @@ -233,6 +234,7 @@ void ContentLoader::loadItem(ItemDef* def, std::string name, fs::path file) { } root->str("icon", def->icon); root->str("placing-block", def->placingBlock); + root->str("script-name", def->scriptName); root->num("stack-size", def->stackSize); // item light emission [r, g, b] where r,g,b in range [0..15] @@ -248,7 +250,7 @@ void ContentLoader::loadBlock(Block* def, std::string full, std::string name) { auto folder = pack->folder; fs::path configFile = folder/fs::path("blocks/"+name+".json"); - fs::path scriptfile = folder/fs::path("scripts/"+name+".lua"); + fs::path scriptfile = folder/fs::path("scripts/"+def->scriptName+".lua"); loadBlock(def, full, configFile); if (fs::is_regular_file(scriptfile)) { scripting::load_block_script(full, scriptfile, &def->rt.funcsset); @@ -259,7 +261,7 @@ void ContentLoader::loadItem(ItemDef* def, std::string full, std::string name) { auto folder = pack->folder; fs::path configFile = folder/fs::path("items/"+name+".json"); - fs::path scriptfile = folder/fs::path("scripts/"+name+".lua"); + fs::path scriptfile = folder/fs::path("scripts/"+def->scriptName+".lua"); loadItem(def, full, configFile); if (fs::is_regular_file(scriptfile)) { scripting::load_item_script(full, scriptfile, &def->rt.funcsset); diff --git a/src/items/ItemDef.h b/src/items/ItemDef.h index 1bcb97df..501af70a 100644 --- a/src/items/ItemDef.h +++ b/src/items/ItemDef.h @@ -30,6 +30,7 @@ public: std::string icon = "blocks:notfound"; std::string placingBlock = "core:air"; + std::string scriptName = name.substr(name.find(':')+1); struct { itemid_t id; diff --git a/src/voxels/Block.h b/src/voxels/Block.h index 4bd0bf79..9f55f1c7 100644 --- a/src/voxels/Block.h +++ b/src/voxels/Block.h @@ -81,7 +81,7 @@ public: std::vector modelExtraPoints = {}; //initially made for tetragons std::vector modelUVs = {}; // boxes' tex-UVs also there uint8_t emission[4] {0, 0, 0, 0}; - unsigned char drawGroup = 0; + ubyte drawGroup = 0; BlockModel model = BlockModel::block; bool lightPassing = false; bool skyLightPassing = false; @@ -95,6 +95,7 @@ public: AABB hitbox; BlockRotProfile rotations; std::string pickingItem = name+BLOCK_ITEM_SUFFIX; + std::string scriptName = name.substr(name.find(':')+1); struct { blockid_t id;