diff --git a/mods/CORE/CraftSystem/src/CraftSystem/ImmersiveCraftStage/TappingStage.lua b/mods/CORE/CraftSystem/src/CraftSystem/ImmersiveCraftStage/TappingStage.lua index 42371b4..c142c04 100644 --- a/mods/CORE/CraftSystem/src/CraftSystem/ImmersiveCraftStage/TappingStage.lua +++ b/mods/CORE/CraftSystem/src/CraftSystem/ImmersiveCraftStage/TappingStage.lua @@ -11,6 +11,7 @@ local ImmersiveCraftStage = require('CraftSystem.ImmersiveCraftStage') ---@class CraftSystem.ImmersiveCraftStage.TappingStage : CraftSystem.ImmersiveCraftStage ---@field targetItem string ---@field clicksNeed string +---@field toolGroup string? ---@field startHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapPosition, Player:Player) ---@field processHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapPosition, Player:Player) ---@field endHandler fun(self:CraftSystem.ImmersiveCraftStage.TappingStage, pos:MapPosition, Player:Player) @@ -23,6 +24,7 @@ local TappingStage = extend(ImmersiveCraftStage, {}) ---@class CraftSystem.ImmersiveCraftStage.TappingStageDef : CraftSystem.ImmersiveCraftStageDef ---@field targetItem string ---@field clicksNeed string +---@field toolGroup string? ---Data table for transferring various time parameters between calls. --- @@ -39,6 +41,7 @@ function TappingStage:new(def) local instance = ImmersiveCraftStage:new(def) instance.targetItem = def.targetItem instance.clicksNeed = def.clicksNeed + instance.toolGroup = def.toolGroup -- Registering the crafting stage start handler. instance.startHandler = function(tappingStage , pos, player) @@ -143,7 +146,12 @@ function TappingStage:new(def) -- Returns a human-readable description of the crafting stage. instance.toString = function(tappingStage) - local stageDesc = ('Tapping x%s'):format(tappingStage.clicksNeed) + local stageDesc + if tappingStage.toolGroup ~= nil then + stageDesc = ('Tapping x%s tool with a group "%s"'):format(tappingStage.clicksNeed, tappingStage.toolGroup) + else + stageDesc = ('Tapping x%s'):format(tappingStage.clicksNeed) + end return stageDesc end @@ -151,7 +159,17 @@ function TappingStage:new(def) -- Subscribe to an event that means the player hit the entity. Events.subscribe(('craft_system:punch_tapping_node:%s:%s'):format(instance.craftName, instance.name), ---@param craftNode LuaEntity + ---@param player Player function(eventName, pos, player, craftNode) + -- We get the item that the player clicked on the crafting node. + local toolDef = player:get_wielded_item():get_definition() + + -- If a crafting stage requires a specific tool group and he doesn't have it... + if instance.toolGroup and (not toolDef.groups or not toolDef.groups[instance.toolGroup]) then + -- ...then we don't do anything. + return + end + -- DRAFT START: -- Creating particles for i=0, 10 do diff --git a/mods/CORE/WorkStation/src/WorkStation.lua b/mods/CORE/WorkStation/src/WorkStation.lua index 3ff05af..4447262 100644 --- a/mods/CORE/WorkStation/src/WorkStation.lua +++ b/mods/CORE/WorkStation/src/WorkStation.lua @@ -208,6 +208,7 @@ ImmersiveCraftHandler:registerCraft('bricks', { ---@type CraftSystem.ImmersiveCraftStage.TappingStageDef { name = 'tapping_2', + toolGroup = 'crushing', targetItem = 'rocks:sylite_block', type = 'tapping', clicksNeed = 5,