Fix endermen teleporting in the rain in the end per issue #1169.

This commit is contained in:
MysticTempest 2021-02-25 21:48:37 -06:00
parent 73616453a4
commit 2ace4ccc68
1 changed files with 29 additions and 26 deletions

View File

@ -242,36 +242,39 @@ mobs:register_mob("mobs_mc:enderman", {
}) })
end end
-- RAIN DAMAGE / EVASIVE WARP BEHAVIOUR HERE. -- RAIN DAMAGE / EVASIVE WARP BEHAVIOUR HERE.
if mcl_weather.state == "rain" or mcl_weather.state == "lightning" then local dim = mcl_worlds.pos_to_dimension(enderpos)
local damage = true if dim == "overworld" then
local enderpos = self.object:get_pos() if mcl_weather.state == "rain" or mcl_weather.state == "lightning" then
enderpos.y = enderpos.y+2.89 local damage = true
local height = {x=enderpos.x, y=enderpos.y+512,z=enderpos.z} local enderpos = self.object:get_pos()
local ray = minetest.raycast(enderpos, height, true) enderpos.y = enderpos.y+2.89
-- Check for blocks above enderman. local height = {x=enderpos.x, y=enderpos.y+512,z=enderpos.z}
for pointed_thing in ray do local ray = minetest.raycast(enderpos, height, true)
if pointed_thing.type == "node" then -- Check for blocks above enderman.
local nn = minetest.get_node(minetest.get_pointed_thing_position(pointed_thing)).name for pointed_thing in ray do
local def = minetest.registered_nodes[nn] if pointed_thing.type == "node" then
if (not def) or def.walkable then local nn = minetest.get_node(minetest.get_pointed_thing_position(pointed_thing)).name
-- There's a node in the way. Delete arrow without damage local def = minetest.registered_nodes[nn]
damage = false if (not def) or def.walkable then
break -- There's a node in the way. Delete arrow without damage
damage = false
break
end
end end
end end
end
if damage == true then if damage == true then
self.state = "" self.state = ""
--rain hurts enderman --rain hurts enderman
self.object:punch(self.object, 1.0, { self.object:punch(self.object, 1.0, {
full_punch_interval=1.0, full_punch_interval=1.0,
damage_groups={fleshy=self._damage}, damage_groups={fleshy=self._damage},
}, nil) }, nil)
--randomly teleport hopefully under something. --randomly teleport hopefully under something.
self:teleport(nil) self:teleport(nil)
end
end end
end else return end
-- AGRESSIVELY WARP/CHASE PLAYER BEHAVIOUR HERE. -- AGRESSIVELY WARP/CHASE PLAYER BEHAVIOUR HERE.
if self.state == "attack" then if self.state == "attack" then
--if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then --if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then