0
0
Fork 0

Add saturation value to food items

This commit is contained in:
Wuzzy 2017-05-20 17:45:04 +02:00
parent a300831614
commit 3291fcb054
14 changed files with 45 additions and 3 deletions

View File

@ -1,5 +1,6 @@
mcl_core
mcl_sounds
mcl_hunger
bucket
mcl_farming
mcl_mobitems

View File

@ -55,6 +55,7 @@ minetest.register_node("mcl_cake:cake", {
sounds = mcl_sounds.node_sound_leaves_defaults(),
_food_particles = false,
_mcl_saturation = 0.4,
_mcl_blast_resistance = 2.5,
_mcl_hardness = 0.5,
})
@ -96,6 +97,7 @@ local register_slice = function(level, nodebox, desc)
sounds = mcl_sounds.node_sound_leaves_defaults(),
_food_particles = false,
_mcl_saturation = 0.4,
_mcl_blast_resistance = 2.5,
_mcl_hardness = 0.5,
})

View File

@ -139,6 +139,7 @@ minetest.register_craftitem("mcl_core:apple", {
on_place = minetest.item_eat(4),
on_secondary_use = minetest.item_eat(4),
groups = { food = 2, eatable = 4 },
_mcl_saturation = 2.4,
})
minetest.register_craftitem("mcl_core:apple_gold", {
@ -150,4 +151,5 @@ minetest.register_craftitem("mcl_core:apple_gold", {
on_place = minetest.item_eat(8),
on_secondary_use = minetest.item_eat(8),
groups = { food = 2, eatable = 8 },
_mcl_saturation = 9.6,
})

View File

@ -257,6 +257,7 @@ minetest.register_craftitem("mcl_end:chorus_fruit", {
on_place = minetest.item_eat(4),
on_secondary_use = minetest.item_eat(4),
groups = { food = 2, eatable = 4 },
_mcl_saturation = 2.4,
stack_max = 64,
})

View File

@ -125,6 +125,7 @@ minetest.register_craftitem("mcl_farming:beetroot_item", {
on_place = minetest.item_eat(1),
on_secondary_use = minetest.item_eat(1),
groups = { food = 2, eatable = 1 },
_mcl_saturation = 1.2,
})
minetest.register_craftitem("mcl_farming:beetroot_soup", {
@ -136,6 +137,7 @@ minetest.register_craftitem("mcl_farming:beetroot_soup", {
on_place = minetest.item_eat(6, "mcl_core:bowl"),
on_secondary_use = minetest.item_eat(6, "mcl_core:bowl"),
groups = { food = 3, eatable = 6 },
_mcl_saturation = 7.2,
})
minetest.register_craft({

View File

@ -84,6 +84,7 @@ minetest.register_craftitem("mcl_farming:carrot_item", {
_doc_items_usagehelp = "Hold it in your hand and rightclick to eat it. Place it on top of farmland to plant the carrot. It grows in sunlight and grows faster on hydrated farmland. Rightclick an animal to feed it.",
inventory_image = "farming_carrot.png",
groups = { food = 2, eatable = 3 },
_mcl_saturation = 3.6,
on_secondary_use = minetest.item_eat(3),
on_place = function(itemstack, placer, pointed_thing)
local new = mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:carrot_1")
@ -102,6 +103,7 @@ minetest.register_craftitem("mcl_farming:carrot_item_gold", {
on_place = minetest.item_eat(6),
on_secondary_use = minetest.item_eat(6),
groups = { brewitem = 1, food = 2, eatable = 6 },
_mcl_saturation = 14.4,
})
minetest.register_craft({

View File

@ -114,6 +114,7 @@ minetest.register_craftitem("mcl_farming:melon_item", {
on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 },
_mcl_saturation = 1.2,
})
minetest.register_craft({

View File

@ -85,6 +85,7 @@ minetest.register_craftitem("mcl_farming:potato_item", {
_doc_items_usagehelp = "Hold it in your hand and rightclick to eat it. Place it on top of farmland to plant it. It grows in sunlight and grows faster on hydrated farmland. Rightclick an animal to feed it.",
inventory_image = "farming_potato.png",
groups = { food = 2, eatable = 1 },
_mcl_saturation = 0.6,
stack_max = 64,
on_secondary_use = minetest.item_eat(1),
on_place = function(itemstack, placer, pointed_thing)
@ -105,6 +106,7 @@ minetest.register_craftitem("mcl_farming:potato_item_baked", {
on_place = minetest.item_eat(6),
on_secondary_use = minetest.item_eat(6),
groups = { food = 2, eatable = 6 },
_mcl_saturation = 6.0,
})
minetest.register_craftitem("mcl_farming:potato_item_poison", {
@ -117,6 +119,7 @@ minetest.register_craftitem("mcl_farming:potato_item_poison", {
on_place = minetest.item_eat(0),
on_secondary_use = minetest.item_eat(0),
groups = { food = 2, eatable = 0 },
_mcl_saturation = 1.2,
})
minetest.register_craft({

View File

@ -131,6 +131,7 @@ minetest.register_craftitem("mcl_farming:pumpkin_pie", {
on_place = minetest.item_eat(8),
on_secondary_use = minetest.item_eat(8),
groups = { food = 2, eatable = 8 },
_mcl_saturation = 4.8,
})
minetest.register_craft({

View File

@ -112,6 +112,7 @@ minetest.register_craftitem("mcl_farming:cookie", {
_doc_items_longdesc = "This is a food item which can be eaten for 2 hunger points.",
inventory_image = "farming_cookie.png",
groups = {food=2, eatable=2},
_mcl_saturation = 0.4,
on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
})
@ -122,6 +123,7 @@ minetest.register_craftitem("mcl_farming:bread", {
_doc_items_longdesc = "This is a food item which can be eaten for 5 hunger points.",
inventory_image = "farming_bread.png",
groups = {food=2, eatable=5},
_mcl_saturation = 6.0,
on_place = minetest.item_eat(5),
on_secondary_use = minetest.item_eat(5),
})

View File

@ -127,6 +127,7 @@ minetest.register_craftitem("mcl_fishing:fish_raw", {
on_secondary_use = minetest.item_eat(2),
stack_max = 64,
groups = { food=2, eatable = 2 },
_mcl_saturation = 0.4,
})
minetest.register_craftitem("mcl_fishing:fish_cooked", {
@ -137,6 +138,7 @@ minetest.register_craftitem("mcl_fishing:fish_cooked", {
on_secondary_use = minetest.item_eat(5),
stack_max = 64,
groups = { food=2, eatable=5 },
_mcl_saturation = 9.6,
})
minetest.register_craft({
@ -155,6 +157,7 @@ minetest.register_craftitem("mcl_fishing:salmon_raw", {
on_secondary_use = minetest.item_eat(2),
stack_max = 64,
groups = { food=2, eatable = 2 },
_mcl_saturation = 0.4,
})
minetest.register_craftitem("mcl_fishing:salmon_cooked", {
@ -165,6 +168,7 @@ minetest.register_craftitem("mcl_fishing:salmon_cooked", {
on_secondary_use = minetest.item_eat(6),
stack_max = 64,
groups = { food=2, eatable=6 },
_mcl_saturation = 9.6,
})
minetest.register_craft({
@ -183,6 +187,7 @@ minetest.register_craftitem("mcl_fishing:clownfish_raw", {
on_secondary_use = minetest.item_eat(1),
stack_max = 64,
groups = { food=2, eatable = 1 },
_mcl_saturation = 0.2,
})
-- Pufferfish
@ -195,5 +200,6 @@ minetest.register_craftitem("mcl_fishing:pufferfish_raw", {
on_secondary_use = minetest.item_eat(1),
stack_max = 64,
groups = { food=2, eatable=1 },
_mcl_saturation = 0.2,
})

View File

@ -8,6 +8,7 @@ minetest.register_craftitem("mcl_mobitems:rotten_flesh", {
on_place = minetest.item_eat(4),
on_secondary_use = minetest.item_eat(4),
groups = { food = 2, eatable = 4 },
_mcl_saturation = 0.8,
stack_max = 64,
})
@ -19,6 +20,7 @@ minetest.register_craftitem("mcl_mobitems:mutton", {
on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 },
_mcl_saturation = 1.2,
stack_max = 64,
})
@ -30,6 +32,7 @@ minetest.register_craftitem("mcl_mobitems:cooked_mutton", {
on_place = minetest.item_eat(6),
on_secondary_use = minetest.item_eat(6),
groups = { food = 2, eatable = 6 },
_mcl_saturation = 9.6,
stack_max = 64,
})
@ -41,6 +44,7 @@ minetest.register_craftitem("mcl_mobitems:beef", {
on_place = minetest.item_eat(3),
on_secondary_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 },
_mcl_saturation = 1.8,
stack_max = 64,
})
@ -52,6 +56,7 @@ minetest.register_craftitem("mcl_mobitems:cooked_beef", {
on_place = minetest.item_eat(8),
on_secondary_use = minetest.item_eat(8),
groups = { food = 2, eatable = 8 },
_mcl_saturation = 12.8,
stack_max = 64,
})
@ -63,6 +68,7 @@ minetest.register_craftitem("mcl_mobitems:chicken", {
on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 },
_mcl_saturation = 1.2,
stack_max = 64,
})
@ -74,6 +80,7 @@ minetest.register_craftitem("mcl_mobitems:cooked_chicken", {
on_place = minetest.item_eat(6),
on_secondary_use = minetest.item_eat(6),
groups = { food = 2, eatable = 6 },
_mcl_saturation = 7.2,
stack_max = 64,
})
@ -85,6 +92,7 @@ minetest.register_craftitem("mcl_mobitems:porkchop", {
on_place = minetest.item_eat(3),
on_secondary_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 },
_mcl_saturation = 1.8,
stack_max = 64,
})
@ -96,6 +104,7 @@ minetest.register_craftitem("mcl_mobitems:cooked_porkchop", {
on_place = minetest.item_eat(8),
on_secondary_use = minetest.item_eat(8),
groups = { food = 2, eatable = 8 },
_mcl_saturation = 12.8,
stack_max = 64,
})
@ -107,6 +116,7 @@ minetest.register_craftitem("mcl_mobitems:rabbit", {
on_place = minetest.item_eat(3),
on_secondary_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 },
_mcl_saturation = 1.8,
stack_max = 64,
})
@ -118,6 +128,7 @@ minetest.register_craftitem("mcl_mobitems:cooked_rabbit", {
on_place = minetest.item_eat(5),
on_secondary_use = minetest.item_eat(5),
groups = { food = 2, eatable = 5 },
_mcl_saturation = 6.0,
stack_max = 64,
})
@ -142,6 +153,7 @@ minetest.register_craftitem("mcl_mobitems:spider_eye", {
on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 },
_mcl_saturation = 3.2,
stack_max = 64,
})
@ -261,6 +273,7 @@ minetest.register_craftitem("mcl_mobitems:rabbit_stew", {
on_place = minetest.item_eat(10, "mcl_core:bowl"),
on_secondary_use = minetest.item_eat(10, "mcl_core:bowl"),
groups = { food = 3, eatable = 10 },
_mcl_saturation = 6.0,
})
minetest.register_craftitem("mcl_mobitems:shulker_shell", {

View File

@ -146,10 +146,14 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisen, heal, sou
mcl_hunger.hunger[name] = h
mcl_hunger.set_hunger_raw(user)
end
-- Dummy saturation (= hunger change)
-- TODO: Use food's actual saturation value
-- Add saturation (must be defined in item table)
if hunger_change then
mcl_hunger.saturate(name, hunger_change)
local saturation = minetest.registered_items[itemname]._mcl_saturation
if not saturation then
saturation = 0.0
minetest.log("warning", "[mcl_hunger] No saturation defined for item “"..itemname.."”!")
end
mcl_hunger.saturate(name, saturation)
end
-- Poison
if poisen then

View File

@ -214,6 +214,8 @@ minetest.register_globalstep(function(dtime)
if controls.up or controls.down or controls.left or controls.right then
-- TODO: Add exhaustion for moving in water
end
-- Jumping
-- FIXME: This is quite hacky and doesn't check if the player is actually jumping
if controls.jump then
mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_JUMP)
end