diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index f20c46eac4..d78f2fbfeb 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -235,6 +235,23 @@ minetest.register_on_leaveplayer( function(player) _reset_player_effects(player) minetest.register_on_dieplayer( function(player) _reset_player_effects(player) end) +function mcl_potions.is_obj_hit(self, pos) + + for _,object in pairs(minetest.get_objects_inside_radius(pos, 1.1)) do + + local entity = object:get_luaentity() + + if entity and entity.name ~= self.object:get_luaentity().name then + + if object:is_player() or entity._cmi_is_mob then return true end + + end + + end + return false +end + + function mcl_potions.make_invisible(player, toggle) if not player then return false end diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index 26b5c3c12b..cd99e85b1f 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -19,7 +19,9 @@ local function register_lingering(name, descr, color, def) local obj = minetest.env:add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) obj:setacceleration({x=0, y=-9.8, z=0}) - item:take_item() + if not minetest.settings:get_bool("creative_mode") then + item:take_item() + end return item end, stack_max = 1, @@ -38,7 +40,7 @@ local function register_lingering(name, descr, color, def) local n = node.name local d = 2 local redux_map = {7/8,0.5,0.25} - if n ~= "air" then + if n ~= "air" or mcl_potions.is_obj_hit(self, pos) then minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) minetest.add_particlespawner({ amount = 1000, diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index d1d2708db7..4745881b9a 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -5,6 +5,7 @@ local splash_image = function(colorstring, opacity) return "mcl_potions_splash_overlay.png^[colorize:"..colorstring..":"..tostring(opacity).."^mcl_potions_splash_bottle.png" end + local function register_splash(name, descr, color, def) local id = "mcl_potions:"..name.."_splash" @@ -18,7 +19,9 @@ local function register_splash(name, descr, color, def) local obj = minetest.env:add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") obj:set_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) obj:set_acceleration({x=0, y=-9.8, z=0}) - item:take_item() + if not minetest.settings:get_bool("creative_mode") then + item:take_item() + end return item end, stack_max = 1, @@ -37,7 +40,7 @@ local function register_splash(name, descr, color, def) local n = node.name local d = 2 local redux_map = {7/8,0.5,0.25} - if n ~= "air" then + if n ~= "air" or mcl_potions.is_obj_hit(self, pos) then minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) minetest.add_particlespawner({ amount = 50,