Check enable damage instead of creative mode in some cases

This commit is contained in:
parent 3aaf0f3e29
commit b573f6314c
4 changed files with 7 additions and 7 deletions

View File

@ -1,3 +1,5 @@
local enable_damage = minetest.settings:get_bool("enable_damage")
function mcl_burning.get_storage(obj) function mcl_burning.get_storage(obj)
return obj:is_player() and mcl_burning.storage[obj] or obj:get_luaentity() return obj:is_player() and mcl_burning.storage[obj] or obj:get_luaentity()
end end
@ -77,7 +79,7 @@ end
-- The effective burn duration is modified by obj's armor protection. -- The effective burn duration is modified by obj's armor protection.
-- If obj was already burning, its burn duration is updated if the current -- If obj was already burning, its burn duration is updated if the current
-- duration is less than burn_time. -- duration is less than burn_time.
-- If obj is dead, fireproof or a creative player, this function does nothing. -- If obj is dead, fireproof or enable_damage is disabled, this function does nothing.
-- --
function mcl_burning.set_on_fire(obj, burn_time) function mcl_burning.set_on_fire(obj, burn_time)
if obj:get_hp() < 0 then if obj:get_hp() < 0 then
@ -89,8 +91,9 @@ function mcl_burning.set_on_fire(obj, burn_time)
return return
end end
if obj:is_player() and minetest.is_creative_enabled(obj:get_player_name()) then if obj:is_player() and not enable_damage then
burn_time = 0 burn_time = 0
return
else else
local max_fire_prot_lvl = 0 local max_fire_prot_lvl = 0
local inv = mcl_util.get_inventory(obj) local inv = mcl_util.get_inventory(obj)

View File

@ -1910,7 +1910,6 @@ end
-- find someone to attack -- find someone to attack
local monster_attack = function(self) local monster_attack = function(self)
if not damage_enabled if not damage_enabled
or minetest.is_creative_enabled("")
or self.passive ~= false or self.passive ~= false
or self.state == "attack" or self.state == "attack"
or day_docile(self) then or day_docile(self) then

View File

@ -42,6 +42,7 @@ minetest.register_entity("mobs_mc:ender_eyes", {
}) })
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator("mobs_mc")
local enable_damage = minetest.settings:get_bool("enable_damage")
local telesound = function(pos, is_source) local telesound = function(pos, is_source)
local snd local snd
@ -412,7 +413,7 @@ mcl_mobs:register_mob("mobs_mc:enderman", {
-- self:teleport(nil) -- self:teleport(nil)
-- self.state = "" -- self.state = ""
--else --else
if self.attack ~= nil and not minetest.settings:get_bool("creative_mode") then if self.attack ~= nil and enable_damage then
self.state = 'attack' self.state = 'attack'
end end
--end --end

View File

@ -605,9 +605,6 @@ end)
-- Don't change HP if the player falls in the water or through End Portal: -- Don't change HP if the player falls in the water or through End Portal:
mcl_damage.register_modifier(function(obj, damage, reason) mcl_damage.register_modifier(function(obj, damage, reason)
if reason.type == "fall" then if reason.type == "fall" then
if minetest.is_creative_enabled(obj:get_player_name()) then
return 0
end
local pos = obj:get_pos() local pos = obj:get_pos()
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local velocity = obj:get_velocity() or obj:get_player_velocity() or {x=0,y=-10,z=0} local velocity = obj:get_velocity() or obj:get_player_velocity() or {x=0,y=-10,z=0}