Code:
function giveEnchantBook(player: player, item: item, name: text):
give {_player} {_item} named "%{_name}%"
function giveCustomEnchantBook(player: player, item: item, name: text, lore1: text = "", lore2: text = "", lore3: text = "", lore4: text = "", lore5: text = "", lore6: text = "", lore7: text = "", lore8: text = ""):
give {_player} {_item} named "%{_name}%" with lore {_lore1}, {_lore2}, {_lore3}, {_lore4}, {_lore5}, {_lore6}, {_lore7}, {_lore8}
options:
commonCustomEnchantLevel: 15
commonEnchantName: &7&lCommon Enchant
uncommonCustomEnchantLevel: 30
uncommonEnchantName: &a&lUncommon Enchant
rareCustomEnchantLevel: 45
rareEnchantName: &9&lRare Enchant
uniqueCustomEnchantLevel: 60
uniqueEnchantName: &e&lUnique Enchant
legendaryCustomEnchantLevel: 75
legendaryEnchantName: &6&lLegendary Enchant
mythicalCustomEnchantLevel: 100
mythicalEnchantName: &d&lMythical Enchant
function ceGUI(slot: integer, item: item, name: text):
set slot {_slot} of {_gui} to {_item} named {_name}
command /ce:
aliases: /customenchants, /customenchant, /enchants
trigger:
set {_gui} to a new chest inventory with 6 rows named "&b&lCustom Enchants"
set slot (integers between 0 and 53) of {_gui} to gray stained glass pane
ceGUI(10, glowing book, "{@commonEnchantName}")
ceGUI(13, glowing book, "{@uncommonEnchantName}")
ceGUI(16, glowing book, "{@rareEnchantName}")
ceGUI(37, glowing book, "{@uniqueEnchantName}")
ceGUI(40, glowing book, "{@legendaryEnchantName}")
ceGUI(43, glowing book, "{@mythicalEnchantName}")
open {_gui} to player
function buyCustomEnchantBook(Custom_Enchant_Level: integer, Custom_Enchant_Name: text):
if {_p}'s level >= "{_Custom_Enchant_Level}":
remove ("{_Custom_Enchant_Level}" parsed as an integer) from {_p}'s level
giveEnchantBook({_p}, book, "{_Custom_Enchant_Name}")
send "You received a {_Custom_Enchant_Name} Book" to {_p}
on inventory click:
if name of event-inventory is "&x&F&F&F&F&F&F&lC&x&F&5&E&B&F&5&lu&x&E&B&D&8&E&B&ls&x&E&2&C&4&E&2<&x&D&8&B&1&D&8&lo&x&C&E&9&D&C&E&lm &x&C&4&8&9&C&4&lE&x&B&B&7&6&B&B&ln&x&B&1&6&2&B&1&lc&x&A&7&4&E&A&7&lh&x&9&D&3&B&9&D&la&x&9&4&2&7&9&4&ln&x&8&A&1&4&8&A<&x&8&0&0&0&8&0&ls":
if index of event-slot = (integers between 0 and 54):
cancel event
if index of event-slot = 10:
buyCustomEnchantBook({@commonCustomEnchantLevel}, "{@commonEnchantName}")
else if index of event-slot = 13:
buyCustomEnchantBook({@uncommonCustomEnchantLevel}, "{@uncommonEnchantName}")
else if index of event-slot = 16:
buyCustomEnchantBook({@rareCustomEnchantLevel}, "{@rareEnchantName}")
else if index of event-slot = 37:
buyCustomEnchantBook({@uniqueCustomEnchantLevel}, "{@uniqueEnchantName}")
else if index of event-slot = 40:
buyCustomEnchantBook({@legendaryCustomEnchantLevel}, "{@legendaryEnchantName}")
else if index of event-slot = 43:
buyCustomEnchantBook({@mythicalCustomEnchantLevel}, "{@mythicalEnchantName}")
on right click:
if event-item is book named "{@commonEnchantName}":
set {_enchantInteger} to a random integer between 1 and 2
if {_enchantInteger} is 1:
giveCustomEnchantBook(player, enchanted book, "&7&lSmelter", "&l&oDescription:", "&7&lSmelts ores into ingot form.", "", "&l&oAppliable To:", "Tools", "", "&l&oRarity:", "&7&lCommon")
else if {_enchantInteger} is 2:
set {_nausea_level} to random integer between 1 and 100
if {_nausea_level} = (integers between 1 and 75): # 75%
set {_common::nausea::level} to 1
else if {_nausea_level} = (integers between 75 and 90):
set {_common::nausea::level} to 2
else if {_nausea_level} = (integers between 90 and 100):
set {_common::nausea::level} to 3
giveCustomEnchantBook(player, enchanted book, "&7&lNausea %{_common::nausea::level}%", "&l&oDescription:", "&7")
function applyEffectFromCustomEnchant(attacker: player, Enchant_Name: text, chance: integer, Effect_Name: text, Effect_Level: text, victim: player, Effect_Time: text):
if lore of {_attacker}'s held item contains "{_Enchant_Name}":
chance of {_chance}%:
apply ({_Enchant_Name} parsed as potion effect type) ({_Effect_Level} parsed as number) to {_victim} for ({_Effect_Time} parsed as timespan)
on damage:
if victim is a player:
# NAUSEA
applyEffectFromCustomEnchant(attacker, "&7&lNausea III", 6, "nausea", "3", victim, "13 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lNausea II", 10, "nausea", "2", victim, "10 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lNausea I", 14, "nausea", "1", victim, "7 seconds")
# POISON
applyEffectFromCustomEnchant(attacker, "&7&lPoison V", 6, "poison", "5", victim, "10 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lPoison IV", 11, "poison", "4", victim, "8 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lPoison III", 16, "poison", "3", victim, "6 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lPoison II", 21, "poison", "2", victim, "4 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lPoison I", 26, "poison", "1", victim, "2 seconds")
# WITHER
applyEffectFromCustomEnchant(attacker, "&7&lWither V", 6, "wither", "5", victim, "10 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lWither IV", 11, "wither", "4", victim, "8 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lWither III", 16, "wither", "3", victim, "6 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lWither II", 21, "wither", "2", victim, "4 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lWither I", 26, "wither", "1", victim, "2 seconds")
# BLINDNESS
applyEffectFromCustomEnchant(attacker, "&7&lBlindness V", 6, "blindness", "5", victim, "10 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lBlindness IV", 11, "blindness", "4", victim, "8 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lBlindness III", 16, "blindness", "3", victim, "6 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lBlindness II", 21, "blindness", "2", victim, "4 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lBlindness I", 26, "blindness", "1", victim, "2 seconds")
# SLOWNESS
applyEffectFromCustomEnchant(attacker, "&7&lSlowness V", 6, "slowness", "5", victim, "10 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lSlowness IV", 11, "slowness", "4", victim, "8 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lSlowness III", 16, "slowness", "3", victim, "6 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lSlowness II", 21, "slowness", "2", victim, "4 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lSlowness I", 26, "slowness", "1", victim, "2 seconds")
# WEAKNESS
applyEffectFromCustomEnchant(attacker, "&7&lWeakness V", 6, "weakness", "5", victim, "10 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lWeakness IV", 11, "weakness", "4", victim, "8 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lWeakness III", 16, "weakness", "3", victim, "6 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lWeakness II", 21, "weakness", "2", victim, "4 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lWeakness I", 26, "weakness", "1", victim, "2 seconds")
# HUNGER
applyEffectFromCustomEnchant(attacker, "&7&lHunger V", 6, "hunger", "5", victim, "10 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lHunger IV", 11, "hunger", "4", victim, "8 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lHunger III", 16, "hunger", "3", victim, "6 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lHunger II", 21, "hunger", "2", victim, "4 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lHunger I", 26, "hunger", "1", victim, "2 seconds")
# DARKNESS
applyEffectFromCustomEnchant(attacker, "&7&lDarkness V", 6, "darkness", "5", victim, "10 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lDarkness IV", 11, "darkness", "4", victim, "8 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lDarkness III", 16, "darkness", "3", victim, "6 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lDarkness II", 21, "darkness", "2", victim, "4 seconds")
applyEffectFromCustomEnchant(attacker, "&7&lDarkness I", 26, "darkness", "1", victim, "2 seconds")
how do I make this more efficient? I'm currently using functions to make this reusable. But, I'm not 100% sure if I'm doing it the best way that I can? Because it just looks very clunky, and unorganized. If you could tell me what I'm doing wrong, ( if anything ), and how I could fix it?[/CODE]