Fix creeper explosions only doing 1/2 heart damage

The solution was to move the creeper explosions to originate from the
center of the creepers collisionbox and not its entity position.
This commit is contained in:
Elias Åström 2021-01-26 14:13:21 +01:00
parent 41bd803185
commit 5ecb56452e
3 changed files with 12 additions and 4 deletions

@ -395,4 +395,13 @@ function mcl_util.generate_on_place_plant_function(condition)
end
end
-- adjust the y level of an object to the center of its collisionbox
-- used to get the origin position of entity explosions
function mcl_util.get_object_center(obj)
local collisionbox = obj:get_properties().collisionbox
local pos = obj:get_pos()
local ymin = collisionbox[2]
local ymax = collisionbox[5]
pos.y = pos.y + (ymax - ymin) / 2.0
return pos
end

@ -2258,7 +2258,6 @@ local dogswitch = function(self, dtime)
return self.dogshoot_switch
end
-- execute current state (stand, walk, run, attacks)
-- returns true if mob has died
local do_states = function(self, dtime)
@ -2550,7 +2549,7 @@ local do_states = function(self, dtime)
if mod_explosions then
if mobs_griefing and not minetest.is_protected(pos, "") then
mcl_explosions.explode(self.object:get_pos(), self.explosion_strength, { drop_chance = 1.0 }, self.object)
mcl_explosions.explode(mcl_util.get_object_center(self.object), self.explosion_strength, { drop_chance = 1.0 }, self.object)
else
minetest.sound_play(self.sounds.explode, {
pos = pos,

@ -71,7 +71,7 @@ mobs:register_mob("mobs_mc:creeper", {
if self._forced_explosion_countdown_timer ~= nil then
self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime
if self._forced_explosion_countdown_timer <= 0 then
mobs:boom(self, self.object:get_pos(), self.explosion_strength)
mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength)
self.object:remove()
end
end