diff --git a/api/register_machine.lua b/api/register_machine.lua index b4ca658..1108ffb 100644 --- a/api/register_machine.lua +++ b/api/register_machine.lua @@ -82,6 +82,7 @@ function api.register_machine(name, def) is_ground_content = false, groups = def.groups, sounds = def.sounds, + drop = def.drop, after_place_node = function(pos, placer, itemstack) local meta = minetest.get_meta(pos) diff --git a/modules/anvil/anvil.lua b/modules/anvil/anvil.lua index fca2e8b..b1ccb08 100644 --- a/modules/anvil/anvil.lua +++ b/modules/anvil/anvil.lua @@ -4,6 +4,7 @@ local FS = function(...) return F(S(...)) end local anvil = cottages.anvil +local ci = cottages.craftitems local add_entity = minetest.add_entity local get_node = minetest.get_node @@ -29,6 +30,7 @@ local hud_timeout = cottages.settings.anvil.hud_timeout local stamina_use = cottages.settings.anvil.stamina local tool_entity_enabled = cottages.settings.anvil.tool_entity_enabled local tool_entity_displacement = cottages.settings.anvil.tool_entity_displacement +local destroy_when_dug = cottages.settings.anvil.destroy_when_dug local hud_info_by_puncher_name = {} @@ -444,6 +446,18 @@ function anvil.preserve_metadata(pos, oldnode, oldmeta, drops) return drops end +local drop + +if destroy_when_dug then + drop = { + items = { + { + items = { ci.steel .. " 7" }, + }, + }, + } +end + cottages.api.register_machine("cottages:anvil", { description = S("anvil"), drawtype = "nodebox", @@ -460,6 +474,7 @@ cottages.api.register_machine("cottages:anvil", { tiles = { "cottages_stone.png^[colorize:#000:192" }, groups = { cracky = 2 }, sounds = cottages.sounds.metal, + drop = drop, inv_info = { input = 1, diff --git a/modules/anvil/crafts.lua b/modules/anvil/crafts.lua index ce3c6d1..4cf1e98 100644 --- a/modules/anvil/crafts.lua +++ b/modules/anvil/crafts.lua @@ -1,16 +1,18 @@ local S = cottages.S local ci = cottages.craftitems -if ci.steel then +if ci.steelblock then minetest.register_craft({ output = "cottages:anvil", recipe = { - { ci.steel, ci.steel, ci.steel }, - { "", ci.steel, "" }, - { ci.steel, ci.steel, ci.steel }, + { ci.steelblock, ci.steelblock, ci.steelblock }, + { "", ci.steelblock, "" }, + { ci.steelblock, ci.steelblock, ci.steelblock }, }, }) +end +if ci.steel then minetest.register_craft({ output = "cottages:hammer", recipe = { diff --git a/resources/craftitems.lua b/resources/craftitems.lua index fc293af..8c49475 100644 --- a/resources/craftitems.lua +++ b/resources/craftitems.lua @@ -24,6 +24,7 @@ if has.default then ci.rail = resolve_item("default:rail") ci.sand = resolve_item("default:sand") ci.steel = resolve_item("default:steel_ingot") + ci.steelblock = resolve_item("default:steelblock") ci.stone = resolve_item("default:stone") end diff --git a/settingtypes.txt b/settingtypes.txt index cc0f7e4..4508a23 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -28,6 +28,9 @@ cottages.anvil.tool_entity_enabled (tool entity enabled) bool false # how far above the anvil to put the entity cottages.anvil.tool_entity_displacement (tool entity displacement) float .125 +# if true, the anvil is destroyed when dug, though it does drop some iron. +cottages.anvil.destroy_when_dug (destroy anvil when dug) bool true + ############################################################################### # provides a barrel which can be used to store liquids, and a couple decorative variants.