1
0
Fork 0

Added visible items cooking on the fire

This commit is contained in:
DinoNuggies4665 2023-05-30 16:31:58 -05:00 committed by PrairieWind
parent 5d970af1b0
commit 30e05d514e
3 changed files with 161 additions and 0 deletions

View File

@ -11,6 +11,12 @@ end
-- on_rightclick function to take items that are cookable in a campfire, and put them in the campfire inventory
function mcl_campfires.take_item(pos, node, player, itemstack)
local campfire_spots = {
{x = -0.25, y = -0.04, z = -0.25},
{x = 0.25, y = -0.04, z = -0.25},
{x = 0.25, y = -0.04, z = 0.25},
{x = -0.25, y = -0.04, z = 0.25},
}
local is_creative = minetest.is_creative_enabled(player:get_player_name())
local inv = player:get_inventory()
local campfire_meta = minetest.get_meta(pos)
@ -26,6 +32,7 @@ function mcl_campfires.take_item(pos, node, player, itemstack)
if not is_creative then itemstack:take_item(1) end -- Take the item if in creative
campfire_inv:set_stack("main", space, stack) -- Set the inventory itemstack at the empty spot
campfire_meta:set_int("cooktime_"..tostring(space), 30) -- Set the cook time meta
minetest.add_entity(pos + campfire_spots[space], player:get_wielded_item():get_name().."_entity") -- Spawn food item on the campfire
break
end
end

View File

