Fix: Sandwich slices

This commit is contained in:
N-Nachtigal 2025-05-30 01:03:33 +02:00
parent 5cfbea5f51
commit ef52910688
3 changed files with 759 additions and 753 deletions

File diff suppressed because it is too large Load diff

View file

@ -9,21 +9,21 @@ minetest.register_node("ma_pops_furniture:toaster", {
"mp_toas_right.png", "mp_toas_right.png",
"mp_toas_left.png", "mp_toas_left.png",
"mp_toas_back.png", "mp_toas_back.png",
"mp_toas_front.png" "mp_toas_front.png",
}, },
walkable = false, walkable = false,
groups = { snappy=3 }, groups = { snappy = 3 },
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.375, -0.5, 0, 0.375, -0.0625, 0.3125}, { -0.375, -0.5, 0, 0.375, -0.0625, 0.3125 },
{-0.4375, -0.1875, 0.0625, -0.375, -0.125, 0.25}, { -0.4375, -0.1875, 0.0625, -0.375, -0.125, 0.25 },
}, },
}, },
}) })
local function breadslice_on_use(itemstack, user, pointed_thing) local function breadslice_on_use(itemstack, user, pointed_thing)
@ -38,10 +38,10 @@ local function breadslice_on_use(itemstack, user, pointed_thing)
if node and pos and (node.name == "ma_pops_furniture:toaster") then if node and pos and (node.name == "ma_pops_furniture:toaster") then
if minetest.is_protected(pos, pname) then if minetest.is_protected(pos, pname) then
minetest.record_protection_violation(pos, pname) minetest.record_protection_violation(pos, pname)
else else
if itemstack:get_count() >= 2 then if itemstack:get_count() >= 2 then
itemstack:take_item(2) itemstack:take_item(2)
minetest.set_node(pos, {name = "ma_pops_furniture:toaster_with_breadslice", param2 = node.param2}) minetest.set_node(pos, { name = "ma_pops_furniture:toaster_with_breadslice", param2 = node.param2 })
return itemstack return itemstack
end end
end end
@ -51,13 +51,16 @@ local function breadslice_on_use(itemstack, user, pointed_thing)
end end
if minetest.registered_items["farming:bread_slice"] then if minetest.registered_items["farming:bread_slice"] then
minetest.override_item("farming:bread_slice", {on_use = breadslice_on_use }) minetest.override_item("farming:bread_slice", { on_use = breadslice_on_use })
minetest.register_alias("ma_pops_furniture:breadslice", "farming:bread_slice") minetest.register_alias("ma_pops_furniture:breadslice", "farming:bread_slice")
elseif minetest.registered_items["sandwiches:bread_slice"] then
minetest.override_item("sandwiches:bread_slice", { on_use = breadslice_on_use })
minetest.register_alias("ma_pops_furniture:breadslice", "sandwiches:bread_slice")
else else
minetest.register_craftitem("ma_pops_furniture:breadslice", { minetest.register_craftitem("ma_pops_furniture:breadslice", {
description = S("Slice of Bread"), description = S("Slice of Bread"),
inventory_image = "mp_breadslice.png", inventory_image = "mp_breadslice.png",
groups = {flammable = 2}, groups = { flammable = 2 },
on_use = breadslice_on_use, on_use = breadslice_on_use,
}) })
end end
@ -69,7 +72,7 @@ else
description = S("Toast"), description = S("Toast"),
inventory_image = "mp_toast.png", inventory_image = "mp_toast.png",
on_use = minetest.item_eat(3), on_use = minetest.item_eat(3),
groups = {flammable = 2}, groups = { flammable = 2 },
}) })
end end
@ -81,10 +84,10 @@ minetest.register_node("ma_pops_furniture:toaster_with_breadslice", {
"mp_toas_right_bread.png", "mp_toas_right_bread.png",
"mp_toas_left_bread.png", "mp_toas_left_bread.png",
"mp_toas_back_bread.png", "mp_toas_back_bread.png",
"mp_toas_front_bread.png" "mp_toas_front_bread.png",
}, },
walkable = false, walkable = false,
groups = {not_in_creative_inventory=1}, groups = { not_in_creative_inventory = 1 },
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
@ -93,10 +96,10 @@ minetest.register_node("ma_pops_furniture:toaster_with_breadslice", {
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.375, -0.5, 0, 0.375, -0.0625, 0.3125}, -- NodeBox1 { -0.375, -0.5, 0, 0.375, -0.0625, 0.3125 }, -- NodeBox1
{-0.25, -0.0625, 0.0625, 0.25, 0.0625, 0.125}, -- NodeBox2 { -0.25, -0.0625, 0.0625, 0.25, 0.0625, 0.125 }, -- NodeBox2
{-0.25, -0.0625, 0.1875, 0.25, 0.0625, 0.25}, -- NodeBox3 { -0.25, -0.0625, 0.1875, 0.25, 0.0625, 0.25 }, -- NodeBox3
{-0.4375, -0.1875, 0.0625, -0.375, -0.125, 0.25}, -- NodeBox4 { -0.4375, -0.1875, 0.0625, -0.375, -0.125, 0.25 }, -- NodeBox4
}, },
}, },
on_punch = function(pos, node, clicker, itemstack, pointed_thing) on_punch = function(pos, node, clicker, itemstack, pointed_thing)
@ -106,10 +109,10 @@ minetest.register_node("ma_pops_furniture:toaster_with_breadslice", {
minetest.sound_play("toaster", { minetest.sound_play("toaster", {
pos = pos, pos = pos,
gain = 1.0, gain = 1.0,
max_hear_distance = 5 max_hear_distance = 5,
}) })
return itemstack return itemstack
end end,
}) })
minetest.register_node("ma_pops_furniture:toaster_toasting_breadslice", { minetest.register_node("ma_pops_furniture:toaster_toasting_breadslice", {
@ -120,10 +123,10 @@ minetest.register_node("ma_pops_furniture:toaster_toasting_breadslice", {
"mp_toas_right_bread.png", "mp_toas_right_bread.png",
"mp_toas_left_toast_side.png", "mp_toas_left_toast_side.png",
"mp_toas_back_side.png", "mp_toas_back_side.png",
"mp_toas_front_side.png" "mp_toas_front_side.png",
}, },
walkable = false, walkable = false,
groups = {not_in_creative_inventory = 1 }, groups = { not_in_creative_inventory = 1 },
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
@ -132,24 +135,24 @@ minetest.register_node("ma_pops_furniture:toaster_toasting_breadslice", {
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.375, -0.5, 0, 0.375, -0.0625, 0.3125}, -- NodeBox1 { -0.375, -0.5, 0, 0.375, -0.0625, 0.3125 }, -- NodeBox1
{-0.4375, -0.375, 0.0625, -0.375, -0.3125, 0.25}, -- NodeBox4 { -0.4375, -0.375, 0.0625, -0.375, -0.3125, 0.25 }, -- NodeBox4
}, },
}, },
}) })
minetest.register_node("ma_pops_furniture:toaster_with_toast", { minetest.register_node("ma_pops_furniture:toaster_with_toast", {
description = S("Toaster with Toast"), description = S("Toaster with Toast"),
tiles = { tiles = {
"mp_toas_top_toast.png", "mp_toas_top_toast.png",
"mp_toas_bottom.png", "mp_toas_bottom.png",
"mp_toas_right_toast.png", "mp_toas_right_toast.png",
"mp_toas_left_toast.png", "mp_toas_left_toast.png",
"mp_toas_back_toast.png", "mp_toas_back_toast.png",
"mp_toas_front_toast.png" "mp_toas_front_toast.png",
}, },
walkable = false, walkable = false,
groups = { snappy=3, not_in_creative_inventory=1 }, groups = { snappy = 3, not_in_creative_inventory = 1 },
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
@ -157,21 +160,22 @@ minetest.register_node("ma_pops_furniture:toaster_with_toast", {
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.375, -0.5, 0, 0.375, -0.0625, 0.3125}, -- NodeBox1 { -0.375, -0.5, 0, 0.375, -0.0625, 0.3125 }, -- NodeBox1
{-0.25, -0.0625, 0.0625, 0.25, 0.0625, 0.125}, -- NodeBox2 { -0.25, -0.0625, 0.0625, 0.25, 0.0625, 0.125 }, -- NodeBox2
{-0.25, -0.0625, 0.1875, 0.25, 0.0625, 0.25}, -- NodeBox3 { -0.25, -0.0625, 0.1875, 0.25, 0.0625, 0.25 }, -- NodeBox3
{-0.4375, -0.1875, 0.0625, -0.375, -0.125, 0.25}, -- NodeBox4 { -0.4375, -0.1875, 0.0625, -0.375, -0.125, 0.25 }, -- NodeBox4
}, },
}, },
on_punch = function (pos, node, player, pointed_thing) on_punch = function(pos, node, player, pointed_thing)
local inv = player:get_inventory() local inv = player:get_inventory()
local left = inv:add_item("main", "ma_pops_furniture:toast 2") local left = inv:add_item("main", "ma_pops_furniture:toast 2")
if left:is_empty() then if left:is_empty() then
minetest.set_node(pos, {name = "ma_pops_furniture:toaster", param2 = node.param2}) minetest.set_node(pos, { name = "ma_pops_furniture:toaster", param2 = node.param2 })
end end
end end,
}) })
--[[
--Slice of Bread (only if not farming one used) --Slice of Bread (only if not farming one used)
if not minetest.registered_items["farming:bread_slice"] then if not minetest.registered_items["farming:bread_slice"] then
minetest.register_craft({ minetest.register_craft({
@ -180,4 +184,5 @@ if not minetest.registered_items["farming:bread_slice"] then
recipe = {"farming:bread", "ma_pops_furniture:knife"}, recipe = {"farming:bread", "ma_pops_furniture:knife"},
replacements = {{"ma_pops_furniture:knife", "ma_pops_furniture:knife"}}, replacements = {{"ma_pops_furniture:knife", "ma_pops_furniture:knife"}},
}) })
end end ]]
--

View file

@ -51,8 +51,8 @@ minetest.register_craftitem("sandwiches:bread_slice", {
minetest.register_craft({ minetest.register_craft({
output = "sandwiches:bread_slice 4", output = "sandwiches:bread_slice 4",
type = "shapeless", type = "shapeless",
recipe = {"group:food_bread", "group:food_cutting_board", ""}, recipe = {"group:food_bread", board, ""},
replacements = { {"group:food_cutting_board", board }, } replacements = { {board, board }, }
}) })
minetest.register_craftitem("sandwiches:bread_crumbs", { minetest.register_craftitem("sandwiches:bread_crumbs", {