From 4de3bfda8e838c7173204d7780ebcdc21d536674 Mon Sep 17 00:00:00 2001 From: kay27 Date: Mon, 21 Jun 2021 02:47:20 +0400 Subject: [PATCH] [extra_mobs] Fix critical attempt to index local c_pos (a nil value) --- mods/ENTITIES/extra_mobs/piglin.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/extra_mobs/piglin.lua b/mods/ENTITIES/extra_mobs/piglin.lua index babd6c476b..35fa8a2f47 100644 --- a/mods/ENTITIES/extra_mobs/piglin.lua +++ b/mods/ENTITIES/extra_mobs/piglin.lua @@ -127,9 +127,11 @@ local piglin = { self.state = "stand" end local c_pos = self.object:get_pos() - self.what_traded = trading_items[math.random(#trading_items)] - for x = 1, math.random(self.what_traded.amount_min, self.what_traded.amount_max) do - minetest.add_item({x=math.random(c_pos.x - 1, c_pos.x + 1), y=math.random(c_pos.y - 1, c_pos.y + 1), z= math.random(c_pos.z - 1, c_pos.z + 1)}, self.what_traded.itemstring) + if c_pos then + self.what_traded = trading_items[math.random(#trading_items)] + for x = 1, math.random(self.what_traded.amount_min, self.what_traded.amount_max) do + minetest.add_item({x=math.random(c_pos.x - 1, c_pos.x + 1), y=math.random(c_pos.y - 1, c_pos.y + 1), z= math.random(c_pos.z - 1, c_pos.z + 1)}, self.what_traded.itemstring) + end end end) end