#Copyright (c) 2023 eult#0001 options: #This option is meant to make it easier to add lifes #through commands so you don't have to change it #! It is impossible to go higher than 2147483647 lives. Base-lifes: 5 #this is the permission that is required to to allow #the user to use the command permission: itemlife.admin #Change this to true if you want the item to #not be dropped after death #NOTE; only enabled on keep inventory false Drop-on-keepInventory: false #! COMMAND command /itemlife [] [] []: aliases: il permission: {@permission} trigger: if arg-1 is not set: send "&8» &a/il &8[&aslot number &8|| &atool&8] &8[&eLifes&8] &8[&eplayer&8]" stop if arg-2 > 2147483647: send "&8» &cIt is impossible to go higher than &42,147,483,647&c lives." stop if arg-1 is "tool" or "t": if arg-2 is not set: set player's tool to setItemLifeTag(player's tool, {@Base-lifes}) else: if arg-3 is not set: set player's tool to setItemLifeTag(player's tool, arg-2) else: set arg-3's tool to setItemLifeTag(arg-3's tool, arg-2) play sound "block.note_block.pling" with volume 1 and pitch 2 to player stop if arg-1 partially matches "[A-Za-z]": send "&8» &eIt is not valid to enter &c/il %arg-1%&e." else: set {_number} to arg-1 parsed as integer if {_number} > 40: send "&8» &cIt is not possible to go higher than 40 slots." stop if arg-2 is not set: set slot {_number} of player's inventory to setItemLifeTag(slot {_number} of player's inventory, {@Base-lifes}) else: if arg-3 is not set: set slot {_number} of player's inventory to setItemLifeTag(slot {_number} of player's inventory, arg-2) else: set slot {_number} of arg-3's inventory to setItemLifeTag(slot {_number} of arg-3's inventory, arg-2) play sound "block.note_block.pling" with volume 1 and pitch 2 to player #! EVENTS on death of player: if gamerule keepInventory of world of victim is true: removeLifeTagInventory(victim) else: loop drops: if getItemLifeTag(loop-item) > 1: remove loop-value from drops if {@Drop-on-keepInventory} is true: add removeLifeTag(loop-value) to {ilRespawn::%victim%::*} else: drop removeLifeTag(loop-value) if getItemLifeTag(loop-value) = 1: remove loop-value from drops on respawn: if {ilRespawn::%player%::*} is set: give {ilRespawn::%player%::*} to player delete {ilRespawn::%player%::*} #! FUCNTIONS function removeLifeTagInventory(p: player): loop all items in the inventory of {_p}: if getItemLifeTag(loop-item) > 1: set loop-item to removeLifeTag(loop-item) else if getItemLifeTag(loop-item) = 1: set loop-item to air function setItemLifeTag(item: item, amount: integer) :: object: set {_n} to nbt compound of {_item} set int tag "life" of {_n} to {_amount} set {_item} to printItemLifeTag({_item}) return {_item} function printItemLifeTag(item: item) :: item: set {_loreSize::*} to lore of {_item} set {_lines} to 1 loop {_loreSize::*}: if line {_lines} of the lore of {_item} contains "Lives left": stop loop add 1 to {_lines} #! Looking for changing the lore? check the line under if getItemLifeTag({_item}) is 1: set line {_lines} of lore of {_item} to "&c%getItemLifeTag({_item})% &7Life left" else: set line {_lines} of lore of {_item} to "&e%getItemLifeTag({_item})% &7Lives left" #! Looking for changing the lore? check the line above return {_item} function getItemLifeTag(item: item) :: object: set {_nbt} to nbt compound of {_item} set {_i} to int tag "life" of {_nbt} return {_i} function removeLifeTag(item: item) :: object: set {_n} to nbt compound of {_item} remove 1 from int tag "life" of {_n} set {_item} to printItemLifeTag({_item}) return {_item}