@ -457,6 +457,28 @@ minetest.register_craft({
cooktime = 10,
})
minetest.register_entity("mcl_fishing:fish_entity", {
initial_properties = {
physical = false,
visual = "wielditem",
wield_item = "mcl_fishing:fish_raw",
wield_image = "mcl_fishing_fish_raw.png",
visual_size = {x=0.25, y=0.25},
collisionbox = {0,0,0,0,0,0},
pointable = false,
},
on_activate = function(self, staticdata)
self.timer = 0
self.object:set_rotation({x = math.pi / 2, y = 0, z = 0})
end,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if self.timer > 31 then
self.object:remove()
end
end,
})
-- Salmon
minetest.register_craftitem("mcl_fishing:salmon_raw", {
description = S("Raw Salmon"),
@ -487,6 +509,28 @@ minetest.register_craft({
cooktime = 10,
})
minetest.register_entity("mcl_fishing:salmon_entity", {
initial_properties = {
physical = false,
visual = "wielditem",
wield_item = "mcl_fishing:salmon_raw",
wield_image = "mcl_fishing_salmon_raw.png",
visual_size = {x=0.25, y=0.25},
collisionbox = {0,0,0,0,0,0},
pointable = false,
},
on_activate = function(self, staticdata)
self.timer = 0
self.object:set_rotation({x = math.pi / 2, y = 0, z = 0})
end,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if self.timer > 31 then
self.object:remove()
end
end,
})
-- Clownfish
minetest.register_craftitem("mcl_fishing:clownfish_raw", {
description = S("Clownfish"),

View File

@ -37,6 +37,28 @@ minetest.register_craftitem("mcl_mobitems:cooked_mutton", {
stack_max = 64,
})
minetest.register_entity("mcl_mobitems:mutton_entity", {
initial_properties = {
physical = false,
visual = "wielditem",
wield_item = "mcl_mobitems:mutton",
wield_image = "mcl_mobitems_mutton_raw.png",
visual_size = {x=0.25, y=0.25},
collisionbox = {0,0,0,0,0,0},
pointable = false,
},
on_activate = function(self, staticdata)
self.timer = 0
self.object:set_rotation({x = math.pi / 2, y = 0, z = 0})
end,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if self.timer > 31 then
self.object:remove()
end
end,
})
minetest.register_craftitem("mcl_mobitems:beef", {
description = S("Raw Beef"),
_doc_items_longdesc = S("Raw beef is the flesh from cows and can be eaten safely. Cooking it will greatly increase its nutritional value."),
@ -61,6 +83,28 @@ minetest.register_craftitem("mcl_mobitems:cooked_beef", {
stack_max = 64,
})
minetest.register_entity("mcl_mobitems:beef_entity", {
initial_properties = {
physical = false,
visual = "wielditem",
wield_item = "mcl_mobitems:beef",
wield_image = "mcl_mobitems_beef_raw.png",
visual_size = {x=0.25, y=0.25},
collisionbox = {0,0,0,0,0,0},
pointable = false,
},
on_activate = function(self, staticdata)
self.timer = 0
self.object:set_rotation({x = math.pi / 2, y = 0, z = 0})
end,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if self.timer > 31 then
self.object:remove()
end
end,
})
minetest.register_craftitem("mcl_mobitems:chicken", {
description = S("Raw Chicken"),
_tt_help = minetest.colorize(mcl_colors.YELLOW, S("30% chance of food poisoning")),
@ -86,6 +130,28 @@ minetest.register_craftitem("mcl_mobitems:cooked_chicken", {
stack_max = 64,
})
minetest.register_entity("mcl_mobitems:chicken_entity", {
initial_properties = {
physical = false,
visual = "wielditem",
wield_item = "mcl_mobitems:chicken",
wield_image = "mcl_mobitems_chicken_raw.png",
visual_size = {x=0.25, y=0.25},
collisionbox = {0,0,0,0,0,0},
pointable = false,
},
on_activate = function(self, staticdata)
self.timer = 0
self.object:set_rotation({x = math.pi / 2, y = 0, z = 0})
end,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if self.timer > 31 then
self.object:remove()
end
end,
})
minetest.register_craftitem("mcl_mobitems:porkchop", {
description = S("Raw Porkchop"),
_doc_items_longdesc = S("A raw porkchop is the flesh from a pig and can be eaten safely. Cooking it will greatly increase its nutritional value."),
@ -110,6 +176,28 @@ minetest.register_craftitem("mcl_mobitems:cooked_porkchop", {
stack_max = 64,
})
minetest.register_entity("mcl_mobitems:porkchop_entity", {
initial_properties = {
physical = false,
visual = "wielditem",
wield_item = "mcl_mobitems:porkchop",
wield_image = "mcl_mobitems_porkchop_raw.png",
visual_size = {x=0.25, y=0.25},
collisionbox = {0,0,0,0,0,0},
pointable = false,
},
on_activate = function(self, staticdata)
self.timer = 0
self.object:set_rotation({x = math.pi / 2, y = 0, z = 0})
end,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if self.timer > 31 then
self.object:remove()
end
end,
})
minetest.register_craftitem("mcl_mobitems:rabbit", {
description = S("Raw Rabbit"),
_doc_items_longdesc = S("Raw rabbit is a food item from a dead rabbit. It can be eaten safely. Cooking it will increase its nutritional value."),
@ -134,6 +222,28 @@ minetest.register_craftitem("mcl_mobitems:cooked_rabbit", {
stack_max = 64,
})
minetest.register_entity("mcl_mobitems:rabbit_entity", {
initial_properties = {
physical = false,
visual = "wielditem",
wield_item = "mcl_mobitems:rabbit",
wield_image = "mcl_mobitems_rabbit_raw.png",
visual_size = {x=0.25, y=0.25},
collisionbox = {0,0,0,0,0,0},
pointable = false,
},
on_activate = function(self, staticdata)
self.timer = 0
self.object:set_rotation({x = math.pi / 2, y = 0, z = 0})
end,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if self.timer > 31 then
self.object:remove()
end
end,
})
-- Reset food poisoning and status effects
local function drink_milk(itemstack, player, pointed_thing)
local bucket = minetest.do_item_eat(0, "mcl_buckets:bucket_empty", itemstack, player, pointed_thing)