Skip to content

Commit

Permalink
Fix //allocate with 0 nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Jul 16, 2019
1 parent b2e086f commit 4f2c7b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion worldedit/serialization.lua
Expand Up @@ -196,7 +196,7 @@ end
-- @return The number of nodes.
function worldedit.allocate(origin_pos, value)
local nodes = load_schematic(value)
if not nodes then return nil end
if not nodes or #nodes == 0 then return nil end
return worldedit.allocate_with_nodes(origin_pos, nodes)
end
Expand Down
6 changes: 6 additions & 0 deletions worldedit_commands/init.lua
Expand Up @@ -1163,9 +1163,15 @@ minetest.register_chatcommand("/allocate", {
return
elseif version > worldedit.LATEST_SERIALIZATION_VERSION then
worldedit.player_notify(name, "File was created with newer version of WorldEdit!")
return
end
local nodepos1, nodepos2, count = worldedit.allocate(pos, value)

if not nodepos1 then
worldedit.player_notify(name, "Schematic empty, nothing allocated")
return
end

worldedit.pos1[name] = nodepos1
worldedit.mark_pos1(name)
worldedit.pos2[name] = nodepos2
Expand Down

0 comments on commit 4f2c7b1

Please sign in to comment.