From 602b75c94da2d2a1359a3591cb863d1a1d7fcffc Mon Sep 17 00:00:00 2001 From: Michael Karneim Date: Fri, 5 Oct 2018 20:22:00 +0200 Subject: [PATCH] =?UTF-8?q?=C3=83=C3=83Initial=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feather.lua | 27 +++++++++++++++++++++++++ give-feather.lua | 21 ++++++++++++++++++++ particle-trail.lua | 49 ++++++++++++++++++++++++++++++++++++++++++++++ startup.lua | 6 ++++++ 4 files changed, 103 insertions(+) create mode 100644 feather.lua create mode 100644 give-feather.lua create mode 100644 particle-trail.lua create mode 100644 startup.lua diff --git a/feather.lua b/feather.lua new file mode 100644 index 0000000..06b4efe --- /dev/null +++ b/feather.lua @@ -0,0 +1,27 @@ +-- featherlight/feather.lua +-- /lua require('featherlight.feather').start() + +local pkg = {} +local module = ... + +function pkg.start() + singleton() + Events.on("SwingArmEvent"):call(function(event) + local item = event.item + if item and item.nbt and item.nbt.tag and item.nbt.tag.Wand == "featherlight-flight" then + local p = event.player + if p.motion:sqrMagnitude() < 0.1 then + p.motion = p.lookVec * 1.3 + else + p.motion = p.motion + p.lookVec * 0.5 + end + end + end) +end + +function singleton() + spell:execute([[/wol spell break byName "%s"]],module) + spell.name = module +end + +return pkg diff --git a/give-feather.lua b/give-feather.lua new file mode 100644 index 0000000..0965953 --- /dev/null +++ b/give-feather.lua @@ -0,0 +1,21 @@ +-- featherlight/give-feather.lua +-- /lua require('featherlight.give-feather').register() +-- /lua require('featherlight.give-feather').giveFeather() + +local pkg = {} +local module = ... + +function pkg.register() + Commands.register("give-feather",string.format([[ + require('%s').giveFeather(...) + ]],module), "/give-feather []", 1) +end + +function pkg.giveFeather(player) + player = player or spell.owner.name + spell:execute([[/give %s minecraft:feather 1 0 + {Wand:"featherlight-flight",display:{Name:"Wand of Featherlight Flight",Lore:["Look into the sky and swing this wand"]},ench:[{id:99,lvl:1}]} + ]], player) +end + +return pkg diff --git a/particle-trail.lua b/particle-trail.lua new file mode 100644 index 0000000..2c74e32 --- /dev/null +++ b/particle-trail.lua @@ -0,0 +1,49 @@ +-- featherlight/particle-trail.lua +-- /lua require('featherlight.particle-trail').start() + +local pkg = {} +local module = ... + +function pkg.start() + singleton() + local players = Entities.find("@a") + Events.on("PlayerLoggedInEvent"):call(function(event) + table.insert(players,event.player) + end) + Events.on("PlayerLoggedOutEvent"):call(function(event) + for i,p in pairs(players) do + if players[i] == p then + table.remove(players,i) + break + end + end + end) + while true do + for _,p in pairs(players) do + local item = p.mainhand + if item and item.nbt and item.nbt.tag and item.nbt.tag.Wand == "featherlight-flight" then + if p.motion:sqrMagnitude() > 0.1 then + spell.rotationYaw = p.rotationYaw + spell.pos = p.pos - 0.2 * spell.lookVec + spell:move("up",0.2) + pkg.particle() + end + end + end + sleep(1) + if Time.gametime % (20*10) == 0 then + players = Entities.find("@a") + end + end +end + +function pkg.particle() + spell:execute("/particle flame ~ ~0.2 ~ 0 0 0 0.01 100 force @a") +end + +function singleton() + spell:execute([[/wol spell break byName "%s"]],module) + spell.name = module +end + +return pkg diff --git a/startup.lua b/startup.lua new file mode 100644 index 0000000..facf346 --- /dev/null +++ b/startup.lua @@ -0,0 +1,6 @@ +-- featherlight/startup.lua + +spell:execute([[/lua require('featherlight.feather').start()]]) +spell:execute([[/lua require('featherlight.particle-trail').start()]]) + +require('featherlight.give-feather').register()