Created
June 19, 2020 18:10
-
-
Save Penguin-Spy/1cc55d946afea8fb0b12be79c6a4a28c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # get_tool_durability.mcfunction by Penguin_Spy in 2020 | |
| # function to set lore of tool to durability of tool | |
| # ran by the player, updates line 4 of lore of current tool | |
| # all scoreboards are dummy, the fake player stone_axe has a toolDurabilities score of 131 (the max durability) | |
| # expects a blank sign @ 10 129 -13, and a shulker box @ 11 129 -13 | |
| execute store result score @s durability run data get entity @s SelectedItem.tag.Damage | |
| scoreboard players operation @s durability *= -1 constants | |
| #choose which one based on SelectedItem.id | |
| scoreboard players operation @s durability += stone_axe toolDurabilities | |
| #sign, todo: make last text based on scoreboard chosen by SelectedItem.id | |
| data modify block 10 129 -13 Text1 set value '{"text":" ","color":"blue","italic":"false","extra":[{"score":{"objective":"durability","name":"@p"}},{"text":"/131"}]}' | |
| #shulker box | |
| data modify block 11 129 -13 Items[{Slot:0b}] set from entity @s SelectedItem | |
| data modify block 11 129 -13 Items[{Slot:0b}].tag.display.Lore[3] set from block 10 129 -13 Text1 | |
| #clears armor and offhand for some reason: mc bug | |
| #also requires custom loottable for shulkerboxes to drop only their contents | |
| loot replace entity @s weapon.mainhand mine 11 129 -13 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment