1
0
Fork 0

Attempt to fix more crash errors.

This commit is contained in:
Booglejr 2020-06-16 23:59:16 -05:00
parent d19bedc6d2
commit 7b9a79658d
No known key found for this signature in database
GPG Key ID: 9298653061C12F5B
1 changed files with 43 additions and 36 deletions

View File

@ -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