From d798df0742a7c2d7e8c151c831568161ed7b767c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 16 Feb 2017 15:15:05 +0100 Subject: [PATCH] Don't show food particle without inv/wield img --- mods/PLAYER/mcl_hunger/hunger.lua | 41 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index ed2556d24a..f9c6a678ed 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -80,7 +80,6 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisen, heal, sou local pos = user:getpos() pos.y = pos.y + item_drop_settings.player_collect_height - local texture = minetest.registered_items[itemname].inventory_image -- FIXME: Is this correct? o_O minetest.add_item(pos, drop) local foodtype = minetest.get_item_group(itemname, "food") @@ -94,23 +93,29 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisen, heal, sou else -- Assume the item is a food -- Add eat particle effect and sound - minetest.add_particlespawner({ - amount = 20, - time = 0.1, - minpos = {x=pos.x, y=pos.y, z=pos.z}, - maxpos = {x=pos.x, y=pos.y, z=pos.z}, - minvel = {x=-1, y=1, z=-1}, - maxvel = {x=1, y=2, z=1}, - minacc = {x=0, y=-5, z=0}, - maxacc = {x=0, y=-9, z=0}, - minexptime = 1, - maxexptime = 1, - minsize = 1, - maxsize = 2, - collisiondetection = true, - vertical = false, - texture = texture, - }) + local texture = minetest.registered_items[itemname].inventory_image + if not texture or texture == "" then + texture = minetest.registered_items[itemname].wield_image + end + if texture and texture ~= "" then + minetest.add_particlespawner({ + amount = 20, + time = 0.1, + minpos = {x=pos.x, y=pos.y, z=pos.z}, + maxpos = {x=pos.x, y=pos.y, z=pos.z}, + minvel = {x=-1, y=1, z=-1}, + maxvel = {x=1, y=2, z=1}, + minacc = {x=0, y=-5, z=0}, + maxacc = {x=0, y=-9, z=0}, + minexptime = 1, + maxexptime = 1, + minsize = 1, + maxsize = 2, + collisiondetection = true, + vertical = false, + texture = texture, + }) + end minetest.sound_play("mcl_hunger_bite", { pos = pos, max_hear_distance = 12,