diff --git a/cooking.lua b/cooking.lua new file mode 100644 index 0000000..84e6165 --- /dev/null +++ b/cooking.lua @@ -0,0 +1,150 @@ +local cauldron_model = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3125}, + {-0.5, -0.5, 0.3125, 0.5, 0.5, 0.5}, + {-0.5, -0.5, -0.5, -0.3125, 0.5, 0.5}, + {0.3125, -0.5, -0.5, 0.5, 0.5, 0.5}, + {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5} + } +} + +local cauldron_cbox = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.5, -0.5}, + {-0.5, -0.5, 0.5, 0.5, 0.5, 0.5}, + {-0.5, -0.5, -0.5, -0.5, 0.5, 0.5}, + {0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, + {-0.5, -0.5, -0.5, 0.5, 0, 0.5} + } +} + +minetest.register_alias("xdecor:cauldron", "xdecor:cauldron_empty") + +xdecor.register("cauldron_empty", { + description = "Cauldron", + groups = {cracky=2, oddly_breakable_by_hand=1}, + on_rotate = screwdriver.rotate_simple, + tiles = {"xdecor_cauldron_top_empty.png", "xdecor_cauldron_sides.png"}, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3125}, + {-0.5, -0.5, 0.3125, 0.5, 0.5, 0.5}, + {-0.5, -0.5, -0.5, -0.3125, 0.5, 0.5}, + {0.3125, -0.5, -0.5, 0.5, 0.5, 0.5}, + {-0.5, -0.5, -0.5, 0.5, -0.125, 0.5} + } + }, + selection_box = { + type = "fixed", + fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}} + }, + collision_box = cauldron_cbox, + on_rightclick = function(pos, node, clicker, itemstack, _) + if clicker:get_wielded_item():get_name() == "bucket:bucket_water" then + minetest.set_node(pos, {name="xdecor:cauldron_idle", param2=node.param2}) + itemstack:replace("bucket:bucket_empty") + end + end +}) + +xdecor.register("cauldron_idle", { + groups = {cracky=2, oddly_breakable_by_hand=1, not_in_creative_inventory=1}, + on_rotate = screwdriver.rotate_simple, + tiles = {"xdecor_cauldron_top_idle.png", "xdecor_cauldron_sides.png"}, + drop = "xdecor:cauldron_empty", + node_box = cauldron_model, + collision_box = cauldron_cbox, + selection_box = { + type = "fixed", + fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}} + } +}) + +xdecor.register("cauldron_boiling_water", { + groups = {cracky=2, oddly_breakable_by_hand=1, not_in_creative_inventory=1}, + on_rotate = screwdriver.rotate_simple, + drop = "xdecor:cauldron_empty", + tiles = { + { name = "xdecor_cauldron_top_anim_boiling_water.png", + animation = {type="vertical_frames", length=3.0} }, + "xdecor_cauldron_sides.png" + }, + node_box = cauldron_model, + collision_box = cauldron_cbox, + selection_box = { + type = "fixed", + fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}} + }, + infotext = "Drop some foods inside to make a soup" +}) + +xdecor.register("cauldron_soup", { + groups = {cracky=2, oddly_breakable_by_hand=1, not_in_creative_inventory=1}, + on_rotate = screwdriver.rotate_simple, + drop = "xdecor:cauldron_empty", + tiles = { + { name = "xdecor_cauldron_top_anim_soup.png", + animation = {type="vertical_frames", length=3.0} }, + "xdecor_cauldron_sides.png" + }, + node_box = cauldron_model, + collision_box = cauldron_cbox, + selection_box = { + type = "fixed", + fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}} + }, + infotext = "Your soup is ready, use an empty bowl to eat it", + on_rightclick = function(pos, node, clicker, itemstack, _) + local inv = clicker:get_inventory() + if clicker:get_wielded_item():get_name() == "xdecor:bowl" then + if inv:room_for_item("main", "xdecor:bowl_soup 1") then + itemstack:take_item() + inv:add_item("main", "xdecor:bowl_soup 1") + minetest.set_node(pos, {name="xdecor:cauldron_empty", param2=node.param2}) + else + minetest.chat_send_player(clicker:get_player_name(), "No room in your inventory to add a bowl of soup!") + end + return itemstack + end + end +}) + +minetest.register_abm({ + nodenames = {"xdecor:cauldron_idle"}, + interval = 15, chance = 1, + action = function(pos, node, _, _) + local below_node = {x=pos.x, y=pos.y-1, z=pos.z} + if minetest.get_node(below_node).name:find("fire") then + minetest.set_node(pos, {name="xdecor:cauldron_boiling_water", param2=node.param2}) + end + end +}) + +minetest.register_abm({ + nodenames = {"xdecor:cauldron_boiling_water", "xdecor:cauldron_soup"}, + interval = 3, chance = 1, + action = function(pos, node, _, _) + local below_node = {x=pos.x, y=pos.y-1, z=pos.z} + if not minetest.get_node(below_node).name:find("fire") then + minetest.set_node(pos, {name="xdecor:cauldron_idle", param2=node.param2}) + end + end +}) + +local old_on_step = minetest.registered_entities["__builtin:item"].on_step + +minetest.registered_entities["__builtin:item"].on_step = function(self, dtime) + if minetest.get_node(self.object:getpos()).name == "xdecor:cauldron_boiling_water" then + local itemname = self.object:get_luaentity().itemstring + if itemname:match("default:apple%s%d%d") or + itemname:match("flowers:mushroom_brown%s%d%d") then + self.object:remove() + minetest.set_node(vector.round(self.object:getpos()), {name="xdecor:cauldron_soup"}) + end + end + old_on_step(self, dtime) +end + diff --git a/crafts.lua b/crafts.lua index a5e0e9f..4e02626 100644 --- a/crafts.lua +++ b/crafts.lua @@ -16,6 +16,26 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = "xdecor:bowl 3", + recipe = { + {"group:wood", "", "group:wood"}, + {"", "group:wood", ""} + } +}) + +minetest.register_craftitem("xdecor:bowl", { + description = "Bowl", + inventory_image = "xdecor_bowl.png" +}) + +minetest.register_craftitem("xdecor:bowl_soup", { + description = "Bowl of soup", + inventory_image = "xdecor_bowl_soup.png", + groups = {not_in_creative_inventory = 1}, + on_use = minetest.item_eat(30) +}) + minetest.register_craft({ output = "xdecor:candle", recipe = { @@ -47,10 +67,10 @@ minetest.register_craft({ }) minetest.register_craft({ - output = "xdecor:cauldron", + output = "xdecor:cauldron_empty", recipe = { - {"default:iron_lump", "bucket:bucket_water", "default:iron_lump"}, - {"default:iron_lump", "bucket:bucket_water", "default:iron_lump"}, + {"default:iron_lump", "", "default:iron_lump"}, + {"default:iron_lump", "", "default:iron_lump"}, {"default:iron_lump", "default:iron_lump", "default:iron_lump"} } }) diff --git a/init.lua b/init.lua index c15b571..225aa75 100644 --- a/init.lua +++ b/init.lua @@ -4,6 +4,7 @@ local modpath = minetest.get_modpath("xdecor") dofile(modpath.."/handlers/nodeboxes.lua") dofile(modpath.."/handlers/registration.lua") dofile(modpath.."/chess.lua") +dofile(modpath.."/cooking.lua") dofile(modpath.."/crafts.lua") dofile(modpath.."/enchanting.lua") dofile(modpath.."/hive.lua") diff --git a/nodes.lua b/nodes.lua index 1637e9e..43251f6 100644 --- a/nodes.lua +++ b/nodes.lua @@ -123,38 +123,6 @@ xdecor.register("candle", { } }) -xdecor.register("cauldron", { - description = "Cauldron", - groups = {cracky=2, oddly_breakable_by_hand=1}, - on_rotate = screwdriver.rotate_simple, - tiles = { - { name = "xdecor_cauldron_top_anim.png", - animation = {type="vertical_frames", length=3.0} }, - "xdecor_cauldron_sides.png" - } -}) - -if minetest.get_modpath("bucket") then - local original_bucket_on_use = minetest.registered_items["bucket:bucket_empty"].on_use - minetest.override_item("bucket:bucket_empty", { - on_use = function(itemstack, user, pointed_thing) - local inv = user:get_inventory() - if pointed_thing.type == "node" and minetest.get_node(pointed_thing.under).name == "xdecor:cauldron" then - if inv:room_for_item("main", "bucket:bucket_water 1") then - itemstack:take_item() - inv:add_item("main", "bucket:bucket_water 1") - else - minetest.chat_send_player(user:get_player_name(), "No room in your inventory to add a filled bucket!") - end - return itemstack - else if original_bucket_on_use then - return original_bucket_on_use(itemstack, user, pointed_thing) - end - end - end - }) -end - xpanes.register_pane("chainlink", { description = "Chain Link", tiles = {"xdecor_chainlink.png"}, @@ -492,12 +460,12 @@ xdecor.register("painting_1", { legacy_wallmounted = true, walkable = false, on_rotate = screwdriver.rotate_simple, - wield_image = "xdecor_painting_1.png", + wield_image = "xdecor_painting_empty.png", selection_box = {type="wallmounted"}, groups = {dig_immediate=3, flammable=3, attached_node=1}, after_place_node = function(pos, _, _, _) local node = minetest.get_node(pos) - minetest.set_node(pos, {name = "xdecor:painting_"..math.random(1,4), param2 = node.param2}) + minetest.set_node(pos, {name="xdecor:painting_"..math.random(1,4), param2=node.param2}) end }) diff --git a/textures/xdecor_bowl.png b/textures/xdecor_bowl.png new file mode 100644 index 0000000..2667c73 Binary files /dev/null and b/textures/xdecor_bowl.png differ diff --git a/textures/xdecor_bowl_soup.png b/textures/xdecor_bowl_soup.png new file mode 100644 index 0000000..c246e3e Binary files /dev/null and b/textures/xdecor_bowl_soup.png differ diff --git a/textures/xdecor_cauldron_sides.png b/textures/xdecor_cauldron_sides.png index 1a5e6e9..f698b2f 100644 Binary files a/textures/xdecor_cauldron_sides.png and b/textures/xdecor_cauldron_sides.png differ diff --git a/textures/xdecor_cauldron_top_anim.png b/textures/xdecor_cauldron_top_anim_boiling_water.png similarity index 100% rename from textures/xdecor_cauldron_top_anim.png rename to textures/xdecor_cauldron_top_anim_boiling_water.png diff --git a/textures/xdecor_cauldron_top_anim_soup.png b/textures/xdecor_cauldron_top_anim_soup.png new file mode 100644 index 0000000..029cc23 Binary files /dev/null and b/textures/xdecor_cauldron_top_anim_soup.png differ diff --git a/textures/xdecor_cauldron_top_empty.png b/textures/xdecor_cauldron_top_empty.png new file mode 100644 index 0000000..f04df9f Binary files /dev/null and b/textures/xdecor_cauldron_top_empty.png differ diff --git a/textures/xdecor_cauldron_top_idle.png b/textures/xdecor_cauldron_top_idle.png new file mode 100644 index 0000000..938abe0 Binary files /dev/null and b/textures/xdecor_cauldron_top_idle.png differ diff --git a/textures/xdecor_painting_empty.png b/textures/xdecor_painting_empty.png new file mode 100644 index 0000000..fe1cc6f Binary files /dev/null and b/textures/xdecor_painting_empty.png differ