From 177196a8d2d2131b8dfbcb0cf28c501353924b83 Mon Sep 17 00:00:00 2001 From: DinoNuggies4665 Date: Tue, 30 May 2023 19:40:12 -0500 Subject: [PATCH] modified: mods/ITEMS/mcl_campfires/api.lua modified: mods/ITEMS/mcl_fishing/init.lua modified: mods/ITEMS/mcl_mobitems/init.lua --- mods/ITEMS/mcl_campfires/api.lua | 11 ++++++++-- mods/ITEMS/mcl_fishing/init.lua | 14 ------------- mods/ITEMS/mcl_mobitems/init.lua | 35 -------------------------------- 3 files changed, 9 insertions(+), 51 deletions(-) diff --git a/mods/ITEMS/mcl_campfires/api.lua b/mods/ITEMS/mcl_campfires/api.lua index af496b202..c6c90faa5 100644 --- a/mods/ITEMS/mcl_campfires/api.lua +++ b/mods/ITEMS/mcl_campfires/api.lua @@ -2,11 +2,17 @@ local S = minetest.get_translator(minetest.get_current_modname()) mcl_campfires = {} local drop_items = mcl_util.drop_items_from_meta_container("main") +local food_entity = {nil, nil, nil, nil} local function on_blast(pos) local node = minetest.get_node(pos) drop_items(pos, node) minetest.remove_node(pos) + for i = 1, 4 do + if food_entity[i] then + food_entity[i]:remove() + end + end end -- on_rightclick function to take items that are cookable in a campfire, and put them in the campfire inventory @@ -32,7 +38,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], stack:get_name().."_entity") -- Spawn food item on the campfire + food_entity[space] = minetest.add_entity(pos + campfire_spots[space], stack:get_name().."_entity") -- Spawn food item on the campfire break end end @@ -58,6 +64,7 @@ function mcl_campfires.cook_item(pos, elapsed) elseif time_r <= 0 then local cooked = minetest.get_craft_result({method = "cooking", width = 1, items = {item}}) if cooked then + food_entity[i]:remove() -- Remove visual food entity minetest.add_item(pos, cooked.item) -- Drop Cooked Item inv:set_stack("main", i, "") -- Clear Inventory continue = continue + 1 -- Indicate that the slot is clear. @@ -169,7 +176,7 @@ function mcl_campfires.register_campfire(name, def) _mcl_hardness = 2, damage_per_second = def.damage, on_blast = on_blast, - after_dig_node = drop_items, + after_dig_node = on_blast, }) end diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index 442662deb..35d309519 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -468,15 +468,8 @@ minetest.register_entity("mcl_fishing:fish_raw_entity", { 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 @@ -520,15 +513,8 @@ minetest.register_entity("mcl_fishing:salmon_raw_entity", { 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 diff --git a/mods/ITEMS/mcl_mobitems/init.lua b/mods/ITEMS/mcl_mobitems/init.lua index a84e3ece8..3783fe1fb 100644 --- a/mods/ITEMS/mcl_mobitems/init.lua +++ b/mods/ITEMS/mcl_mobitems/init.lua @@ -48,15 +48,8 @@ minetest.register_entity("mcl_mobitems:mutton_entity", { 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", { @@ -94,15 +87,8 @@ minetest.register_entity("mcl_mobitems:beef_entity", { 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", { @@ -141,15 +127,8 @@ minetest.register_entity("mcl_mobitems:chicken_entity", { 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", { @@ -187,15 +166,8 @@ minetest.register_entity("mcl_mobitems:porkchop_entity", { 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", { @@ -233,15 +205,8 @@ minetest.register_entity("mcl_mobitems:rabbit_entity", { 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