Implement doMobLoot gamerule

This commit is contained in:
teknomunk 2024-06-18 19:25:02 -05:00
parent c65cf67a46
commit 9af61bd342
1 changed files with 6 additions and 3 deletions

View File

@ -8,6 +8,10 @@ local gamerule_maxEntityCramming = vl_tuning.setting("gamerule:maxEntityCramming
description = S("The maximum number of pushable entities a mob or player can push, before taking 6♥♥♥ entity cramming damage per half-second."), description = S("The maximum number of pushable entities a mob or player can push, before taking 6♥♥♥ entity cramming damage per half-second."),
default = 24, default = 24,
}) })
local gamerule_doMobLoot = vl_tuning.setting("gamerule:doMobLoot", "bool", {
description = S("Whether mobs should drop items and experience orbs."),
default = true,
})
local CRAMMING_DAMAGE = 3 local CRAMMING_DAMAGE = 3
local DEATH_DELAY = 0.5 local DEATH_DELAY = 0.5
@ -478,6 +482,8 @@ function mob_class:check_for_death(cause, cmi_cause)
-- TODO other env damage shouldn't drop xp -- TODO other env damage shouldn't drop xp
-- "rain", "water", "drowning", "suffocation" -- "rain", "water", "drowning", "suffocation"
if not gamerule_doMobLoot[1] then return end
-- dropped cooked item if mob died in fire or lava -- dropped cooked item if mob died in fire or lava
if cause == "lava" or cause == "fire" then if cause == "lava" or cause == "fire" then
self:item_drop(true, 0) self:item_drop(true, 0)
@ -507,13 +513,10 @@ function mob_class:check_for_death(cause, cmi_cause)
end end
end end
end end
end end
-- execute custom death function -- execute custom death function
if self.on_die then if self.on_die then
local pos = self.object:get_pos() local pos = self.object:get_pos()
local on_die_exit = self.on_die(self, pos, cmi_cause) local on_die_exit = self.on_die(self, pos, cmi_cause)
if on_die_exit ~= true then if on_die_exit ~= true then