From f65c40f805a7d9311519755a22725c5f4bfb38c9 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Tue, 6 Apr 2021 17:20:11 +0200 Subject: [PATCH] Make dragon egg teleport on punching --- mods/ITEMS/mcl_end/building.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_end/building.lua b/mods/ITEMS/mcl_end/building.lua index 3dcf0671e..94fd26434 100644 --- a/mods/ITEMS/mcl_end/building.lua +++ b/mods/ITEMS/mcl_end/building.lua @@ -169,7 +169,16 @@ minetest.register_node("mcl_end:dragon_egg", { sounds = mcl_sounds.node_sound_stone_defaults(), _mcl_blast_resistance = 9, _mcl_hardness = 3, - -- TODO: Make dragon egg teleport on punching + on_punch = function(pos, node) + local max_dist = vector.new(15, 7, 15) + local positions = minetest.find_nodes_in_area(vector.subtract(pos, max_dist), vector.add(pos, max_dist), "air", false) + if #positions > 0 then + local tpos = positions[math.random(#positions)] + minetest.remove_node(pos) + minetest.set_node(tpos, node) + minetest.check_for_falling(tpos) + end + end, })