Items can cool in storeboxes, but not cook

Cooking recipes run in all visinv nodes, not just
item stacks, BUT non-stack-only nodes (i.e. all
storeboxes) block flame touchgroups so things
in boxes cannot be heated/melted.

This allows items dropped into boxes from ore
melting to cool, but prevents sand from being
melted in a box which would naively replace
the box with the molten glass entirely.

This also fixes an old rumored bug where forcing
glowing lode items into a shelf with a door would
cause them to stay hot indefinitely.

N.B. lode cooking/cooling used to assume it could
replace the entire node, and deleted the thing
as a fail-safe when an item of the given temper
was not found (e.g. tools w/ handles).  This is
now gone, and invalid tempers will throw errors
if they can ever be achieved in practice.
This commit is contained in:
Aaron Suen 2021-11-27 19:26:31 -05:00
parent 919eec3e1b
commit 9235744612
3 changed files with 14 additions and 7 deletions

View File

@ -47,6 +47,9 @@ local function craftcheck(recipe, pos, node, data, xx, xz, zx, zz)
addgroups(sum, rel(0, -1, 0))
addgroups(sum, rel(0, 0, 1))
addgroups(sum, rel(0, 0, -1))
if data.touchgroupmodify then
data.touchgroupmodify(sum)
end
for k, v in pairs(recipe.touchgroups) do
local w = sum[k] or 0
if v > 0 and w < v then return end

View File

@ -26,12 +26,17 @@ minetest.after(0, function()
end
end)
local function flameblock(sum) sum.flame = nil end
nodecore.register_dnt({
name = dntname,
time = 1,
nodenames = {modname .. ":stack"},
nodenames = {"group:visinv"},
action = function(pos, node)
node.stack = nodecore.stack_get(pos)
local data = nodecore.craft_cooking_data()
if minetest.get_item_group(node.name, "is_stack_only") == 0 then
data.touchgroupmodify = flameblock
end
nodecore.craft_check(pos, node, data)
if not data.progressing then
return minetest.get_meta(pos):set_string(modname, "")
@ -43,7 +48,7 @@ nodecore.register_dnt({
minetest.register_abm({
label = "item stack cook",
nodenames = {modname .. ":stack"},
nodenames = {"group:visinv"},
interval = 1,
chance = 1,
action = function(pos)

View File

@ -1,6 +1,6 @@
-- LUALOCALS < ---------------------------------------------------------
local ItemStack, minetest, nodecore, pairs, type
= ItemStack, minetest, nodecore, pairs, type
local ItemStack, error, minetest, nodecore, pairs, type
= ItemStack, error, minetest, nodecore, pairs, type
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
@ -104,14 +104,13 @@ local function replacestack(pos, alt)
local name = stack and stack:get_name() or node.name
local def = minetest.registered_items[name] or {}
alt = def["metal_alt_" .. alt]
if not alt then return nodecore.remove_node(pos) end
if not alt then return error("no " .. alt .. " alt for " .. name) end
if stack then
local repl = ItemStack(alt)
local qty = stack:get_count()
if qty == 0 then qty = 1 end
repl:set_count(qty * repl:get_count())
nodecore.remove_node(pos)
return nodecore.item_eject(pos, repl)
nodecore.stack_set(pos, repl)
else
nodecore.set_node(pos, {name = alt})
nodecore.fallcheck(pos)