From 060a8538404846f8ed697c064d32c941219e5c93 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 27 Nov 2017 12:17:26 +0100 Subject: [PATCH] Add end escape pearl --- mods/MISC/mcl_temp_end_escape/depends.txt | 4 +++ mods/MISC/mcl_temp_end_escape/init.lua | 38 +++++++++++++++++++++++ mods/MISC/mcl_wip/init.lua | 6 ++-- 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 mods/MISC/mcl_temp_end_escape/depends.txt create mode 100644 mods/MISC/mcl_temp_end_escape/init.lua diff --git a/mods/MISC/mcl_temp_end_escape/depends.txt b/mods/MISC/mcl_temp_end_escape/depends.txt new file mode 100644 index 0000000000..5a27c903a3 --- /dev/null +++ b/mods/MISC/mcl_temp_end_escape/depends.txt @@ -0,0 +1,4 @@ +mcl_worlds +mcl_spawn +mcl_throwing +mcl_mobitems diff --git a/mods/MISC/mcl_temp_end_escape/init.lua b/mods/MISC/mcl_temp_end_escape/init.lua new file mode 100644 index 0000000000..4c9f2e1427 --- /dev/null +++ b/mods/MISC/mcl_temp_end_escape/init.lua @@ -0,0 +1,38 @@ +local escape = function(itemstack, user, pointed_thing) + local pos = user:get_pos() + if not pos then + return itemstack + end + local dim = mcl_worlds.pos_to_dimension(pos) + + if dim == "end" then + local target = mcl_spawn.get_spawn_pos(user) + user:set_pos(target) + minetest.sound_play("mcl_portals_teleport", {pos=target, gain=0.5, max_hear_distance = 16}) + itemstack:take_item() + else + minetest.chat_send_player(user:get_player_name(), "This item only works in the End.") + end + return itemstack +end + + +minetest.register_craftitem("mcl_temp_end_escape:end_escape_pearl", { + description = "End Escape Pearl", + _doc_items_longdesc = "With this item you can teleport from the End back to spawn point in the Overworld.".."\n".."This item will be removed in later versions.", + _doc_items_uagehelp = "Use rightclick to use. This only works in the End.", + inventory_image = "mcl_throwing_ender_pearl.png^[colorize:#0000FF:127", + wield_image = "mcl_throwing_ender_pearl.png^[colorize:#0000FF:127", + on_place = escape, + on_secondary_use = escape, + stack_max = 64, +}) + +minetest.register_craft({ + output = "mcl_temp_end_escape:end_escape_pearl", + type = "shapeless", + recipe = { + "mcl_throwing:ender_pearl","mcl_mobitems:shulker_shell", + "mcl_mobitems:shulker_shell","mcl_throwing:ender_pearl", + }, +}) diff --git a/mods/MISC/mcl_wip/init.lua b/mods/MISC/mcl_wip/init.lua index 8bcfb74b4d..538b34c40a 100644 --- a/mods/MISC/mcl_wip/init.lua +++ b/mods/MISC/mcl_wip/init.lua @@ -20,7 +20,9 @@ local wip_items = { "mcl_minecarts:tnt_minecart", "mcl_minecarts:activator_rail", } -local experimental_items = {} +local experimental_items = { + "mcl_temp_end_escape:end_escape_pearl", +} for i=1,#wip_items do local def = minetest.registered_items[wip_items[i]] @@ -42,7 +44,7 @@ for i=1,#experimental_items do break end local new_description = def.description - new_description = new_description .. "\n"..core.colorize("#FFFF00", "(Experimental)") + new_description = new_description .. "\n"..core.colorize("#FFFF00", "(Temporary)") minetest.override_item(experimental_items[i], { description = new_description }) end