2015-06-29 20:55:56 +03:00
--[[
#!#!#!#Cake mod created by Jordan4ibanez#!#!#
#!#!#!#Released under CC Attribution-ShareAlike 3.0 Unported #!#!#
] ] --
2020-02-19 06:54:17 +03:00
local CAKE_HUNGER_POINTS = 2
2021-05-29 17:12:33 +03:00
local S = minetest.get_translator ( minetest.get_current_modname ( ) )
2019-03-08 01:40:43 +03:00
2017-01-24 04:31:49 +03:00
local cake_texture = { " cake_top.png " , " cake_bottom.png " , " cake_inner.png " , " cake_side.png " , " cake_side.png " , " cake_side.png " }
local slice_1 = { - 7 / 16 , - 8 / 16 , - 7 / 16 , - 5 / 16 , 0 / 16 , 7 / 16 }
2017-02-28 02:01:51 +03:00
local slice_2 = { - 7 / 16 , - 8 / 16 , - 7 / 16 , - 3 / 16 , 0 / 16 , 7 / 16 }
local slice_3 = { - 7 / 16 , - 8 / 16 , - 7 / 16 , - 1 / 16 , 0 / 16 , 7 / 16 }
local slice_4 = { - 7 / 16 , - 8 / 16 , - 7 / 16 , 1 / 16 , 0 / 16 , 7 / 16 }
local slice_5 = { - 7 / 16 , - 8 / 16 , - 7 / 16 , 3 / 16 , 0 / 16 , 7 / 16 }
local slice_6 = { - 7 / 16 , - 8 / 16 , - 7 / 16 , 5 / 16 , 0 / 16 , 7 / 16 }
local full_cake = { - 7 / 16 , - 8 / 16 , - 7 / 16 , 7 / 16 , 0 / 16 , 7 / 16 }
2015-06-29 20:55:56 +03:00
minetest.register_craft ( {
2017-01-16 23:13:26 +03:00
output = " mcl_cake:cake " ,
2015-06-29 20:55:56 +03:00
recipe = {
2021-05-29 17:12:33 +03:00
{ " mcl_mobitems:milk_bucket " , " mcl_mobitems:milk_bucket " , " mcl_mobitems:milk_bucket " } ,
{ " mcl_core:sugar " , " mcl_throwing:egg " , " mcl_core:sugar " } ,
{ " mcl_farming:wheat_item " , " mcl_farming:wheat_item " , " mcl_farming:wheat_item " } ,
2015-06-29 20:55:56 +03:00
} ,
2017-01-17 03:09:11 +03:00
replacements = {
2017-08-03 17:36:55 +03:00
{ " mcl_mobitems:milk_bucket " , " mcl_buckets:bucket_empty " } ,
{ " mcl_mobitems:milk_bucket " , " mcl_buckets:bucket_empty " } ,
{ " mcl_mobitems:milk_bucket " , " mcl_buckets:bucket_empty " } ,
2017-01-17 03:09:11 +03:00
} ,
2015-06-29 20:55:56 +03:00
} )
2017-01-16 23:13:26 +03:00
minetest.register_node ( " mcl_cake:cake " , {
2019-03-08 01:40:43 +03:00
description = S ( " Cake " ) ,
2020-02-19 06:54:17 +03:00
_tt_help = S ( " With 7 tasty slices! " ) .. " \n " .. S ( " Hunger points: +@1 per slice " , CAKE_HUNGER_POINTS ) ,
2019-03-08 01:40:43 +03:00
_doc_items_longdesc = S ( " 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. " ) ,
_doc_items_usagehelp = S ( " 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. " ) ,
2015-06-29 20:55:56 +03:00
tiles = { " cake_top.png " , " cake_bottom.png " , " cake_side.png " , " cake_side.png " , " cake_side.png " , " cake_side.png " } ,
2021-02-18 16:00:17 +03:00
use_texture_alpha = minetest.features . use_texture_alpha_string_modes and " opaque " or false ,
2017-01-16 22:59:07 +03:00
inventory_image = " cake.png " ,
wield_image = " cake.png " ,
2015-06-29 20:55:56 +03:00
paramtype = " light " ,
2017-01-05 00:36:51 +03:00
is_ground_content = false ,
2015-06-29 20:55:56 +03:00
drawtype = " nodebox " ,
selection_box = {
type = " fixed " ,
2017-02-28 02:01:51 +03:00
fixed = full_cake
2015-06-29 20:55:56 +03:00
} ,
node_box = {
type = " fixed " ,
2017-02-28 02:01:51 +03:00
fixed = full_cake
} ,
2015-06-29 20:55:56 +03:00
stack_max = 1 ,
Add `compostability` to node definition group.
* mcl_cake/init.lua (cake);
* mcl_core/craftitems.lua (apple);
* mcl_core/nodes_base.lua (dirt with grass);
* mcl_core/nodes_cactuscane.lua (cactus, sugarcane);
* mcl_core/nodes_climb.lua (vines);
* mcl_core/nodes_trees.lua (leaves, saplings);
* mcl_dye/init.lua (cocoa beans);
* mcl_farming/beetroot.lua (beetroot, & seeds);
* mcl_farming/carrots.lua (carrot);
* mcl_farming/melon.lua (melon, & slice, & seeds);
* mcl_farming/potatoes.lua (potato, baked potato);
* mcl_farming/pumpkin.lua (pumpkin, carved &, & seeds, & pie);
* mcl_farming/wheat.lua (wheat, cookie, bread, hay block);
* mcl_flowers/init.lua (flowers, ferns, grass, & tall variants);
* mcl_mushrooms/small.lua (red and brown mushrooms);
* mcl_mushrooms/huge.lua (red and brown huge mushrooms);
* mcl_nether/init.lua (nether wart block);
* mcl_nether/nether_wart.lua (nether wart);
* mcl_ocean/kelp.lua (kelp, dried &, & block);
* mcl_ocean/sea_pickle.lua (sea pickle);
* mcl_ocean/seagrass.lua (seagrass).
2022-03-29 13:54:51 +03:00
groups = {
handy = 1 , attached_node = 1 , dig_by_piston = 1 , comparator_signal = 14 ,
cake = 7 , food = 2 , no_eat_delay = 1 , compostability = 100
} ,
2021-05-29 17:12:33 +03:00
drop = " " ,
2015-06-29 20:55:56 +03:00
on_rightclick = function ( pos , node , clicker , itemstack )
2019-02-08 23:59:01 +03:00
-- Cake is subject to protection
local name = clicker : get_player_name ( )
if minetest.is_protected ( pos , name ) then
minetest.record_protection_violation ( pos , name )
return
end
2017-05-23 03:09:47 +03:00
local newcake = minetest.do_item_eat ( 2 , ItemStack ( " mcl_cake:cake_6 " ) , ItemStack ( " mcl_cake:cake " ) , clicker , { type = " nothing " } )
-- Check if we were allowed to eat
2020-07-10 17:08:40 +03:00
if newcake : get_name ( ) ~= " mcl_cake:cake " or minetest.is_creative_enabled ( clicker : get_player_name ( ) ) then
2017-05-23 03:09:47 +03:00
minetest.add_node ( pos , { type = " node " , name = " mcl_cake:cake_6 " , param2 = 0 } )
end
2015-06-29 20:55:56 +03:00
end ,
2017-02-11 20:46:23 +03:00
sounds = mcl_sounds.node_sound_leaves_defaults ( ) ,
2017-02-16 17:25:07 +03:00
_food_particles = false ,
2017-05-20 18:45:04 +03:00
_mcl_saturation = 0.4 ,
2020-04-17 22:40:13 +03:00
_mcl_blast_resistance = 0.5 ,
2017-03-20 21:29:46 +03:00
_mcl_hardness = 0.5 ,
2015-06-29 20:55:56 +03:00
} )
2017-02-16 17:25:07 +03:00
2017-02-28 02:01:51 +03:00
local register_slice = function ( level , nodebox , desc )
local this = " mcl_cake:cake_ " .. level
local after_eat = " mcl_cake:cake_ " .. ( level - 1 )
local on_rightclick
if level > 1 then
on_rightclick = function ( pos , node , clicker , itemstack )
2019-02-08 23:59:01 +03:00
local name = clicker : get_player_name ( )
if minetest.is_protected ( pos , name ) then
minetest.record_protection_violation ( pos , name )
return
end
2020-02-19 06:54:17 +03:00
local newcake = minetest.do_item_eat ( CAKE_HUNGER_POINTS , ItemStack ( after_eat ) , ItemStack ( this ) , clicker , { type = " nothing " } )
2017-05-23 03:09:47 +03:00
-- Check if we were allowed to eat
2020-07-10 17:08:40 +03:00
if newcake : get_name ( ) ~= this or minetest.is_creative_enabled ( clicker : get_player_name ( ) ) then
2017-05-23 03:09:47 +03:00
minetest.add_node ( pos , { type = " node " , name = after_eat , param2 = 0 } )
end
2017-02-28 02:01:51 +03:00
end
else
2017-05-23 03:09:47 +03:00
-- Last slice
2017-02-28 02:01:51 +03:00
on_rightclick = function ( pos , node , clicker , itemstack )
2019-02-08 23:59:01 +03:00
local name = clicker : get_player_name ( )
if minetest.is_protected ( pos , name ) then
minetest.record_protection_violation ( pos , name )
return
end
2020-02-19 06:54:17 +03:00
local newcake = minetest.do_item_eat ( CAKE_HUNGER_POINTS , ItemStack ( " mcl:cake:cake 0 " ) , ItemStack ( " mcl_cake:cake_1 " ) , clicker , { type = " nothing " } )
2017-05-23 03:09:47 +03:00
-- Check if we were allowed to eat
2020-07-10 17:08:40 +03:00
if newcake : get_name ( ) ~= this or minetest.is_creative_enabled ( clicker : get_player_name ( ) ) then
2017-05-23 03:09:47 +03:00
minetest.remove_node ( pos )
2021-06-12 01:18:52 +03:00
minetest.check_for_falling ( pos )
2017-05-23 03:09:47 +03:00
end
2017-02-28 02:01:51 +03:00
end
end
2017-02-16 17:25:07 +03:00
2017-02-28 02:01:51 +03:00
minetest.register_node ( this , {
description = desc ,
2017-03-02 21:53:53 +03:00
_doc_items_create_entry = false ,
2017-02-28 02:01:51 +03:00
tiles = cake_texture ,
2021-02-18 16:00:17 +03:00
use_texture_alpha = minetest.features . use_texture_alpha_string_modes and " opaque " or false ,
2017-02-28 02:01:51 +03:00
paramtype = " light " ,
is_ground_content = false ,
drawtype = " nodebox " ,
selection_box = {
type = " fixed " ,
fixed = nodebox ,
2015-06-29 20:55:56 +03:00
} ,
2017-02-28 02:01:51 +03:00
node_box = {
type = " fixed " ,
fixed = nodebox ,
} ,
Add `compostability` to node definition group.
* mcl_cake/init.lua (cake);
* mcl_core/craftitems.lua (apple);
* mcl_core/nodes_base.lua (dirt with grass);
* mcl_core/nodes_cactuscane.lua (cactus, sugarcane);
* mcl_core/nodes_climb.lua (vines);
* mcl_core/nodes_trees.lua (leaves, saplings);
* mcl_dye/init.lua (cocoa beans);
* mcl_farming/beetroot.lua (beetroot, & seeds);
* mcl_farming/carrots.lua (carrot);
* mcl_farming/melon.lua (melon, & slice, & seeds);
* mcl_farming/potatoes.lua (potato, baked potato);
* mcl_farming/pumpkin.lua (pumpkin, carved &, & seeds, & pie);
* mcl_farming/wheat.lua (wheat, cookie, bread, hay block);
* mcl_flowers/init.lua (flowers, ferns, grass, & tall variants);
* mcl_mushrooms/small.lua (red and brown mushrooms);
* mcl_mushrooms/huge.lua (red and brown huge mushrooms);
* mcl_nether/init.lua (nether wart block);
* mcl_nether/nether_wart.lua (nether wart);
* mcl_ocean/kelp.lua (kelp, dried &, & block);
* mcl_ocean/sea_pickle.lua (sea pickle);
* mcl_ocean/seagrass.lua (seagrass).
2022-03-29 13:54:51 +03:00
groups = {
handy = 1 , attached_node = 1 , not_in_creative_inventory = 1 ,
dig_by_piston = 1 , cake = level , comparator_signal = level * 2 ,
food = 2 , no_eat_delay = 1
} ,
2021-05-29 17:12:33 +03:00
drop = " " ,
2017-02-28 02:01:51 +03:00
on_rightclick = on_rightclick ,
sounds = mcl_sounds.node_sound_leaves_defaults ( ) ,
2017-02-16 17:25:07 +03:00
2017-02-28 02:01:51 +03:00
_food_particles = false ,
2017-05-20 18:45:04 +03:00
_mcl_saturation = 0.4 ,
2020-04-17 22:40:13 +03:00
_mcl_blast_resistance = 0.5 ,
2017-03-20 21:29:46 +03:00
_mcl_hardness = 0.5 ,
2017-02-28 02:01:51 +03:00
} )
2017-03-20 20:12:05 +03:00
if minetest.get_modpath ( " doc " ) then
doc.add_entry_alias ( " nodes " , " mcl_cake:cake " , " nodes " , " mcl_cake:cake_ " .. level )
end
2017-02-28 02:01:51 +03:00
end
2017-02-16 17:25:07 +03:00
2019-03-08 01:40:43 +03:00
register_slice ( 6 , slice_6 , S ( " Cake (6 Slices Left) " ) )
register_slice ( 5 , slice_5 , S ( " Cake (5 Slices Left) " ) )
register_slice ( 4 , slice_4 , S ( " Cake (4 Slices Left) " ) )
register_slice ( 3 , slice_3 , S ( " Cake (3 Slices Left) " ) )
register_slice ( 2 , slice_2 , S ( " Cake (2 Slices Left) " ) )
register_slice ( 1 , slice_1 , S ( " Cake (1 Slice Left) " ) )