Skip to content

Instantly share code, notes, and snippets.

@Adrodoc
Last active April 23, 2017 19:18
Show Gist options
  • Save Adrodoc/5f2b7a64704338a6f6f9e601ebb88039 to your computer and use it in GitHub Desktop.
Save Adrodoc/5f2b7a64704338a6f6f9e601ebb88039 to your computer and use it in GitHub Desktop.
enchantments
-- Beispiel: /give @p stick 1 0 {ANIMATION_HAND:"/tellraw @p {\"text\":\"You feel a strong aura while wielding this stick\",\"color\":\"blue\"}"}
if adrodoc55 == nil then
require "gist.5812f439642a1d4a9d89cdb75b38a13a.adrodoc55"
end
function adrodoc55.handleEnchantments()
spell:execute('tellraw @a {"text":"Enabling Item Enchantments!","color":"blue"}')
spell:execute('lua adrodoc55.handleEnchantment(ANIMATION_HAND)')
spell:execute('lua adrodoc55.handleEnchantment(CHAT)')
spell:execute('lua adrodoc55.handleEnchantment(LEFT_CLICK)')
spell:execute('lua adrodoc55.handleEnchantment(PLAYER_JOINED)')
spell:execute('lua adrodoc55.handleEnchantment(PLAYER_LEFT)')
spell:execute('lua adrodoc55.handleEnchantment(PLAYER_SPAWNED)')
spell:execute('lua adrodoc55.handleEnchantment(RIGHT_CLICK)')
spell:execute('lua adrodoc55.handleEnchantment(WHISPER)')
end
function adrodoc55.handleEnchantment(eventType)
local q = Events.register(eventType)
for e in q.next do
if e.player ~= nil and e.player.mainHand ~= nil then
local nbt = e.player.mainHand:getNbt()
if nbt ~= nil and nbt.tag ~= null and nbt.tag[eventType] ~= nil then
spell:execute('execute ' .. e.player.id .. ' ~ ~ ~ ' .. nbt.tag[eventType])
end
end
end
end
-- Beispiel: /give @p stick 1 0 {ANIMATION_HAND:"/tellraw @p {\"text\":\"You feel a strong aura while wielding this stick\",\"color\":\"blue\"}"}
if adrodoc55 == nil then
require "gist.5812f439642a1d4a9d89cdb75b38a13a.adrodoc55"
end
function adrodoc55.handleEnchantments()
spell:execute('tellraw @a {"text":"Enabling Item Enchantments!","color":"blue"}')
spell:execute('lua adrodoc55.handleEnchantment(ANIMATION_HAND)')
spell:execute('lua adrodoc55.handleEnchantment(CHAT)')
spell:execute('lua adrodoc55.handleEnchantment(LEFT_CLICK)')
spell:execute('lua adrodoc55.handleEnchantment(PLAYER_JOINED)')
spell:execute('lua adrodoc55.handleEnchantment(PLAYER_LEFT)')
spell:execute('lua adrodoc55.handleEnchantment(PLAYER_SPAWNED)')
spell:execute('lua adrodoc55.handleEnchantment(RIGHT_CLICK)')
spell:execute('lua adrodoc55.handleEnchantment(WHISPER)')
end
function adrodoc55.handleEnchantment(eventType)
local q = Events.register(eventType)
for e in q.next do
if e.player ~= nil and e.player.mainHand ~= nil then
local nbt = e.player.mainHand:getNbt()
if nbt ~= nil and nbt.tag ~= null and nbt.tag[eventType] ~= nil then
spell:execute('execute ' .. e.player.id .. ' ~ ~ ~ ' .. nbt.tag[eventType])
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment