From 96be84161f1aaa153882bb17ef493470cbd81554 Mon Sep 17 00:00:00 2001 From: kay27 Date: Mon, 10 May 2021 01:57:34 +0400 Subject: [PATCH] [mcl_mapgen_core] Don't crash if Ender Dragon doesn't spawn for some reason --- mods/MAPGEN/mcl_mapgen_core/init.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 90b272506..bdcdb1b4d 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -1248,9 +1248,14 @@ local function generate_clay(minp, maxp, blockseed, voxelmanip_data, voxelmanip_ end local function generate_end_exit_portal(pos) - local dragon_entity = minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon"):get_luaentity() - dragon_entity._initial = true - dragon_entity._portal_pos = pos + local obj = minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon") + if obj then + local dragon_entity = obj:get_luaentity() + dragon_entity._initial = true + dragon_entity._portal_pos = pos + else + minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn") + end mcl_structures.call_struct(pos, "end_exit_portal") end