mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
Attempt to fix more crash errors.
This commit is contained in:
parent
d19bedc6d2
commit
7b9a79658d
@ -268,12 +268,15 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||
else
|
||||
if self.attack then
|
||||
target = self.attack
|
||||
pos = target:get_pos()
|
||||
if pos ~= nil then
|
||||
if vector.distance(self.object:get_pos(), target:get_pos()) > 10 then
|
||||
self:teleport(target)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- ARROW / DAYTIME PEOPLE AVOIDANCE BEHAVIOUR HERE.
|
||||
-- Check for arrows and people nearby.
|
||||
local enderpos = self.object:get_pos()
|
||||
@ -438,6 +441,7 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||
-- Find all solid nodes below air in a 10×10×10 cuboid centered on the target
|
||||
local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(target_pos, 5), vector.add(target_pos, 5), {"group:solid", "group:cracky", "group:crumbly"})
|
||||
local telepos
|
||||
if nodes ~= nil then
|
||||
if #nodes > 0 then
|
||||
-- Up to 64 attempts to teleport
|
||||
for n=1, math.min(64, #nodes) do
|
||||
@ -460,12 +464,14 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||
self.object:set_pos(telepos)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Attempt to randomly teleport enderman
|
||||
local pos = self.object:get_pos()
|
||||
-- Find all solid nodes below air in a 65×65×65 cuboid centered on the enderman
|
||||
local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(pos, 32), vector.add(pos, 32), {"group:solid", "group:cracky", "group:crumbly"})
|
||||
local telepos
|
||||
if nodes ~= nil then
|
||||
if #nodes > 0 then
|
||||
-- Up to 64 attempts to teleport
|
||||
for n=1, math.min(64, #nodes) do
|
||||
@ -489,6 +495,7 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_die = function(self, pos)
|
||||
-- Drop carried node on death
|
||||
|
Loading…
Reference in New Issue
Block a user