1
0
Fork 0

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

View File

@ -395,4 +395,13 @@ function mcl_util.generate_on_place_plant_function(condition)
end end
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

View File

@ -2258,7 +2258,6 @@ local dogswitch = function(self, dtime)
return self.dogshoot_switch return self.dogshoot_switch
end end
-- execute current state (stand, walk, run, attacks) -- execute current state (stand, walk, run, attacks)
-- returns true if mob has died -- returns true if mob has died
local do_states = function(self, dtime) local do_states = function(self, dtime)
@ -2550,7 +2549,7 @@ local do_states = function(self, dtime)
if mod_explosions then if mod_explosions then
if mobs_griefing and not minetest.is_protected(pos, "") 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 else
minetest.sound_play(self.sounds.explode, { minetest.sound_play(self.sounds.explode, {
pos = pos, pos = pos,

View File

@ -71,7 +71,7 @@ mobs:register_mob("mobs_mc:creeper", {
if self._forced_explosion_countdown_timer ~= nil then if self._forced_explosion_countdown_timer ~= nil then
self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime
if self._forced_explosion_countdown_timer <= 0 then 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() self.object:remove()
end end
end end