2 #!#!#!#Cake mod created by Jordan4ibanez#!#!#
3 #!#!#!#Released under CC Attribution-ShareAlike 3.0 Unported #!#!#
6 local cake_texture
= {"cake_top.png","cake_bottom.png","cake_inner.png","cake_side.png","cake_side.png","cake_side.png"}
7 local slice_1
= { -7/16, -8/16, -7/16, -5/16, 0/16, 7/16}
8 local slice_2
= { -7/16, -8/16, -7/16, -3/16, 0/16, 7/16}
9 local slice_3
= { -7/16, -8/16, -7/16, -1/16, 0/16, 7/16}
10 local slice_4
= { -7/16, -8/16, -7/16, 1/16, 0/16, 7/16}
11 local slice_5
= { -7/16, -8/16, -7/16, 3/16, 0/16, 7/16}
12 local slice_6
= { -7/16, -8/16, -7/16, 5/16, 0/16, 7/16}
14 local full_cake
= { -7/16, -8/16, -7/16, 7/16, 0/16, 7/16}
16 minetest
.register_craft({
17 output
= "mcl_cake:cake",
19 {'mcl_mobitems:milk_bucket', 'mcl_mobitems:milk_bucket', 'mcl_mobitems:milk_bucket'},
20 {'mcl_core:sugar', 'mcl_throwing:egg', 'mcl_core:sugar'},
21 {'mcl_farming:wheat_item', 'mcl_farming:wheat_item', 'mcl_farming:wheat_item'},
24 {"mcl_mobitems:milk_bucket", "mcl_buckets:bucket_empty"},
25 {"mcl_mobitems:milk_bucket", "mcl_buckets:bucket_empty"},
26 {"mcl_mobitems:milk_bucket", "mcl_buckets:bucket_empty"},
30 minetest
.register_node("mcl_cake:cake", {
32 _doc_items_longdesc
= "Cakes can be placed and eaten to restore hunger points. A cake has 7 slices. Each slice restores 2 hunger points and 0.4 saturation points. Cakes will be destroyed when dug or when the block below them is broken.",
33 _doc_items_usagehelp
= "Place the cake anywhere, then rightclick it to eat a single slice. You can't eat from the cake when your hunger bar is full.",
34 tiles
= {"cake_top.png","cake_bottom.png","cake_side.png","cake_side.png","cake_side.png","cake_side.png"},
35 inventory_image
= "cake.png",
36 wield_image
= "cake.png",
38 is_ground_content
= false,
49 groups
= {handy
=1, cake
=7, food
=2,no_eat_delay
=1, attached_node
=1, dig_by_piston
=1},
51 on_rightclick
= function(pos
, node
, clicker
, itemstack
)
52 local newcake
= minetest
.do_item_eat(2, ItemStack("mcl_cake:cake_6"), ItemStack("mcl_cake:cake"), clicker
, {type="nothing"})
53 -- Check if we were allowed to eat
54 if newcake
:get_name() ~= "mcl_cake:cake" then
55 minetest
.add_node(pos
,{type="node",name
="mcl_cake:cake_6",param2
=0})
58 sounds
= mcl_sounds
.node_sound_leaves_defaults(),
60 _food_particles
= false,
61 _mcl_saturation
= 0.4,
62 _mcl_blast_resistance
= 2.5,
66 local register_slice
= function(level
, nodebox
, desc
)
67 local this
= "mcl_cake:cake_"..level
68 local after_eat
= "mcl_cake:cake_"..(level
-1)
71 on_rightclick
= function(pos
, node
, clicker
, itemstack
)
72 local newcake
= minetest
.do_item_eat(2, ItemStack(after_eat
), ItemStack(this
), clicker
, {type="nothing"})
73 -- Check if we were allowed to eat
74 if newcake
:get_name() ~= this
then
75 minetest
.add_node(pos
,{type="node",name
=after_eat
,param2
=0})
80 on_rightclick
= function(pos
, node
, clicker
, itemstack
)
81 local newcake
= minetest
.do_item_eat(2, ItemStack("mcl:cake:cake 0"), ItemStack("mcl_cake:cake_1"), clicker
, {type="nothing"})
82 -- Check if we were allowed to eat
83 if newcake
:get_name() ~= this
then
84 minetest
.remove_node(pos
)
85 core
.check_for_falling(pos
)
90 minetest
.register_node(this
, {
92 _doc_items_create_entry
= false,
95 is_ground_content
= false,
105 groups
= {handy
=1, cake
=level
, food
=2,no_eat_delay
=1,attached_node
=1,not_in_creative_inventory
=1,dig_by_piston
=1},
107 on_rightclick
= on_rightclick
,
108 sounds
= mcl_sounds
.node_sound_leaves_defaults(),
110 _food_particles
= false,
111 _mcl_saturation
= 0.4,
112 _mcl_blast_resistance
= 2.5,
116 if minetest
.get_modpath("doc") then
117 doc
.add_entry_alias("nodes", "mcl_cake:cake", "nodes", "mcl_cake:cake_"..level
)
121 register_slice(6, slice_6
, "Cake (6 Slices Left")
122 register_slice(5, slice_5
, "Cake (5 Slices Left")
123 register_slice(4, slice_4
, "Cake (4 Slices Left")
124 register_slice(3, slice_3
, "Cake (3 Slices Left")
125 register_slice(2, slice_2
, "Cake (2 Slices Left")
126 register_slice(1, slice_1
, "Cake (1 Slice Left")