From ebab220fb2318ac725b6d91456682c7ec658e397 Mon Sep 17 00:00:00 2001 From: NO11 Date: Tue, 13 Apr 2021 20:33:34 +0000 Subject: [PATCH] add rocket for elytra boost --- mods/ITEMS/mcl_fireworks/README.txt | 7 ++++ mods/ITEMS/mcl_fireworks/config.txt | 2 + mods/ITEMS/mcl_fireworks/crafting.lua | 17 +++++++++ mods/ITEMS/mcl_fireworks/init.lua | 4 ++ mods/ITEMS/mcl_fireworks/register.lua | 55 +++++++++++++++++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 mods/ITEMS/mcl_fireworks/README.txt create mode 100644 mods/ITEMS/mcl_fireworks/config.txt create mode 100644 mods/ITEMS/mcl_fireworks/crafting.lua create mode 100644 mods/ITEMS/mcl_fireworks/init.lua create mode 100644 mods/ITEMS/mcl_fireworks/register.lua diff --git a/mods/ITEMS/mcl_fireworks/README.txt b/mods/ITEMS/mcl_fireworks/README.txt new file mode 100644 index 0000000000..4cf71fc9b1 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/README.txt @@ -0,0 +1,7 @@ +Firework mod for Mineclone 2 + +by NO11 and and some parts by j45 + +Sound credits: + +* mcl_firework_rocket.ogg (tnt_ignite.ogg): Own derivate work of sound by Ned Bouhalassa (CC0) created in 2005, source: diff --git a/mods/ITEMS/mcl_fireworks/config.txt b/mods/ITEMS/mcl_fireworks/config.txt new file mode 100644 index 0000000000..5a12a1f527 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/config.txt @@ -0,0 +1,2 @@ +name = mcl_firework +author = NO11, j45 diff --git a/mods/ITEMS/mcl_fireworks/crafting.lua b/mods/ITEMS/mcl_fireworks/crafting.lua new file mode 100644 index 0000000000..a9e156aa69 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/crafting.lua @@ -0,0 +1,17 @@ +minetest.register_craft({ + type = "shapeless", + output = "mcl_fireworks:rocket_1 3", + recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "mcl_fireworks:rocket_2 3", + recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "mcl_fireworks:rocket_3 3", + recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder"}, +}) \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/init.lua b/mods/ITEMS/mcl_fireworks/init.lua new file mode 100644 index 0000000000..cd19225805 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/init.lua @@ -0,0 +1,4 @@ +local path = minetest.get_modpath("mcl_fireworks") + +dofile(path .. "/register.lua") +dofile(path .. "/crafting.lua") \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/mcl_fireworks/register.lua new file mode 100644 index 0000000000..cb8d89e58e --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/register.lua @@ -0,0 +1,55 @@ +local S = minetest.get_translator("mcl_fireworks") + +local help = S("Flight Duration:") +local description = S("Firework Rocket") +local rocket_sound = function() + minetest.sound_play("mcl_fireworks_rocket") +end + +minetest.register_craftitem("mcl_fireworks:rocket_1", { + description = description, + _tt_help = help.." 1", + inventory_image = "mcl_fireworks_rocket.png", + stack_max = 64, + on_use = function(itemstack, user, pointed_thing) + itemstack:take_item() + local torso = user:get_inventory():get_stack("armor", 3) + if torso and torso:get_name() == "mcl_armor:elytra" then + user:add_player_velocity(vector.multiply(user:get_look_dir(), 20)) + rocket_sound() + end + return itemstack + end, +}) + +minetest.register_craftitem("mcl_fireworks:rocket_2", { + description = description, + _tt_help = help.." 2", + inventory_image = "mcl_fireworks_rocket.png", + stack_max = 64, + on_use = function(itemstack, user, pointed_thing) + itemstack:take_item() + local torso = user:get_inventory():get_stack("armor", 3) + if torso and torso:get_name() == "mcl_armor:elytra" then + user:add_player_velocity(vector.multiply(user:get_look_dir(), 30)) + rocket_sound() + end + return itemstack + end, +}) + +minetest.register_craftitem("mcl_fireworks:rocket_3", { + description = description, + _tt_help = help.." 3", + inventory_image = "mcl_fireworks_rocket.png", + stack_max = 64, + on_use = function(itemstack, user, pointed_thing, player) + itemstack:take_item() + local torso = user:get_inventory():get_stack("armor", 3) + if torso and torso:get_name() == "mcl_armor:elytra" then + user:add_player_velocity(vector.multiply(user:get_look_dir(), 40)) + rocket_sound() + end + return itemstack + end, +})