Boats: Avoid crash if boat pos over limit

If the boat pos is over limit, 'add entity' will not add an entity,
causing 'boat' to be nil.
This commit is contained in:
paramat 2016-12-21 07:38:27 +00:00
parent 12b1541971
commit 3c9d0893ee
1 changed files with 5 additions and 3 deletions

View File

@ -233,9 +233,11 @@ minetest.register_craftitem("boats:boat", {
end end
pointed_thing.under.y = pointed_thing.under.y + 0.5 pointed_thing.under.y = pointed_thing.under.y + 0.5
boat = minetest.add_entity(pointed_thing.under, "boats:boat") boat = minetest.add_entity(pointed_thing.under, "boats:boat")
boat:setyaw(placer:get_look_horizontal()) if boat then
if not minetest.setting_getbool("creative_mode") then boat:setyaw(placer:get_look_horizontal())
itemstack:take_item() if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
end end
return itemstack return itemstack
end, end,