Add default crafting config values

This commit is contained in:
Kae 2023-07-24 22:11:45 +10:00
parent c127b50303
commit 4c636e911c
2 changed files with 14 additions and 2 deletions

View File

@ -0,0 +1,10 @@
// Default config for all crafting interfaces, vanilla and modded.
{ "default" : {
// Disables the crafting timer if true.
"disableTimer" : false,
// This is only used if the crafting timer is enabled.
// This is how many crafts are ran when the crafting timer wraps.
"craftCount" : 1
} }

View File

@ -38,7 +38,9 @@ CraftingPane::CraftingPane(WorldClientPtr worldClient, PlayerPtr player, Json co
auto assets = Root::singleton().assets();
// get the config data for this crafting pane, default to "bare hands" crafting
auto baseConfig = settings.get("config", "/interface/windowconfig/crafting.config");
m_settings = jsonMerge(assets->fetchJson(baseConfig), settings);
m_settings = jsonMerge(assets->json("/interface/windowconfig/crafting.config:default"),
jsonMerge(assets->fetchJson(baseConfig), settings));
m_filter = StringSet::from(jsonToStringList(m_settings.get("filter", JsonArray())));
GuiReader reader;
@ -266,7 +268,7 @@ void CraftingPane::update(float dt) {
// crafters gonna craft
while (m_crafting && m_craftTimer.wrapTick()) {
craft(1);
craft(min(m_count, (int)m_settings.getInt("craftCount", 1)));
}
// update crafting icon, progress and buttons