diff --git a/mods/CORE/CraftSystem/src/CraftSystem.lua b/mods/CORE/CraftSystem/src/CraftSystem.lua index e6c1b9a..8b56503 100644 --- a/mods/CORE/CraftSystem/src/CraftSystem.lua +++ b/mods/CORE/CraftSystem/src/CraftSystem.lua @@ -205,9 +205,19 @@ end ---@return boolean check true if craft can be produced ---@return ItemStack[] materialStacks list of itemStacks for crafting function CraftSystem:checkPossiblePlayerInventoryCrafting(player, craft, recipeIndex, count) + local OutputStack = ItemStack(craft.output) + + if count <= 0 then + Logger.warningLog('`CraftSystem:checkPossiblePlayerInventoryCrafting()`: param `count` <= 0. '.. + 'Was force-reset to `1`. '.. + 'Info: value: `%s`, player: `%s`, craft: `%s`', + count, player:get_player_name(), craft.name + ) + count = 1 + end + local inventory = player:get_inventory() - local OutputStack = ItemStack(craft.output) OutputStack:set_count(OutputStack:get_count() * count) local materialStacks, materialGroups = getMaterials(craft, recipeIndex, count) diff --git a/mods/CORE/CraftSystem/src/CraftSystem/ImmersiveCraft.lua b/mods/CORE/CraftSystem/src/CraftSystem/ImmersiveCraft.lua index b0d27f5..ca2fd33 100644 --- a/mods/CORE/CraftSystem/src/CraftSystem/ImmersiveCraft.lua +++ b/mods/CORE/CraftSystem/src/CraftSystem/ImmersiveCraft.lua @@ -83,6 +83,15 @@ end ---@param amount integer ---@return boolean function ImmersiveCraft:startCraft(pos, player, amount) + if amount <= 0 then + Logger.warningLog('`ImmersiveCraft:startCraft()`: param `amount` <= 0. '.. + 'Was force-reset to `1`. '.. + 'Info: value: `%s`, player: `%s`, craft: `%s`', + amount, player:get_player_name(), self.name + ) + amount = 1 + end + local workStation = Smc.getNodeSuperclassByPos(pos) --[[@as ImmersiveWorkStation?]] assert(workStation ~= nil) @@ -124,7 +133,7 @@ function ImmersiveCraft:endCraft(pos, player) local playerName = meta:get_string('player_name') assert(playerName ~= '') local amount = meta:get_float('craft_amount') - assert(amount ~= 0) + assert(amount > 0) -- Drop the result of crafting. local dropPos = v(pos) + v(0, 0.9,0) diff --git a/mods/CORE/CraftSystem/src/CraftSystem/ImmersiveCraftStage/TappingStage.lua b/mods/CORE/CraftSystem/src/CraftSystem/ImmersiveCraftStage/TappingStage.lua index fe0c280..f513f4e 100644 --- a/mods/CORE/CraftSystem/src/CraftSystem/ImmersiveCraftStage/TappingStage.lua +++ b/mods/CORE/CraftSystem/src/CraftSystem/ImmersiveCraftStage/TappingStage.lua @@ -129,7 +129,7 @@ function TappingStage:new(def) assert(stageData ~= nil) local amount = meta:get_float('craft_amount') - assert(amount ~= 0) + assert(amount > 0) ---@type CraftSystem.ImmersiveCraftStage.TappingStageData? local stageData = stageData diff --git a/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI.lua b/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI.lua index 45a3336..c0bedc8 100644 --- a/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI.lua +++ b/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI.lua @@ -646,7 +646,7 @@ PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::%S+::craft_item', functio end Smc.putOrDrop(player, inventory, craft.output) - elseif tabName == 'node_tab' and allowCrafting and handler.baseType == 'immersive' then + elseif allowCrafting and tabName == 'node_tab' and handler.baseType == 'immersive' then ---@type CraftSystem.ImmersiveCraft craft = craft local inventory = player:get_inventory()