From aa012ec574791eb34cf57b21f3658b29976410d8 Mon Sep 17 00:00:00 2001
From: BluePsychoRanger <40612230+BluePsychoRanger@users.noreply.github.com>
Date: Sun, 9 Jul 2023 02:49:09 -0700
Subject: [PATCH 1/4] Update Item Library
- Rewrote code to be more readable
- Documented the code
- Optimized functionality
- Fixed some bugs
---
smithed_libraries/packs/item/README.md | 18 +++-
smithed_libraries/packs/item/beet.yaml | 2 +-
.../advancements/impl/inventory_changed.json | 20 +++++
.../impl/technical/inventory_changed.json | 18 ----
.../durability/calc_durability.mcfunction | 63 -------------
.../impl/durability/calc_mending.mcfunction | 5 --
.../durability/calc_mending/clamp.mcfunction | 30 -------
.../calc_mending/return_overflow.mcfunction | 4 -
.../impl/durability/damage.mcfunction | 7 --
.../impl/durability/damage/boots.mcfunction | 8 --
.../impl/durability/damage/chest.mcfunction | 17 ++++
.../durability/damage/chestplate.mcfunction | 8 --
.../impl/durability/damage/feet.mcfunction | 17 ++++
.../impl/durability/damage/force.mcfunction | 15 ----
.../damage/force/calc_unbreaking.mcfunction | 28 ++++++
.../durability/damage/force/sub.mcfunction | 17 +++-
.../impl/durability/damage/head.mcfunction | 17 ++++
.../impl/durability/damage/helmet.mcfunction | 8 --
.../durability/damage/leggings.mcfunction | 8 --
.../impl/durability/damage/legs.mcfunction | 17 ++++
.../durability/damage/mainhand.mcfunction | 15 +++-
.../impl/durability/damage/offhand.mcfunction | 15 +++-
.../impl/durability/detect.mcfunction | 8 --
.../impl/durability/get_max.mcfunction | 87 ------------------
.../functions/impl/durability/init.mcfunction | 2 -
.../impl/durability/process/boots.mcfunction | 5 --
.../durability/process/chestplate.mcfunction | 5 --
.../impl/durability/process/handle.mcfunction | 5 --
.../impl/durability/process/helmet.mcfunction | 5 --
.../durability/process/leggings.mcfunction | 5 --
.../durability/process/mainhand.mcfunction | 6 --
.../durability/process/offhand.mcfunction | 5 --
.../track_changes/check_durability.mcfunction | 17 ++++
.../durability/track_changes/mark.mcfunction | 8 ++
.../track_changes/process/chest.mcfunction | 15 ++++
.../track_changes/process/feet.mcfunction | 15 ++++
.../track_changes/process/head.mcfunction | 15 ++++
.../track_changes/process/legs.mcfunction | 15 ++++
.../track_changes/process/mainhand.mcfunction | 15 ++++
.../track_changes/process/offhand.mcfunction | 15 ++++
.../track_changes/process_item.mcfunction | 15 ++++
.../durability/track_changes/wait.mcfunction | 6 ++
.../update/calc_durability.mcfunction | 65 ++++++++++++++
.../durability/update/initial_data.mcfunction | 90 +++++++++++++++++++
.../impl/durability/update/start.mcfunction | 17 ++++
.../functions/impl/technical/load.mcfunction | 13 ++-
.../impl/technical/player.mcfunction | 1 -
.../functions/impl/technical/tick.mcfunction | 3 -
.../item_modifiers/impl/update_nbt.json | 14 +++
.../item_modifiers/update_nbt.json | 16 ----
.../smithed.item/predicates/chance/10.json | 7 --
.../smithed.item/predicates/chance/11.json | 7 --
.../smithed.item/predicates/chance/12.json | 7 --
.../smithed.item/predicates/chance/14.json | 7 --
.../smithed.item/predicates/chance/16.json | 7 --
.../smithed.item/predicates/chance/20.json | 7 --
.../smithed.item/predicates/chance/25.json | 7 --
.../smithed.item/predicates/chance/33.json | 7 --
.../smithed.item/predicates/chance/50.json | 7 --
.../smithed.item/predicates/chance/9.json | 7 --
.../predicates/impl/chance/10.json | 4 +
.../predicates/impl/chance/11.json | 4 +
.../predicates/impl/chance/12.json | 4 +
.../predicates/impl/chance/14.json | 4 +
.../predicates/impl/chance/16.json | 4 +
.../predicates/impl/chance/20.json | 4 +
.../predicates/impl/chance/25.json | 4 +
.../predicates/impl/chance/33.json | 4 +
.../predicates/impl/chance/50.json | 4 +
.../predicates/impl/chance/9.json | 4 +
.../impl/has_custom_durability/chest.json | 14 +++
.../impl/has_custom_durability/feet.json | 14 +++
.../impl/has_custom_durability/head.json | 14 +++
.../impl/has_custom_durability/legs.json | 14 +++
.../impl/has_custom_durability/mainhand.json | 14 +++
.../impl/has_custom_durability/offhand.json | 14 +++
.../functions/event/item_changed/chest.json | 3 +
.../functions/event/item_changed/feet.json | 3 +
.../functions/event/item_changed/head.json | 3 +
.../functions/event/item_changed/legs.json | 3 +
.../event/item_changed/mainhand.json | 3 +
.../functions/event/item_changed/offhand.json | 3 +
82 files changed, 644 insertions(+), 413 deletions(-)
create mode 100644 smithed_libraries/packs/item/data/smithed.item/advancements/impl/inventory_changed.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/advancements/impl/technical/inventory_changed.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_durability.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_mending.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_mending/clamp.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_mending/return_overflow.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/boots.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/chest.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/chestplate.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/feet.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force/calc_unbreaking.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/head.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/helmet.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/leggings.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/legs.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/detect.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/get_max.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/init.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/boots.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/chestplate.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/handle.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/helmet.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/leggings.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/mainhand.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/offhand.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/check_durability.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/mark.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/chest.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/feet.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/head.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/legs.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/mainhand.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/offhand.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process_item.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/wait.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/update/calc_durability.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/update/initial_data.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/update/start.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/player.mcfunction
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/tick.mcfunction
create mode 100644 smithed_libraries/packs/item/data/smithed.item/item_modifiers/impl/update_nbt.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/item_modifiers/update_nbt.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/chance/10.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/chance/11.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/chance/12.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/chance/14.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/chance/16.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/chance/20.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/chance/25.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/chance/33.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/chance/50.json
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/chance/9.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/10.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/11.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/12.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/14.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/16.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/20.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/25.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/33.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/50.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/9.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/chest.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/feet.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/head.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/legs.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/mainhand.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/offhand.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/chest.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/feet.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/head.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/legs.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/mainhand.json
create mode 100644 smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/offhand.json
diff --git a/smithed_libraries/packs/item/README.md b/smithed_libraries/packs/item/README.md
index 8a933dc..7ca0349 100644
--- a/smithed_libraries/packs/item/README.md
+++ b/smithed_libraries/packs/item/README.md
@@ -1,6 +1,18 @@
# Item
+This library allows for items to have custom durability. A maximum durability can be set when creating the item and the library will properly track the damage changes (both increase and decrease) and mirror the custom durability.
+Additionally, this library adds API calls to damage custom items via a command.
+## Usage
+For usage information, see the [documentation](https://wiki.smithed.dev/libraries/item)
## Downloading
-You can download it from [here](https://smithed.dev/thenuclearnexus/smithed.item)
-or
-You can build it from source using the [beet](https://github.com/mcbeet/beet)
+You can download this library from [the website](https://api.smithed.dev/download?pack=smithed:item)
+or
+You can build it from source using [beet](https://github.com/mcbeet/beet)
+
+### Building
+```
+$ pip install beet mecha
+$ git clone https://github.com/Smithed-MC/Libraries
+$ cd Libraries
+$ beet -p smithed_libraries/packs/item
+```
diff --git a/smithed_libraries/packs/item/beet.yaml b/smithed_libraries/packs/item/beet.yaml
index f65a787..9f13c64 100644
--- a/smithed_libraries/packs/item/beet.yaml
+++ b/smithed_libraries/packs/item/beet.yaml
@@ -3,7 +3,7 @@ extend: "@smithed_libraries/common.yaml"
id: smithed.item
name: Smithed Item
description: Native Item Library for Smithed
-version: "0.2.1"
+version: "0.3.1"
data_pack:
name: Smithed Item
diff --git a/smithed_libraries/packs/item/data/smithed.item/advancements/impl/inventory_changed.json b/smithed_libraries/packs/item/data/smithed.item/advancements/impl/inventory_changed.json
new file mode 100644
index 0000000..b14e92e
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/advancements/impl/inventory_changed.json
@@ -0,0 +1,20 @@
+{
+ "criteria": {
+ "requirement": {
+ "trigger": "minecraft:inventory_changed",
+ "conditions": {
+ "items": [
+ {
+ "count": {
+ "min": 1
+ },
+ "nbt": "{smithed:{durability:{}}}"
+ }
+ ]
+ }
+ }
+ },
+ "rewards": {
+ "function": "smithed.item:impl/durability/track_changes/mark"
+ }
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/advancements/impl/technical/inventory_changed.json b/smithed_libraries/packs/item/data/smithed.item/advancements/impl/technical/inventory_changed.json
deleted file mode 100644
index 44ef4a3..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/advancements/impl/technical/inventory_changed.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "criteria": {
- "requirement": {
- "trigger": "minecraft:inventory_changed",
- "conditions": {
- "items": [
- {
- "nbt": "{smithed:{hasLore:1b}}"
- }
- ]
- }
- }
- },
- "rewards": {
- "function": "smithed.item:impl/lore/update_inventory"
- }
- }
-
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_durability.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_durability.mcfunction
deleted file mode 100644
index f03b863..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_durability.mcfunction
+++ /dev/null
@@ -1,63 +0,0 @@
-execute store result score $temp smithed.data run data get storage smithed.item:main item.tag.smithed.durability.dur
-execute store result score $temp1 smithed.data run data get storage smithed.item:main item.tag.smithed.durability.damage
-execute store result score $temp2 smithed.data run data get storage smithed.item:main item.tag.Damage
-execute store result score $temp3 smithed.data run data get storage smithed.item:main item.tag.smithed.durability.max
-function smithed.item:impl/durability/get_max
-
-#change internal dur value
-
-## durability.damage -= Damage
-scoreboard players operation $temp1 smithed.data -= $temp2 smithed.data
-
-execute if score $temp1 smithed.data matches 1.. if data storage smithed.item:main item.tag.Enchantments[{id:"minecraft:mending"}] run function smithed.item:impl/durability/calc_mending
-
-## durability.dur += (durability.damage - Damage)
-scoreboard players operation $temp smithed.data += $temp1 smithed.data
-
-## (durability.damage - Damage) + Damage
-scoreboard players operation $temp1 smithed.data += $temp2 smithed.data
-
-## if (base.MaxDur > 1 && durability.dur > durability.max) then durability.dur = durability.max
-execute if score $temp4 smithed.data matches 1.. if score $temp smithed.data > $temp3 smithed.data run scoreboard players operation $temp smithed.data = $temp3 smithed.data
-
-## if (durability.dur <= -1) then durability.dur = -1
-execute if score $temp smithed.data matches ..-1 run scoreboard players set $temp smithed.data -1
-
-## if (base.MaxDur >= 1) then item.tag.smithed.durability.dur = durability.dur
-execute if score $temp4 smithed.data matches 1.. store result storage smithed.item:main item.tag.smithed.durability.dur int 1 run scoreboard players get $temp smithed.data
-
-#set dur bar
-
-## temp5 = base.MaxDur
-scoreboard players operation $temp5 smithed.data = $temp4 smithed.data
-
-## temp6 = base.MaxDur - 8
-scoreboard players operation $temp6 smithed.data = $temp4 smithed.data
-scoreboard players remove $temp6 smithed.data 8
-
-## temp5 *= durability.dur
-scoreboard players operation $temp5 smithed.data *= $temp smithed.data
-
-## temp5 /= durability.max
-scoreboard players operation $temp5 smithed.data /= $temp3 smithed.data
-
-## base.MaxDur -= temp5
-scoreboard players operation $temp4 smithed.data -= $temp5 smithed.data
-
-## if (base.MaxDur > 1 && base.MaxDur > temp6) then base.MaxDur = temp6
-execute if score $temp4 smithed.data matches 1.. if score $temp4 smithed.data > $temp6 smithed.data run scoreboard players operation $temp4 smithed.data = $temp6 smithed.data
-
-execute if score $temp4 smithed.data matches 1.. store result storage smithed.item:main item.tag.Damage int 1 run scoreboard players get $temp4 smithed.data
-execute if score $temp4 smithed.data matches 1.. store result storage smithed.item:main item.tag.smithed.durability.damage int 1 run scoreboard players get $temp4 smithed.data
-
-#change durability of unbreakable items
-execute if score $temp4 smithed.data matches 0 store result score $temp smithed.data run data get storage smithed.item:main item.tag.smithed.durability.dur
-execute if score $temp4 smithed.data matches 0 run scoreboard players remove $temp smithed.data 1
-execute if score $temp4 smithed.data matches 0 store result storage smithed.item:main item.tag.smithed.durability.dur int 1 run scoreboard players get $temp smithed.data
-
-function smithed.item:impl/lore/build
-
-#output state
-scoreboard players set $out smithed.data 1
-execute if score $temp smithed.data matches ..-1 if data storage smithed.item:main item.tag.smithed.durability run scoreboard players set $out smithed.data 0
-execute if score $temp smithed.data matches ..-1 if data storage smithed.item:main item.tag.smithed.durability{no_break:1b} run scoreboard players set $out smithed.data -1
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_mending.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_mending.mcfunction
deleted file mode 100644
index 883922c..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_mending.mcfunction
+++ /dev/null
@@ -1,5 +0,0 @@
-scoreboard players operation $xp.temp smithed.data = @s smithed.xp
-scoreboard players operation $xp.temp smithed.data -= @s smithed.prev_xp
-scoreboard players operation $xp.temp smithed.data *= 2 smithed.const
-
-execute if score $xp.temp smithed.data matches 1.. run function smithed.item:impl/durability/calc_mending/clamp
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_mending/clamp.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_mending/clamp.mcfunction
deleted file mode 100644
index 1f72233..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_mending/clamp.mcfunction
+++ /dev/null
@@ -1,30 +0,0 @@
-
-scoreboard players operation $temp1 smithed.data += $xp.temp smithed.data
-scoreboard players operation $xp.temp1 smithed.data = $temp smithed.data
-scoreboard players operation $xp.temp1 smithed.data += $temp1 smithed.data
-
-execute if score $xp.temp1 smithed.data > $temp3 smithed.data run function smithed.item:impl/durability/calc_mending/return_overflow
-
-execute if score $xp.temp smithed.data matches 256.. run xp add @s -128 points
-execute if score $xp.temp smithed.data matches 256.. run scoreboard players remove $xp.temp smithed.data 256
-
-execute if score $xp.temp smithed.data matches 128.. run xp add @s -64 points
-execute if score $xp.temp smithed.data matches 128.. run scoreboard players remove $xp.temp smithed.data 128
-
-execute if score $xp.temp smithed.data matches 64.. run xp add @s -32 points
-execute if score $xp.temp smithed.data matches 64.. run scoreboard players remove $xp.temp smithed.data 64
-
-execute if score $xp.temp smithed.data matches 32.. run xp add @s -16 points
-execute if score $xp.temp smithed.data matches 32.. run scoreboard players remove $xp.temp smithed.data 32
-
-execute if score $xp.temp smithed.data matches 16.. run xp add @s -8 points
-execute if score $xp.temp smithed.data matches 16.. run scoreboard players remove $xp.temp smithed.data 16
-
-execute if score $xp.temp smithed.data matches 8.. run xp add @s -4 points
-execute if score $xp.temp smithed.data matches 8.. run scoreboard players remove $xp.temp smithed.data 8
-
-execute if score $xp.temp smithed.data matches 4.. run xp add @s -2 points
-execute if score $xp.temp smithed.data matches 4.. run scoreboard players remove $xp.temp smithed.data 4
-
-execute if score $xp.temp smithed.data matches 2.. run xp add @s -1 points
-execute if score $xp.temp smithed.data matches 2.. run scoreboard players remove $xp.temp smithed.data 2
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_mending/return_overflow.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_mending/return_overflow.mcfunction
deleted file mode 100644
index fdfb317..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/calc_mending/return_overflow.mcfunction
+++ /dev/null
@@ -1,4 +0,0 @@
-scoreboard players operation $xp.temp1 smithed.data -= $temp3 smithed.data
-scoreboard players operation $temp1 smithed.data -= $xp.temp1 smithed.data
-scoreboard players operation $xp.temp smithed.data -= $xp.temp1 smithed.data
-
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage.mcfunction
deleted file mode 100644
index 3a9e7a7..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage.mcfunction
+++ /dev/null
@@ -1,7 +0,0 @@
-execute unless data storage smithed.item:main item.tag.smithed.durability.dur run function smithed.item:impl/durability/init
-
-function smithed.item:impl/durability/calc_durability
-
-## execute unless item smithed.item:main item{id:"minecraft:elytra} then dont do the stuff
-execute if score $out smithed.data matches -1..0 run playsound minecraft:entity.item.break player @a[distance=..16]
-execute if score $out smithed.data matches 0 run data modify storage smithed.item:main item set value "null"
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/boots.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/boots.mcfunction
deleted file mode 100644
index 5522a7f..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/boots.mcfunction
+++ /dev/null
@@ -1,8 +0,0 @@
-# @public
-
-data modify storage smithed.item:main item set from entity @s Inventory[{Slot:100b}]
-
-function smithed.item:impl/durability/damage/force
-
-execute unless data storage smithed.item:main {item:"null"} unless score $out smithed.data matches -1 run item modify entity @s armor.feet smithed.item:update_nbt
-execute if data storage smithed.item:main {item:"null"} run item replace entity @s armor.feet with air
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/chest.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/chest.mcfunction
new file mode 100644
index 0000000..28c4408
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/chest.mcfunction
@@ -0,0 +1,17 @@
+# @public
+
+# force damage to the item in the player's chest slot
+# @s = player who needs to have durability changed in chest slot
+# located at world spawn
+# run from api call
+
+# set chest durability
+data modify storage smithed.item:main item set from entity @s Inventory[{Slot:102b}]
+function smithed.item:impl/durability/damage/force/calc_unbreaking
+
+# update chest
+execute if score $out smithed.item matches 1 run item modify entity @s armor.chest smithed.item:impl/update_nbt
+execute if score $out smithed.item matches 0 run item replace entity @s armor.chest with air
+execute if score $out smithed.item matches -1 run function #smithed.item:event/item_changed/chest
+
+scoreboard players reset $out smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/chestplate.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/chestplate.mcfunction
deleted file mode 100644
index 1926b2f..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/chestplate.mcfunction
+++ /dev/null
@@ -1,8 +0,0 @@
-# @public
-
-data modify storage smithed.item:main item set from entity @s Inventory[{Slot:102b}]
-
-function smithed.item:impl/durability/damage/force
-
-execute unless data storage smithed.item:main {item:"null"} unless score $out smithed.data matches -1 run item modify entity @s armor.chest smithed.item:update_nbt
-execute if data storage smithed.item:main {item:"null"} run item replace entity @s armor.chest with air
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/feet.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/feet.mcfunction
new file mode 100644
index 0000000..24e06db
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/feet.mcfunction
@@ -0,0 +1,17 @@
+# @public
+
+# force damage to the item in the player's feet slot
+# @s = player who needs to have durability changed in feet slot
+# located at world spawn
+# run from api call
+
+# set feet durability
+data modify storage smithed.item:main item set from entity @s Inventory[{Slot:100b}]
+function smithed.item:impl/durability/damage/force/calc_unbreaking
+
+# update feet
+execute if score $out smithed.item matches 1 run item modify entity @s armor.feet smithed.item:impl/update_nbt
+execute if score $out smithed.item matches 0 run item replace entity @s armor.feet with air
+execute if score $out smithed.item matches -1 run function #smithed.item:event/item_changed/feet
+
+scoreboard players reset $out smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force.mcfunction
deleted file mode 100644
index 5f88a2a..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force.mcfunction
+++ /dev/null
@@ -1,15 +0,0 @@
-# @public
-
-execute store result score $temp smithed.data run data get storage smithed.item:main item.tag.Enchantments[{id:"minecraft:unbreaking"}].lvl
-
-execute if score $temp smithed.data matches 0 run function smithed.item:impl/durability/damage/force/sub
-execute if score $temp smithed.data matches 1 if predicate smithed.item:chance/50 run function smithed.item:impl/durability/damage/force/sub
-execute if score $temp smithed.data matches 2 if predicate smithed.item:chance/33 run function smithed.item:impl/durability/damage/force/sub
-execute if score $temp smithed.data matches 3 if predicate smithed.item:chance/25 run function smithed.item:impl/durability/damage/force/sub
-execute if score $temp smithed.data matches 4 if predicate smithed.item:chance/20 run function smithed.item:impl/durability/damage/force/sub
-execute if score $temp smithed.data matches 5 if predicate smithed.item:chance/16 run function smithed.item:impl/durability/damage/force/sub
-execute if score $temp smithed.data matches 6 if predicate smithed.item:chance/14 run function smithed.item:impl/durability/damage/force/sub
-execute if score $temp smithed.data matches 7 if predicate smithed.item:chance/12 run function smithed.item:impl/durability/damage/force/sub
-execute if score $temp smithed.data matches 8 if predicate smithed.item:chance/11 run function smithed.item:impl/durability/damage/force/sub
-execute if score $temp smithed.data matches 9 if predicate smithed.item:chance/10 run function smithed.item:impl/durability/damage/force/sub
-execute if score $temp smithed.data matches 10.. if predicate smithed.item:chance/9 run function smithed.item:impl/durability/damage/force/sub
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force/calc_unbreaking.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force/calc_unbreaking.mcfunction
new file mode 100644
index 0000000..22175a9
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force/calc_unbreaking.mcfunction
@@ -0,0 +1,28 @@
+# force damage to the item
+# @s = player who needs to have durability changed
+# located at world spawn
+# run from durability/damage/
+
+# get unbreaking level
+execute store result score $unbreaking_lvl smithed.item run data get storage smithed.item:main item.tag.Enchantments[{id:"minecraft:unbreaking"}].lvl
+
+# check if the item is unbreakable
+scoreboard players set $unbreakable smithed.item 0
+execute store result score $unbreakable smithed.item run data get storage smithed.item:main item.tag.Unbreakable
+execute unless score $unbreakable smithed.item matches 0 run scoreboard players set $unbreaking_lvl smithed.item -1
+
+# if delta is positive (i.e. adding durability), ignore unbreaking
+execute if score $delta smithed.item matches 1.. run scoreboard players set $unbreaking_lvl smithed.item 0
+
+# damage the item, based on its unbreaking level
+execute if score $unbreaking_lvl smithed.item matches 0 run function smithed.item:impl/durability/damage/force/sub
+execute if score $unbreaking_lvl smithed.item matches 1 if predicate smithed.item:impl/chance/50 run function smithed.item:impl/durability/damage/force/sub
+execute if score $unbreaking_lvl smithed.item matches 2 if predicate smithed.item:impl/chance/33 run function smithed.item:impl/durability/damage/force/sub
+execute if score $unbreaking_lvl smithed.item matches 3 if predicate smithed.item:impl/chance/25 run function smithed.item:impl/durability/damage/force/sub
+execute if score $unbreaking_lvl smithed.item matches 4 if predicate smithed.item:impl/chance/20 run function smithed.item:impl/durability/damage/force/sub
+execute if score $unbreaking_lvl smithed.item matches 5 if predicate smithed.item:impl/chance/16 run function smithed.item:impl/durability/damage/force/sub
+execute if score $unbreaking_lvl smithed.item matches 6 if predicate smithed.item:impl/chance/14 run function smithed.item:impl/durability/damage/force/sub
+execute if score $unbreaking_lvl smithed.item matches 7 if predicate smithed.item:impl/chance/12 run function smithed.item:impl/durability/damage/force/sub
+execute if score $unbreaking_lvl smithed.item matches 8 if predicate smithed.item:impl/chance/11 run function smithed.item:impl/durability/damage/force/sub
+execute if score $unbreaking_lvl smithed.item matches 9 if predicate smithed.item:impl/chance/10 run function smithed.item:impl/durability/damage/force/sub
+execute if score $unbreaking_lvl smithed.item matches 10.. if predicate smithed.item:impl/chance/9 run function smithed.item:impl/durability/damage/force/sub
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force/sub.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force/sub.mcfunction
index 77ef1b6..2a2d5d9 100644
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force/sub.mcfunction
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force/sub.mcfunction
@@ -1,5 +1,14 @@
-execute store result score $temp smithed.data run data get storage smithed.item:main item.tag.Damage
-scoreboard players remove $temp smithed.data 1
-execute store result storage smithed.item:main item.tag.smithed.durability.damage int 1 run scoreboard players get $temp smithed.data
+# set damage change and run the damage handler
+# @s = player who needs to have durability changed
+# located at world spawn
+# run from durability/damage/force/calc_unbreaking
-function smithed.item:impl/durability/process/handle
+# get durability change
+execute store result score $old_damage smithed.item run data get storage smithed.item:main item.tag.Damage
+scoreboard players operation $old_damage smithed.item += $delta smithed.item
+scoreboard players set $delta smithed.item -1
+
+# update durability
+scoreboard players set $force smithed.item 1
+execute if score $unbreakable smithed.item matches 0 run function smithed.item:impl/durability/track_changes/process_item
+scoreboard players reset $force smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/head.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/head.mcfunction
new file mode 100644
index 0000000..d8e0314
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/head.mcfunction
@@ -0,0 +1,17 @@
+# @public
+
+# force damage to the item in the player's head slot
+# @s = player who needs to have durability changed in head slot
+# located at world spawn
+# run from api call
+
+# set head durability
+data modify storage smithed.item:main item set from entity @s Inventory[{Slot:103b}]
+function smithed.item:impl/durability/damage/force/calc_unbreaking
+
+# update head
+execute if score $out smithed.item matches 1 run item modify entity @s armor.head smithed.item:impl/update_nbt
+execute if score $out smithed.item matches 0 run item replace entity @s armor.head with air
+execute if score $out smithed.item matches -1 run function #smithed.item:event/item_changed/head
+
+scoreboard players reset $out smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/helmet.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/helmet.mcfunction
deleted file mode 100644
index 8bceac3..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/helmet.mcfunction
+++ /dev/null
@@ -1,8 +0,0 @@
-# @public
-
-data modify storage smithed.item:main item set from entity @s Inventory[{Slot:103b}]
-
-function smithed.item:impl/durability/damage/force
-
-execute unless data storage smithed.item:main {item:"null"} unless score $out smithed.data matches -1 run item modify entity @s armor.head smithed.item:update_nbt
-execute if data storage smithed.item:main {item:"null"} run item replace entity @s armor.head with air
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/leggings.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/leggings.mcfunction
deleted file mode 100644
index cc5587d..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/leggings.mcfunction
+++ /dev/null
@@ -1,8 +0,0 @@
-# @public
-
-data modify storage smithed.item:main item set from entity @s Inventory[{Slot:101b}]
-
-function smithed.item:impl/durability/damage/force
-
-execute unless data storage smithed.item:main {item:"null"} unless score $out smithed.data matches -1 run item modify entity @s armor.legs smithed.item:update_nbt
-execute if data storage smithed.item:main {item:"null"} run item replace entity @s armor.legs with air
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/legs.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/legs.mcfunction
new file mode 100644
index 0000000..1f6445c
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/legs.mcfunction
@@ -0,0 +1,17 @@
+# @public
+
+# force damage to the item in the player's legs slot
+# @s = player who needs to have durability changed in legs slot
+# located at world spawn
+# run from api call
+
+# set legs durability
+data modify storage smithed.item:main item set from entity @s Inventory[{Slot:101b}]
+function smithed.item:impl/durability/damage/force/calc_unbreaking
+
+# update legs
+execute if score $out smithed.item matches 1 run item modify entity @s armor.legs smithed.item:impl/update_nbt
+execute if score $out smithed.item matches 0 run item replace entity @s armor.legs with air
+execute if score $out smithed.item matches -1 run function #smithed.item:event/item_changed/legs
+
+scoreboard players reset $out smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/mainhand.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/mainhand.mcfunction
index 60b98a8..9640cc8 100644
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/mainhand.mcfunction
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/mainhand.mcfunction
@@ -1,8 +1,17 @@
# @public
+# force damage to the item in the player's mainhand
+# @s = player who needs to have durability changed in mainhand
+# located at world spawn
+# run from api call
+
+# set mainhand durability
data modify storage smithed.item:main item set from entity @s SelectedItem
+function smithed.item:impl/durability/damage/force/calc_unbreaking
-function smithed.item:impl/durability/damage/force
+# update mainhand
+execute if score $out smithed.item matches 1 run item modify entity @s weapon.mainhand smithed.item:impl/update_nbt
+execute if score $out smithed.item matches 0 run item replace entity @s weapon.mainhand with air
+execute if score $out smithed.item matches -1 run function #smithed.item:event/item_changed/mainhand
-execute unless data storage smithed.item:main {item:"null"} unless score $out smithed.data matches -1 run item modify entity @s weapon.mainhand smithed.item:update_nbt
-execute if data storage smithed.item:main {item:"null"} run item replace entity @s weapon.mainhand with air
\ No newline at end of file
+scoreboard players reset $out smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/offhand.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/offhand.mcfunction
index 926c505..0849b29 100644
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/offhand.mcfunction
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/offhand.mcfunction
@@ -1,8 +1,17 @@
# @public
+# force damage to the item in the player's offhand
+# @s = player who needs to have durability changed in offhand
+# located at world spawn
+# run from api call
+
+# set offhand durability
data modify storage smithed.item:main item set from entity @s Inventory[{Slot:-106b}]
+function smithed.item:impl/durability/damage/force/calc_unbreaking
-function smithed.item:impl/durability/damage/force
+# update offhand
+execute if score $out smithed.item matches 1 run item modify entity @s weapon.offhand smithed.item:impl/update_nbt
+execute if score $out smithed.item matches 0 run item replace entity @s weapon.offhand with air
+execute if score $out smithed.item matches -1 run function #smithed.item:event/item_changed/offhand
-execute unless data storage smithed.item:main {item:"null"} unless score $out smithed.data matches -1 run item modify entity @s weapon.offhand smithed.item:update_nbt
-execute if data storage smithed.item:main {item:"null"} run item replace entity @s weapon.offhand with air
\ No newline at end of file
+scoreboard players reset $out smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/detect.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/detect.mcfunction
deleted file mode 100644
index 363194a..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/detect.mcfunction
+++ /dev/null
@@ -1,8 +0,0 @@
-execute if data entity @s SelectedItem.tag.smithed.durability run function smithed.item:impl/durability/process/mainhand
-
-execute if data entity @s Inventory[{Slot:-106b}].tag.smithed.durability run function smithed.item:impl/durability/process/offhand
-
-execute if data entity @s Inventory[{Slot:100b}].tag.smithed.durability run function smithed.item:impl/durability/process/boots
-execute if data entity @s Inventory[{Slot:101b}].tag.smithed.durability run function smithed.item:impl/durability/process/leggings
-execute if data entity @s Inventory[{Slot:102b}].tag.smithed.durability run function smithed.item:impl/durability/process/chestplate
-execute if data entity @s Inventory[{Slot:103b}].tag.smithed.durability run function smithed.item:impl/durability/process/helmet
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/get_max.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/get_max.mcfunction
deleted file mode 100644
index e90ef85..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/get_max.mcfunction
+++ /dev/null
@@ -1,87 +0,0 @@
-
-scoreboard players set $temp4 smithed.data -1
-
-execute if data storage smithed.item:main item{id:"minecraft:golden_sword"} run scoreboard players set $temp4 smithed.data 32
-execute if data storage smithed.item:main item{id:"minecraft:golden_pickaxe"} run scoreboard players set $temp4 smithed.data 32
-execute if data storage smithed.item:main item{id:"minecraft:golden_axe"} run scoreboard players set $temp4 smithed.data 32
-execute if data storage smithed.item:main item{id:"minecraft:golden_shovel"} run scoreboard players set $temp4 smithed.data 32
-execute if data storage smithed.item:main item{id:"minecraft:golden_hoe"} run scoreboard players set $temp4 smithed.data 32
-
-execute if data storage smithed.item:main item{id:"minecraft:wooden_sword"} run scoreboard players set $temp4 smithed.data 59
-execute if data storage smithed.item:main item{id:"minecraft:wooden_pickaxe"} run scoreboard players set $temp4 smithed.data 59
-execute if data storage smithed.item:main item{id:"minecraft:wooden_axe"} run scoreboard players set $temp4 smithed.data 59
-execute if data storage smithed.item:main item{id:"minecraft:wooden_shovel"} run scoreboard players set $temp4 smithed.data 59
-execute if data storage smithed.item:main item{id:"minecraft:wooden_hoe"} run scoreboard players set $temp4 smithed.data 59
-
-execute if data storage smithed.item:main item{id:"minecraft:stone_sword"} run scoreboard players set $temp4 smithed.data 131
-execute if data storage smithed.item:main item{id:"minecraft:stone_pickaxe"} run scoreboard players set $temp4 smithed.data 131
-execute if data storage smithed.item:main item{id:"minecraft:stone_axe"} run scoreboard players set $temp4 smithed.data 131
-execute if data storage smithed.item:main item{id:"minecraft:stone_shovel"} run scoreboard players set $temp4 smithed.data 131
-execute if data storage smithed.item:main item{id:"minecraft:stone_hoe"} run scoreboard players set $temp4 smithed.data 131
-
-execute if data storage smithed.item:main item{id:"minecraft:iron_sword"} run scoreboard players set $temp4 smithed.data 250
-execute if data storage smithed.item:main item{id:"minecraft:iron_pickaxe"} run scoreboard players set $temp4 smithed.data 250
-execute if data storage smithed.item:main item{id:"minecraft:iron_axe"} run scoreboard players set $temp4 smithed.data 250
-execute if data storage smithed.item:main item{id:"minecraft:iron_shovel"} run scoreboard players set $temp4 smithed.data 250
-execute if data storage smithed.item:main item{id:"minecraft:iron_hoe"} run scoreboard players set $temp4 smithed.data 250
-
-execute if data storage smithed.item:main item{id:"minecraft:diamond_sword"} run scoreboard players set $temp4 smithed.data 1561
-execute if data storage smithed.item:main item{id:"minecraft:diamond_pickaxe"} run scoreboard players set $temp4 smithed.data 1561
-execute if data storage smithed.item:main item{id:"minecraft:diamond_axe"} run scoreboard players set $temp4 smithed.data 1561
-execute if data storage smithed.item:main item{id:"minecraft:diamond_shovel"} run scoreboard players set $temp4 smithed.data 1561
-execute if data storage smithed.item:main item{id:"minecraft:diamond_hoe"} run scoreboard players set $temp4 smithed.data 1561
-
-execute if data storage smithed.item:main item{id:"minecraft:netherite_sword"} run scoreboard players set $temp4 smithed.data 2031
-execute if data storage smithed.item:main item{id:"minecraft:netherite_pickaxe"} run scoreboard players set $temp4 smithed.data 2031
-execute if data storage smithed.item:main item{id:"minecraft:netherite_axe"} run scoreboard players set $temp4 smithed.data 2031
-execute if data storage smithed.item:main item{id:"minecraft:netherite_shovel"} run scoreboard players set $temp4 smithed.data 2031
-execute if data storage smithed.item:main item{id:"minecraft:netherite_hoe"} run scoreboard players set $temp4 smithed.data 2031
-
-
-
-execute if data storage smithed.item:main item{id:"minecraft:leather_helmet"} run scoreboard players set $temp4 smithed.data 55
-execute if data storage smithed.item:main item{id:"minecraft:leather_chestplate"} run scoreboard players set $temp4 smithed.data 80
-execute if data storage smithed.item:main item{id:"minecraft:leather_leggings"} run scoreboard players set $temp4 smithed.data 75
-execute if data storage smithed.item:main item{id:"minecraft:leather_boots"} run scoreboard players set $temp4 smithed.data 65
-
-execute if data storage smithed.item:main item{id:"minecraft:golden_helmet"} run scoreboard players set $temp4 smithed.data 77
-execute if data storage smithed.item:main item{id:"minecraft:golden_chestplate"} run scoreboard players set $temp4 smithed.data 112
-execute if data storage smithed.item:main item{id:"minecraft:golden_leggings"} run scoreboard players set $temp4 smithed.data 105
-execute if data storage smithed.item:main item{id:"minecraft:golden_boots"} run scoreboard players set $temp4 smithed.data 91
-
-execute if data storage smithed.item:main item{id:"minecraft:chainmail_helmet"} run scoreboard players set $temp4 smithed.data 165
-execute if data storage smithed.item:main item{id:"minecraft:chainmail_chestplate"} run scoreboard players set $temp4 smithed.data 240
-execute if data storage smithed.item:main item{id:"minecraft:chainmail_leggings"} run scoreboard players set $temp4 smithed.data 225
-execute if data storage smithed.item:main item{id:"minecraft:chainmail_boots"} run scoreboard players set $temp4 smithed.data 195
-
-execute if data storage smithed.item:main item{id:"minecraft:iron_helmet"} run scoreboard players set $temp4 smithed.data 165
-execute if data storage smithed.item:main item{id:"minecraft:iron_chestplate"} run scoreboard players set $temp4 smithed.data 240
-execute if data storage smithed.item:main item{id:"minecraft:iron_leggings"} run scoreboard players set $temp4 smithed.data 225
-execute if data storage smithed.item:main item{id:"minecraft:iron_boots"} run scoreboard players set $temp4 smithed.data 195
-
-execute if data storage smithed.item:main item{id:"minecraft:diamond_helmet"} run scoreboard players set $temp4 smithed.data 363
-execute if data storage smithed.item:main item{id:"minecraft:diamond_chestplate"} run scoreboard players set $temp4 smithed.data 528
-execute if data storage smithed.item:main item{id:"minecraft:diamond_leggings"} run scoreboard players set $temp4 smithed.data 495
-execute if data storage smithed.item:main item{id:"minecraft:diamond_boots"} run scoreboard players set $temp4 smithed.data 429
-
-execute if data storage smithed.item:main item{id:"minecraft:netherite_helmet"} run scoreboard players set $temp4 smithed.data 407
-execute if data storage smithed.item:main item{id:"minecraft:netherite_chestplate"} run scoreboard players set $temp4 smithed.data 592
-execute if data storage smithed.item:main item{id:"minecraft:netherite_leggings"} run scoreboard players set $temp4 smithed.data 555
-execute if data storage smithed.item:main item{id:"minecraft:netherite_boots"} run scoreboard players set $temp4 smithed.data 481
-
-execute if data storage smithed.item:main item{id:"minecraft:fishing_rod"} run scoreboard players set $temp4 smithed.data 64
-execute if data storage smithed.item:main item{id:"minecraft:flint_and_steel"} run scoreboard players set $temp4 smithed.data 64
-execute if data storage smithed.item:main item{id:"minecraft:carrot_on_a_stick"} run scoreboard players set $temp4 smithed.data 25
-execute if data storage smithed.item:main item{id:"minecraft:warped_fungus_on_a_stick"} run scoreboard players set $temp4 smithed.data 100
-execute if data storage smithed.item:main item{id:"minecraft:shears"} run scoreboard players set $temp4 smithed.data 238
-execute if data storage smithed.item:main item{id:"minecraft:shield"} run scoreboard players set $temp4 smithed.data 336
-execute if data storage smithed.item:main item{id:"minecraft:bow"} run scoreboard players set $temp4 smithed.data 384
-execute if data storage smithed.item:main item{id:"minecraft:trident"} run scoreboard players set $temp4 smithed.data 250
-execute if data storage smithed.item:main item{id:"minecraft:elytra"} run scoreboard players set $temp4 smithed.data 1561
-execute if data storage smithed.item:main item{id:"minecraft:crossbow"} run scoreboard players set $temp4 smithed.data 326
-execute if data storage smithed.item:main item{id:"minecraft:turtle_helmet"} run scoreboard players set $temp4 smithed.data 275
-execute if data storage smithed.item:main item{tag:{Unbreakable:1b}} run scoreboard players set $temp4 smithed.data 0
-
-execute if score $temp4 smithed.data matches -1 run data merge storage smithed.logging:main {message:'[{"text":"Invalid tool used! "},{"nbt":"item.id","storage":"smithed.item:"}]',type:'WARNING'}
-execute if score $temp4 smithed.data matches -1 run function #smithed.logging:print
-
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/init.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/init.mcfunction
deleted file mode 100644
index 78ba144..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/init.mcfunction
+++ /dev/null
@@ -1,2 +0,0 @@
-data modify storage smithed.item:main item.tag.smithed.durability.dur set from storage smithed.item:main item.tag.smithed.durability.max
-data modify storage smithed.item:main item.tag.smithed.durability.damage set value 0
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/boots.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/boots.mcfunction
deleted file mode 100644
index 71c91cd..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/boots.mcfunction
+++ /dev/null
@@ -1,5 +0,0 @@
-data modify storage smithed.item:main item set from entity @s Inventory[{Slot:100b}]
-function smithed.item:impl/durability/process/handle
-
-execute unless data storage smithed.item:main {item:"null"} unless score $out smithed.data matches -1 run item modify entity @s armor.feet smithed.item:update_nbt
-execute if data storage smithed.item:main {item:"null"} run item replace entity @s armor.feet with air
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/chestplate.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/chestplate.mcfunction
deleted file mode 100644
index 8cbd3e3..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/chestplate.mcfunction
+++ /dev/null
@@ -1,5 +0,0 @@
-data modify storage smithed.item:main item set from entity @s Inventory[{Slot:102b}]
-function smithed.item:impl/durability/process/handle
-
-execute unless data storage smithed.item:main {item:"null"} unless score $out smithed.data matches -1 run item modify entity @s armor.chest smithed.item:update_nbt
-execute if data storage smithed.item:main {item:"null"} run item replace entity @s armor.chest with air
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/handle.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/handle.mcfunction
deleted file mode 100644
index 2acd3bd..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/handle.mcfunction
+++ /dev/null
@@ -1,5 +0,0 @@
-execute store result score $temp smithed.data run data get storage smithed.item:main item.tag.Damage
-execute store result score $temp1 smithed.data run data get storage smithed.item:main item.tag.smithed.durability.damage
-
-execute if score $temp smithed.data = $temp1 smithed.data run scoreboard players set $out smithed.data -1
-execute unless score $temp smithed.data = $temp1 smithed.data run function smithed.item:impl/durability/damage
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/helmet.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/helmet.mcfunction
deleted file mode 100644
index a0238c9..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/helmet.mcfunction
+++ /dev/null
@@ -1,5 +0,0 @@
-data modify storage smithed.item:main item set from entity @s Inventory[{Slot:103b}]
-function smithed.item:impl/durability/process/handle
-
-execute unless data storage smithed.item:main {item:"null"} unless score $out smithed.data matches -1 run item modify entity @s armor.head smithed.item:update_nbt
-execute if data storage smithed.item:main {item:"null"} run item replace entity @s armor.head with air
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/leggings.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/leggings.mcfunction
deleted file mode 100644
index 5f22aae..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/leggings.mcfunction
+++ /dev/null
@@ -1,5 +0,0 @@
-data modify storage smithed.item:main item set from entity @s Inventory[{Slot:101b}]
-function smithed.item:impl/durability/process/handle
-
-execute unless data storage smithed.item:main {item:"null"} unless score $out smithed.data matches -1 run item modify entity @s armor.legs smithed.item:update_nbt
-execute if data storage smithed.item:main {item:"null"} run item replace entity @s armor.legs with air
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/mainhand.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/mainhand.mcfunction
deleted file mode 100644
index b592247..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/mainhand.mcfunction
+++ /dev/null
@@ -1,6 +0,0 @@
-data modify storage smithed.item:main item set from entity @s SelectedItem
-
-function smithed.item:impl/durability/process/handle
-
-execute unless data storage smithed.item:main {item:"null"} unless score $out smithed.data matches -1 run item modify entity @s weapon.mainhand smithed.item:update_nbt
-execute if data storage smithed.item:main {item:"null"} run item replace entity @s weapon.mainhand with air
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/offhand.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/offhand.mcfunction
deleted file mode 100644
index 7b60c93..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/process/offhand.mcfunction
+++ /dev/null
@@ -1,5 +0,0 @@
-data modify storage smithed.item:main item set from entity @s Inventory[{Slot:-106b}]
-function smithed.item:impl/durability/process/handle
-
-execute unless data storage smithed.item:main {item:"null"} unless score $out smithed.data matches -1 run item modify entity @s weapon.offhand smithed.item:update_nbt
-execute if data storage smithed.item:main {item:"null"} run item replace entity @s weapon.offhand with air
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/check_durability.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/check_durability.mcfunction
new file mode 100644
index 0000000..9885e7f
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/check_durability.mcfunction
@@ -0,0 +1,17 @@
+# checks player for items custom durability
+# @s = player who had a custom durability item change durability
+# located at world spawn
+# run from durability/track_changes/wait
+
+# for each custom item, check what changed
+data modify storage smithed.item:main player set from entity @s {}
+execute if predicate smithed.item:impl/has_custom_durability/mainhand run function smithed.item:impl/durability/track_changes/process/mainhand
+execute if predicate smithed.item:impl/has_custom_durability/offhand run function smithed.item:impl/durability/track_changes/process/offhand
+execute if predicate smithed.item:impl/has_custom_durability/head run function smithed.item:impl/durability/track_changes/process/head
+execute if predicate smithed.item:impl/has_custom_durability/chest run function smithed.item:impl/durability/track_changes/process/chest
+execute if predicate smithed.item:impl/has_custom_durability/legs run function smithed.item:impl/durability/track_changes/process/legs
+execute if predicate smithed.item:impl/has_custom_durability/feet run function smithed.item:impl/durability/track_changes/process/feet
+
+# mark as done with durability changes
+tag @s remove smithed.item.check
+advancement revoke @s only smithed.item:impl/inventory_changed
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/mark.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/mark.mcfunction
new file mode 100644
index 0000000..7ab387e
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/mark.mcfunction
@@ -0,0 +1,8 @@
+# prepare the player for damage calculations
+# @s = player who has a custom durability item that changed durability
+# located at world spawn
+# run from advancement inventory_changed
+
+# mark player for durability checks
+tag @s add smithed.item.check
+schedule function smithed.item:impl/durability/track_changes/wait 1
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/chest.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/chest.mcfunction
new file mode 100644
index 0000000..c30f7c5
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/chest.mcfunction
@@ -0,0 +1,15 @@
+# checks the chest for a change in durability
+# @s = player who has a custom durability item in their chest
+# located at world spawn
+# run from durability/track_changes/get_new
+
+# check chest for changes
+data modify storage smithed.item:main item set from storage smithed.item:main player.Inventory[{Slot:102b}]
+function smithed.item:impl/durability/track_changes/process_item
+
+# update chest
+execute if score $out smithed.item matches 1 run item modify entity @s armor.chest smithed.item:impl/update_nbt
+execute if score $out smithed.item matches 0 run item replace entity @s armor.chest with air
+execute if score $out smithed.item matches -1 run function #smithed.item:event/item_changed/chest
+
+scoreboard players reset $out smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/feet.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/feet.mcfunction
new file mode 100644
index 0000000..1c372ef
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/feet.mcfunction
@@ -0,0 +1,15 @@
+# checks the feet for a change in durability
+# @s = player who has a custom durability item in their feet
+# located at world spawn
+# run from durability/track_changes/get_new
+
+# check feet for changes
+data modify storage smithed.item:main item set from storage smithed.item:main player.Inventory[{Slot:100b}]
+function smithed.item:impl/durability/track_changes/process_item
+
+# update feet
+execute if score $out smithed.item matches 1 run item modify entity @s armor.feet smithed.item:impl/update_nbt
+execute if score $out smithed.item matches 0 run item replace entity @s armor.feet with air
+execute if score $out smithed.item matches -1 run function #smithed.item:event/item_changed/feet
+
+scoreboard players reset $out smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/head.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/head.mcfunction
new file mode 100644
index 0000000..d903ab6
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/head.mcfunction
@@ -0,0 +1,15 @@
+# checks the head for a change in durability
+# @s = player who has a custom durability item in their head
+# located at world spawn
+# run from durability/track_changes/get_new
+
+# check head for changes
+data modify storage smithed.item:main item set from storage smithed.item:main player.Inventory[{Slot:103b}]
+function smithed.item:impl/durability/track_changes/process_item
+
+# update head
+execute if score $out smithed.item matches 1 run item modify entity @s armor.head smithed.item:impl/update_nbt
+execute if score $out smithed.item matches 0 run item replace entity @s armor.head with air
+execute if score $out smithed.item matches -1 run function #smithed.item:event/item_changed/head
+
+scoreboard players reset $out smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/legs.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/legs.mcfunction
new file mode 100644
index 0000000..e281818
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/legs.mcfunction
@@ -0,0 +1,15 @@
+# checks the legs for a change in durability
+# @s = player who has a custom durability item in their legs
+# located at world spawn
+# run from durability/track_changes/get_new
+
+# check legs for changes
+data modify storage smithed.item:main item set from storage smithed.item:main player.Inventory[{Slot:101b}]
+function smithed.item:impl/durability/track_changes/process_item
+
+# update legs
+execute if score $out smithed.item matches 1 run item modify entity @s armor.legs smithed.item:impl/update_nbt
+execute if score $out smithed.item matches 0 run item replace entity @s armor.legs with air
+execute if score $out smithed.item matches -1 run function #smithed.item:event/item_changed/legs
+
+scoreboard players reset $out smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/mainhand.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/mainhand.mcfunction
new file mode 100644
index 0000000..7f47f50
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/mainhand.mcfunction
@@ -0,0 +1,15 @@
+# checks the mainhand for a change in durability
+# @s = player who has a custom durability item in their mainhand
+# located at world spawn
+# run from durability/track_changes/get_new
+
+# check mainhand for changes
+data modify storage smithed.item:main item set from storage smithed.item:main player.SelectedItem
+function smithed.item:impl/durability/track_changes/process_item
+
+# update mainhand
+execute if score $out smithed.item matches 1 run item modify entity @s weapon.mainhand smithed.item:impl/update_nbt
+execute if score $out smithed.item matches 0 run item replace entity @s weapon.mainhand with air
+execute if score $out smithed.item matches -1 run function #smithed.item:event/item_changed/mainhand
+
+scoreboard players reset $out smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/offhand.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/offhand.mcfunction
new file mode 100644
index 0000000..d1d8aa3
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process/offhand.mcfunction
@@ -0,0 +1,15 @@
+# checks the offhand for a change in durability
+# @s = player who has a custom durability item in their offhand
+# located at world spawn
+# run from durability/track_changes/get_new
+
+# check offhand for changes
+data modify storage smithed.item:main item set from storage smithed.item:main player.Inventory[{Slot:-106b}]
+function smithed.item:impl/durability/track_changes/process_item
+
+# update offhand
+execute if score $out smithed.item matches 1 run item modify entity @s weapon.offhand smithed.item:impl/update_nbt
+execute if score $out smithed.item matches 0 run item replace entity @s weapon.offhand with air
+execute if score $out smithed.item matches -1 run function #smithed.item:event/item_changed/offhand
+
+scoreboard players reset $out smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process_item.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process_item.mcfunction
new file mode 100644
index 0000000..fa67160
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/process_item.mcfunction
@@ -0,0 +1,15 @@
+# checks the item a change in durability
+# @s = player who has a custom durability item that changed durability
+# located at world spawn
+# run from durability/track_changes/process/
+# run from durability/damage/force/sub
+
+# compare new and old item damage
+execute store result score $new_damage smithed.item run data get storage smithed.item:main item.tag.Damage
+execute unless score $force smithed.item matches 1 store result score $old_damage smithed.item run data get storage smithed.item:main item.tag.smithed.durability.damage
+execute if score $new_damage smithed.item = $old_damage smithed.item run scoreboard players set $out smithed.item -2
+execute unless score $new_damage smithed.item = $old_damage smithed.item run function smithed.item:impl/durability/update/start
+
+# clean up
+scoreboard players reset $new_damage smithed.item
+scoreboard players reset $old_damage smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/wait.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/wait.mcfunction
new file mode 100644
index 0000000..f8cecea
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/track_changes/wait.mcfunction
@@ -0,0 +1,6 @@
+# waits until the item can be modified safely
+# @s = none
+# located at world spawn
+# run from durability/track_changes/mark
+
+execute as @a[tag=smithed.item.check] run function smithed.item:impl/durability/track_changes/check_durability
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/update/calc_durability.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/update/calc_durability.mcfunction
new file mode 100644
index 0000000..5be042c
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/update/calc_durability.mcfunction
@@ -0,0 +1,65 @@
+# calculates the item's new durability
+# @s = player who has a custom durability item that changed durability
+# located at world spawn
+# run from durability/update/start
+
+# set custom durability
+## get the change in damage (neg if durability decreased, pos if durability increased)
+scoreboard players operation $damage_diff smithed.item = $old_damage smithed.item
+scoreboard players operation $damage_diff smithed.item -= $new_damage smithed.item
+
+## add the change in damage to the durability
+scoreboard players operation $custom_durability smithed.item += $damage_diff smithed.item
+
+## bound between 0 and the custom max durability
+scoreboard players operation $custom_durability smithed.item < $custom_max smithed.item
+scoreboard players operation $custom_durability smithed.item > 0 smithed.const
+
+## update item's custom durability
+execute store result storage smithed.item:main item.tag.smithed.durability.dur int 1 run scoreboard players get $custom_durability smithed.item
+
+# set durability bar
+## get relative durability (new damage = custom durability / custom max * item max)
+scoreboard players operation $relative_dur smithed.item = $custom_durability smithed.item
+scoreboard players operation $relative_dur smithed.item *= $item_max smithed.item
+scoreboard players operation $relative_dur smithed.item /= $custom_max smithed.item
+
+## check if the item is allowed to break
+scoreboard players set $prevent_destroy smithed.item 0
+execute store result score $prevent_destroy smithed.item run data get storage smithed.item:main item.tag.smithed.durability.prevent_destroy
+execute if data storage smithed.item:main item{id:"minecraft:elytra"} unless data storage smithed.item:main item.tag.smithed.durability{prevent_destroy:0b} run scoreboard players set $prevent_destroy smithed.item 1
+
+## get the new expected item damage
+scoreboard players operation $item_damage smithed.item = $item_max smithed.item
+scoreboard players operation $item_damage smithed.item -= $relative_dur smithed.item
+## keep the item's actual durability above 10 (prevent item breaking)
+scoreboard players operation $minus_10 smithed.item = $item_max smithed.item
+scoreboard players remove $minus_10 smithed.item 10
+scoreboard players operation $item_damage smithed.item < $minus_10 smithed.item
+## keep the item's actual damage above 16 (prevent mending overflow), unless both the custom and relative damage are below 16
+scoreboard players operation $custom_damage smithed.item = $custom_max smithed.item
+scoreboard players operation $custom_damage smithed.item -= $custom_durability smithed.item
+execute if score $item_damage smithed.item matches ..15 if score $custom_damage smithed.item matches ..15 run scoreboard players operation $item_damage smithed.item = $custom_damage smithed.item
+execute if score $item_damage smithed.item matches ..15 unless score $custom_damage smithed.item matches ..15 run scoreboard players operation $item_damage smithed.item > 16 smithed.const
+## use actual durability bar if both the custom and relative durability dips below 10
+execute if score $relative_dur smithed.item matches 0..10 if score $custom_durability smithed.item matches 0..10 if score $prevent_destroy smithed.item matches 0 run scoreboard players operation $item_damage smithed.item = $item_max smithed.item
+execute if score $relative_dur smithed.item matches 0..10 if score $custom_durability smithed.item matches 0..10 if score $prevent_destroy smithed.item matches 0 run scoreboard players operation $item_damage smithed.item -= $custom_durability smithed.item
+
+## change the item's actual durability
+execute store result storage smithed.item:main item.tag.smithed.durability.damage int 1 store result storage smithed.item:main item.tag.Damage int 1 run scoreboard players get $item_damage smithed.item
+function smithed.item:impl/lore/build
+
+# output state (1 = durability changed, 0 = broken and gone, -1 = broken and converted to different item, -2 = no change (default))
+scoreboard players set $out smithed.item 1
+execute if score $custom_durability smithed.item matches 0 run scoreboard players set $out smithed.item 0
+execute if score $custom_durability smithed.item matches 0..1 unless score $prevent_destroy smithed.item matches 0 run scoreboard players set $out smithed.item -1
+
+# clean up
+scoreboard players reset $custom_durability smithed.item
+scoreboard players reset $damage_diff smithed.item
+scoreboard players reset $item_damage smithed.item
+scoreboard players reset $custom_max smithed.item
+scoreboard players reset $relative_dur smithed.item
+scoreboard players reset $custom_damage smithed.item
+scoreboard players reset $minus_10 smithed.item
+scoreboard players reset $prevent_destroy smithed.item
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/update/initial_data.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/update/initial_data.mcfunction
new file mode 100644
index 0000000..3c7520c
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/update/initial_data.mcfunction
@@ -0,0 +1,90 @@
+# populates the item data with specific nbt
+# @s = player who has a custom durability item that changed durability
+# located at world spawn
+# run from durability/damage
+
+# set default values
+execute store result storage smithed.item:main item.tag.smithed.durability.dur int 1 run scoreboard players get $custom_max smithed.item
+
+# store max durability of base item
+scoreboard players set $item_max smithed.item 0
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:golden_sword"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 32
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:golden_pickaxe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 32
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:golden_axe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 32
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:golden_shovel"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 32
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:golden_hoe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 32
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:wooden_sword"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 59
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:wooden_pickaxe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 59
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:wooden_axe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 59
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:wooden_shovel"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 59
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:wooden_hoe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 59
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:stone_sword"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 131
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:stone_pickaxe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 131
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:stone_axe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 131
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:stone_shovel"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 131
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:stone_hoe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 131
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:iron_sword"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 250
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:iron_pickaxe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 250
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:iron_axe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 250
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:iron_shovel"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 250
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:iron_hoe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 250
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:diamond_sword"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 1561
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:diamond_pickaxe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 1561
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:diamond_axe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 1561
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:diamond_shovel"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 1561
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:diamond_hoe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 1561
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:netherite_sword"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 2031
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:netherite_pickaxe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 2031
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:netherite_axe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 2031
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:netherite_shovel"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 2031
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:netherite_hoe"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 2031
+
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:turtle_helmet"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 275
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:leather_helmet"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 55
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:leather_chestplate"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 80
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:leather_leggings"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 75
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:leather_boots"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 65
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:golden_helmet"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 77
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:golden_chestplate"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 112
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:golden_leggings"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 105
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:golden_boots"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 91
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:chainmail_helmet"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 165
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:chainmail_chestplate"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 240
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:chainmail_leggings"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 225
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:chainmail_boots"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 195
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:iron_helmet"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 165
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:iron_chestplate"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 240
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:iron_leggings"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 225
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:iron_boots"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 195
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:diamond_helmet"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 363
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:diamond_chestplate"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 528
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:diamond_leggings"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 495
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:diamond_boots"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 429
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:netherite_helmet"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 407
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:netherite_chestplate"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 592
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:netherite_leggings"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 555
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:netherite_boots"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 481
+
+
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:fishing_rod"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 64
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:flint_and_steel"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 64
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:carrot_on_a_stick"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 25
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:shears"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 238
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:shield"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 336
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:bow"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 384
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:trident"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 250
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:elytra"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 432
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:crossbow"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 465
+execute if score $item_max smithed.item matches 0 if data storage smithed.item:main item{id:"minecraft:warped_fungus_on_a_stick"} store result storage smithed.item:main item.tag.smithed.durability.item_max int 1 run scoreboard players set $item_max smithed.item 100
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/update/start.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/update/start.mcfunction
new file mode 100644
index 0000000..ee1a227
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/update/start.mcfunction
@@ -0,0 +1,17 @@
+# runs the custom damage handling
+# @s = player who has a custom durability item that changed durability
+# located at world spawn
+# run from durability/track_changes/process_item
+
+# store durability related values into scoreboard
+execute store result score $custom_max smithed.item run data get storage smithed.item:main item.tag.smithed.durability.max
+execute unless data storage smithed.item:main item.tag.smithed.durability.dur run function smithed.item:impl/durability/update/initial_data
+execute store result score $custom_durability smithed.item run data get storage smithed.item:main item.tag.smithed.durability.dur
+execute unless score $item_max smithed.item matches 0.. store result score $item_max smithed.item run data get storage smithed.item:main item.tag.smithed.durability.item_max
+
+# calculate the new durability
+execute if score $item_max smithed.item matches 1.. run function smithed.item:impl/durability/update/calc_durability
+scoreboard players reset $item_max smithed.item
+
+# if the item broke, play the break sound
+execute if score $out smithed.item matches -1..0 run playsound minecraft:entity.item.break player @a[distance=..16]
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/load.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/load.mcfunction
index 9e32002..292019e 100644
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/load.mcfunction
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/load.mcfunction
@@ -1,5 +1,14 @@
forceload add -30000000 1600
setblock -30000000 0 1603 oak_sign
-scoreboard objectives add smithed.data dummy
+scoreboard objectives add smithed.item dummy
+scoreboard players set $delta smithed.item -1
-schedule function smithed.item:impl/technical/tick 1t replace
\ No newline at end of file
+scoreboard objectives add smithed.const dummy
+scoreboard players set 16 smithed.const 16
+scoreboard players set 2 smithed.const 2
+scoreboard players set 0 smithed.const 0
+
+scoreboard objectives add smithed.xp xp
+scoreboard objectives add smithed.item.prev_xp dummy
+
+#declare storage smithed.item:main
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/player.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/player.mcfunction
deleted file mode 100644
index 696d6b2..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/player.mcfunction
+++ /dev/null
@@ -1 +0,0 @@
-execute if data entity @s Inventory[].tag.smithed.durability run function smithed.item:impl/durability/detect
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/tick.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/tick.mcfunction
deleted file mode 100644
index 042df50..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/tick.mcfunction
+++ /dev/null
@@ -1,3 +0,0 @@
-execute as @a run function smithed.item:impl/technical/player
-
-schedule function smithed.item:impl/technical/tick 1t replace
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/item_modifiers/impl/update_nbt.json b/smithed_libraries/packs/item/data/smithed.item/item_modifiers/impl/update_nbt.json
new file mode 100644
index 0000000..749c349
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/item_modifiers/impl/update_nbt.json
@@ -0,0 +1,14 @@
+{
+ "function": "minecraft:copy_nbt",
+ "source": {
+ "type": "minecraft:storage",
+ "source": "smithed.item:main"
+ },
+ "ops": [
+ {
+ "source": "item.tag",
+ "target": "{}",
+ "op": "merge"
+ }
+ ]
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/item_modifiers/update_nbt.json b/smithed_libraries/packs/item/data/smithed.item/item_modifiers/update_nbt.json
deleted file mode 100644
index 333e920..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/item_modifiers/update_nbt.json
+++ /dev/null
@@ -1,16 +0,0 @@
-[
- {
- "function": "minecraft:copy_nbt",
- "source": {
- "type": "minecraft:storage",
- "source": "smithed.item:main"
- },
- "ops": [
- {
- "source": "item.tag",
- "target": "{}",
- "op": "merge"
- }
- ]
- }
-]
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/10.json b/smithed_libraries/packs/item/data/smithed.item/predicates/chance/10.json
deleted file mode 100644
index bb0df4d..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/10.json
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- {
- "condition": "minecraft:random_chance",
- "chance": 0.1
- }
- ]
-
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/11.json b/smithed_libraries/packs/item/data/smithed.item/predicates/chance/11.json
deleted file mode 100644
index 4fe0215..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/11.json
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- {
- "condition": "minecraft:random_chance",
- "chance": 0.111111111
- }
- ]
-
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/12.json b/smithed_libraries/packs/item/data/smithed.item/predicates/chance/12.json
deleted file mode 100644
index 97d7b4b..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/12.json
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- {
- "condition": "minecraft:random_chance",
- "chance": 0.125
- }
- ]
-
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/14.json b/smithed_libraries/packs/item/data/smithed.item/predicates/chance/14.json
deleted file mode 100644
index 9f11f66..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/14.json
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- {
- "condition": "minecraft:random_chance",
- "chance": 0.14285714
- }
- ]
-
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/16.json b/smithed_libraries/packs/item/data/smithed.item/predicates/chance/16.json
deleted file mode 100644
index 2bcf658..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/16.json
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- {
- "condition": "minecraft:random_chance",
- "chance": 0.166666667
- }
- ]
-
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/20.json b/smithed_libraries/packs/item/data/smithed.item/predicates/chance/20.json
deleted file mode 100644
index c375c49..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/20.json
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- {
- "condition": "minecraft:random_chance",
- "chance": 0.25
- }
- ]
-
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/25.json b/smithed_libraries/packs/item/data/smithed.item/predicates/chance/25.json
deleted file mode 100644
index c375c49..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/25.json
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- {
- "condition": "minecraft:random_chance",
- "chance": 0.25
- }
- ]
-
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/33.json b/smithed_libraries/packs/item/data/smithed.item/predicates/chance/33.json
deleted file mode 100644
index 159c2df..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/33.json
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- {
- "condition": "minecraft:random_chance",
- "chance": 0.333333333
- }
- ]
-
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/50.json b/smithed_libraries/packs/item/data/smithed.item/predicates/chance/50.json
deleted file mode 100644
index 9dedb43..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/50.json
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- {
- "condition": "minecraft:random_chance",
- "chance": 0.5
- }
- ]
-
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/9.json b/smithed_libraries/packs/item/data/smithed.item/predicates/chance/9.json
deleted file mode 100644
index d34d27f..0000000
--- a/smithed_libraries/packs/item/data/smithed.item/predicates/chance/9.json
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- {
- "condition": "minecraft:random_chance",
- "chance": 0.0909090909
- }
- ]
-
\ No newline at end of file
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/10.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/10.json
new file mode 100644
index 0000000..71f1937
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/10.json
@@ -0,0 +1,4 @@
+{
+ "condition": "minecraft:random_chance",
+ "chance": 0.1
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/11.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/11.json
new file mode 100644
index 0000000..a5214c3
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/11.json
@@ -0,0 +1,4 @@
+{
+ "condition": "minecraft:random_chance",
+ "chance": 0.111111111
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/12.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/12.json
new file mode 100644
index 0000000..f926018
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/12.json
@@ -0,0 +1,4 @@
+{
+ "condition": "minecraft:random_chance",
+ "chance": 0.125
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/14.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/14.json
new file mode 100644
index 0000000..eaba3e5
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/14.json
@@ -0,0 +1,4 @@
+{
+ "condition": "minecraft:random_chance",
+ "chance": 0.14285714
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/16.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/16.json
new file mode 100644
index 0000000..a4add80
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/16.json
@@ -0,0 +1,4 @@
+{
+ "condition": "minecraft:random_chance",
+ "chance": 0.166666667
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/20.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/20.json
new file mode 100644
index 0000000..ddc2b7b
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/20.json
@@ -0,0 +1,4 @@
+{
+ "condition": "minecraft:random_chance",
+ "chance": 0.25
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/25.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/25.json
new file mode 100644
index 0000000..ddc2b7b
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/25.json
@@ -0,0 +1,4 @@
+{
+ "condition": "minecraft:random_chance",
+ "chance": 0.25
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/33.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/33.json
new file mode 100644
index 0000000..48c244e
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/33.json
@@ -0,0 +1,4 @@
+{
+ "condition": "minecraft:random_chance",
+ "chance": 0.333333333
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/50.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/50.json
new file mode 100644
index 0000000..a3c55f5
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/50.json
@@ -0,0 +1,4 @@
+{
+ "condition": "minecraft:random_chance",
+ "chance": 0.5
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/9.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/9.json
new file mode 100644
index 0000000..749019d
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/chance/9.json
@@ -0,0 +1,4 @@
+{
+ "condition": "minecraft:random_chance",
+ "chance": 0.0909090909
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/chest.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/chest.json
new file mode 100644
index 0000000..d886ebd
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/chest.json
@@ -0,0 +1,14 @@
+{
+ "condition": "minecraft:entity_properties",
+ "entity": "this",
+ "predicate": {
+ "equipment": {
+ "chest": {
+ "count": {
+ "min": 1
+ },
+ "nbt": "{smithed:{durability:{}}}"
+ }
+ }
+ }
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/feet.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/feet.json
new file mode 100644
index 0000000..1faf704
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/feet.json
@@ -0,0 +1,14 @@
+{
+ "condition": "minecraft:entity_properties",
+ "entity": "this",
+ "predicate": {
+ "equipment": {
+ "feet": {
+ "count": {
+ "min": 1
+ },
+ "nbt": "{smithed:{durability:{}}}"
+ }
+ }
+ }
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/head.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/head.json
new file mode 100644
index 0000000..4c2419e
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/head.json
@@ -0,0 +1,14 @@
+{
+ "condition": "minecraft:entity_properties",
+ "entity": "this",
+ "predicate": {
+ "equipment": {
+ "head": {
+ "count": {
+ "min": 1
+ },
+ "nbt": "{smithed:{durability:{}}}"
+ }
+ }
+ }
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/legs.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/legs.json
new file mode 100644
index 0000000..ab25fc4
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/legs.json
@@ -0,0 +1,14 @@
+{
+ "condition": "minecraft:entity_properties",
+ "entity": "this",
+ "predicate": {
+ "equipment": {
+ "legs": {
+ "count": {
+ "min": 1
+ },
+ "nbt": "{smithed:{durability:{}}}"
+ }
+ }
+ }
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/mainhand.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/mainhand.json
new file mode 100644
index 0000000..5b67ad7
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/mainhand.json
@@ -0,0 +1,14 @@
+{
+ "condition": "minecraft:entity_properties",
+ "entity": "this",
+ "predicate": {
+ "equipment": {
+ "mainhand": {
+ "count": {
+ "min": 1
+ },
+ "nbt": "{smithed:{durability:{}}}"
+ }
+ }
+ }
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/offhand.json b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/offhand.json
new file mode 100644
index 0000000..f979d10
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/predicates/impl/has_custom_durability/offhand.json
@@ -0,0 +1,14 @@
+{
+ "condition": "minecraft:entity_properties",
+ "entity": "this",
+ "predicate": {
+ "equipment": {
+ "offhand": {
+ "count": {
+ "min": 1
+ },
+ "nbt": "{smithed:{durability:{}}}"
+ }
+ }
+ }
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/chest.json b/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/chest.json
new file mode 100644
index 0000000..86dde3d
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/chest.json
@@ -0,0 +1,3 @@
+{
+ "values": []
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/feet.json b/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/feet.json
new file mode 100644
index 0000000..86dde3d
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/feet.json
@@ -0,0 +1,3 @@
+{
+ "values": []
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/head.json b/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/head.json
new file mode 100644
index 0000000..86dde3d
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/head.json
@@ -0,0 +1,3 @@
+{
+ "values": []
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/legs.json b/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/legs.json
new file mode 100644
index 0000000..86dde3d
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/legs.json
@@ -0,0 +1,3 @@
+{
+ "values": []
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/mainhand.json b/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/mainhand.json
new file mode 100644
index 0000000..86dde3d
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/mainhand.json
@@ -0,0 +1,3 @@
+{
+ "values": []
+}
diff --git a/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/offhand.json b/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/offhand.json
new file mode 100644
index 0000000..86dde3d
--- /dev/null
+++ b/smithed_libraries/packs/item/data/smithed.item/tags/functions/event/item_changed/offhand.json
@@ -0,0 +1,3 @@
+{
+ "values": []
+}
From 875911f74f689143c526eed16799a8a6b2361e84 Mon Sep 17 00:00:00 2001
From: BluePsychoRanger <40612230+BluePsychoRanger@users.noreply.github.com>
Date: Sun, 9 Jul 2023 02:51:03 -0700
Subject: [PATCH 2/4] Update version
accidentally forgot to change the patch to 0
---
smithed_libraries/packs/item/beet.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/smithed_libraries/packs/item/beet.yaml b/smithed_libraries/packs/item/beet.yaml
index 9f13c64..d7ecdbc 100644
--- a/smithed_libraries/packs/item/beet.yaml
+++ b/smithed_libraries/packs/item/beet.yaml
@@ -3,7 +3,7 @@ extend: "@smithed_libraries/common.yaml"
id: smithed.item
name: Smithed Item
description: Native Item Library for Smithed
-version: "0.3.1"
+version: "0.3.0"
data_pack:
name: Smithed Item
From 28e662406fea80e644a77bee76a5f319ee60c3fc Mon Sep 17 00:00:00 2001
From: BluePsychoRanger <40612230+BluePsychoRanger@users.noreply.github.com>
Date: Sat, 5 Aug 2023 10:39:12 -0700
Subject: [PATCH 3/4] Document Lore Builder
- add in-code documentation to how the lore builder works
- use `smithed.item` scoreboard instead of `smithed.data`
- made "Unbreakable" lore consistent with vanilla (items are unbreakable if `Unbreakable` is a non-zero numeric tag)
- fixed attribute paths not being versioned
- removed empty function
---
.../functions/impl/lore/attributes.mcfunction | 74 +++++++++++--------
.../functions/impl/lore/build.mcfunction | 39 +++++++---
.../functions/impl/lore/custom.mcfunction | 13 +++-
.../functions/impl/lore/durability.mcfunction | 5 ++
.../impl/lore/enchantments.mcfunction | 26 +++++--
.../impl/lore/update_inventory.mcfunction | 0
6 files changed, 106 insertions(+), 51 deletions(-)
delete mode 100644 smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/update_inventory.mcfunction
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/attributes.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/attributes.mcfunction
index f62530e..3a0cf79 100644
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/attributes.mcfunction
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/attributes.mcfunction
@@ -1,7 +1,12 @@
+# builds attributes into lore
+# @s = (doesn't matter)
+# located at (doesn't matter)
+# run from lore/build
+
from bolt_expressions import Scoreboard, Data
from ./base_attributes import base_attributes
-data_obj = Scoreboard("smithed.data")
+data_obj = Scoreboard("smithed.item")
storage = Data.storage("smithed.item:main")
data modify storage smithed.item:main lore.slots set value {
@@ -13,18 +18,19 @@ data modify storage smithed.item:main lore.slots set value {
head: []
}
-
+# if there are no attribute modifiers, display the base attributes for the vanilla item
unless data storage smithed.item:main item.tag.AttributeModifiers[] function ./attributes/collect_base:
for id in base_attributes:
if data storage smithed.item:main item{id: id}:
storage.lore.temp = base_attributes[id]
- execute store result score $iter smithed.data if data storage smithed.item:main lore.temp[]
+ execute store result score $iter smithed.item if data storage smithed.item:main lore.temp[]
+# if there are attribute modifiers, prepare to iterate
if data storage smithed.item:main item.tag.AttributeModifiers[] function ./attributes/setup_non_base:
data modify storage smithed.item:main lore.temp set from storage smithed.item:main item.tag.AttributeModifiers
- execute store result score $iter smithed.data if data storage smithed.item:main lore.temp[]
-
+ execute store result score $iter smithed.item if data storage smithed.item:main lore.temp[]
+# then iterate through the attribute modifiers
if data storage smithed.item:main lore.temp[] function ./attributes/collect_non_base:
data modify storage smithed.item:main lore.attr set from storage smithed.item:main lore.temp[-1]
data remove storage smithed.item:main lore.attr.UUID
@@ -32,18 +38,20 @@ if data storage smithed.item:main lore.temp[] function ./attributes/collect_non_
data remove storage smithed.item:main lore.temp[-1]
+ # display for all slots (no slot specified in attribute modifier)
unless data storage smithed.item:main lore.attr.Slot function ./attributes/collect_non_base/any:
for slot in ['mainhand', 'offhand', 'feet', 'legs', 'chest', 'head']:
data modify storage smithed.item:main f'lore.slots.{slot}' append from storage smithed.item:main lore.attr
+ # display for single slot (slot specified in attribute modifier)
if data storage smithed.item:main lore.attr.Slot function ./attributes/collect_non_base/specific:
for slot in ['mainhand', 'offhand', 'feet', 'legs', 'chest', 'head']:
if data storage smithed.item:main lore.attr{Slot:slot} data modify storage smithed.item:main f'lore.slots.{slot}' append from storage smithed.item:main lore.attr
+ # loop through all attribute modifiers
+ scoreboard players remove $iter smithed.item 1
- scoreboard players remove $iter smithed.data 1
-
- if score $iter smithed.data matches 1.. function ./attributes/collect_non_base
+ if score $iter smithed.item matches 1.. function ./attributes/collect_non_base
modifiers = [
@@ -73,35 +81,40 @@ def generateOperations(mode):
data modify block -30000000 0 1603 front_text.messages[0] set from storage smithed.item:main lore.attr.initialJSON
+# now add the attributes to the lore
execute function ./attributes/add_lore:
- path = 'lore/attributes/add_lore'
+ path = 'impl/lore/attributes/add_lore'
for slot in ['mainhand', 'offhand', 'feet', 'legs', 'chest', 'head']:
function generate_path(f'{path}/{slot}')
+# for each slot, generate the applicable attribute text
for slot in ['mainhand', 'offhand', 'feet', 'legs', 'chest', 'head']:
function generate_path(f'{path}/{slot}'):
data modify storage smithed.item:main lore.temp set from storage smithed.item:main f'lore.slots.{slot}'
- execute store result score $iter smithed.data if data storage smithed.item:main lore.temp[]
+ execute store result score $iter smithed.item if data storage smithed.item:main lore.temp[]
- if score $iter smithed.data matches 1.. function generate_path(f"{path}/{slot}/add_header"):
+ # newline plus header (e.g. When in Main Hand:)
+ if score $iter smithed.item matches 1.. function generate_path(f"{path}/{slot}/add_header"):
data modify storage smithed.item:main item.tag.display.Lore append value '{"text":""}'
data modify storage smithed.item:main item.tag.display.Lore append value ('{"translate":"item.modifiers.'+slot+'","italic": "false","color":"gray"}')
- if score $iter smithed.data matches 1.. function generate_path(f"{path}/{slot}/loop"):
+ # get each modifier for this slot
+ if score $iter smithed.item matches 1.. function generate_path(f"{path}/{slot}/loop"):
data modify storage smithed.item:main lore.attr set from storage smithed.item:main lore.temp[-1]
data remove storage smithed.item:main lore.temp[-1]
- scoreboard players remove $iter smithed.data 1
+ scoreboard players remove $iter smithed.item 1
+ # calculations
data_obj["$oper"] = storage.lore.attr.Operation
data_obj["$scale"] = 100
- if score $oper smithed.data matches 1.. function generate_path(f"{path}/{slot}/set_scale"):
+ if score $oper smithed.item matches 1.. function generate_path(f"{path}/{slot}/set_scale"):
data_obj["$scale"] = 1
- execute store result score $amount smithed.data run data get storage smithed.item:main lore.attr.Amount 1000000
+ execute store result score $amount smithed.item run data get storage smithed.item:main lore.attr.Amount 1000000
if data storage smithed.item:main lore.attr{base:1b} function ./attributes/get_base:
for m in modifiers:
- if data storage smithed.item:main lore.attr{AttributeName: m} store result score $base smithed.data attribute @s f"minecraft:{m}" base get 1000000
- scoreboard players operation $amount smithed.data += $base smithed.data
+ if data storage smithed.item:main lore.attr{AttributeName: m} store result score $base smithed.item attribute @s f"minecraft:{m}" base get 1000000
+ scoreboard players operation $amount smithed.item += $base smithed.item
for m in modifiers:
if data storage smithed.item:main lore.attr{AttributeName: m} data modify storage smithed.item:main lore.attr.AttributeName set value ('{"translate": "attribute.name.' + m + '"}')
@@ -114,39 +127,40 @@ for slot in ['mainhand', 'offhand', 'feet', 'legs', 'chest', 'head']:
data_obj["$decimal"] /= data_obj["$scale"]
data_obj["$decimal"] -= data_obj["$whole"]
data_obj["$whole"] /= 10000
- # tellraw @s ["Whole: ", {"score":{"name":"$whole","objective":"smithed.data"}}]
- # tellraw @s ["Decim: ", {"score":{"name":"$decimal","objective":"smithed.data"}}]
+ # tellraw @s ["Whole: ", {"score":{"name":"$whole","objective":"smithed.item"}}]
+ # tellraw @s ["Decim: ", {"score":{"name":"$decimal","objective":"smithed.item"}}]
- if score $decimal smithed.data matches 1.. function generate_path(f"{path}/{slot}/simplify"):
+ if score $decimal smithed.item matches 1.. function generate_path(f"{path}/{slot}/simplify"):
data_obj["$decimalLast"] = data_obj["$decimal"] % 10
- if score $decimalLast smithed.data matches 0 function generate_path(f"{path}/{slot}/simplify/iter"):
+ if score $decimalLast smithed.item matches 0 function generate_path(f"{path}/{slot}/simplify/iter"):
data_obj["$decimal"] /= 10
function generate_path(f"{path}/{slot}/simplify")
- unless score $decimal smithed.data matches 0 function generate_path(f"{path}/{slot}/high_low"):
+ unless score $decimal smithed.item matches 0 function generate_path(f"{path}/{slot}/high_low"):
# say high_low
if data storage smithed.item:main lore.attr{base:1b}:
- storage.lore.attr.AmountJSON = '[" ",{"score":{"objective":"smithed.data","name":"$whole"}},".",{"score":{"objective":"smithed.data","name":"$decimal"}}]'
+ storage.lore.attr.AmountJSON = '[" ",{"score":{"objective":"smithed.item","name":"$whole"}},".",{"score":{"objective":"smithed.item","name":"$decimal"}}]'
unless data storage smithed.item:main lore.attr{base:1b}:
- storage.lore.attr.AmountJSON = '[{"score":{"objective":"smithed.data","name":"$whole"}},".",{"score":{"objective":"smithed.data","name":"$decimal"}}]'
- if score $decimal smithed.data matches 0 function generate_path(f"{path}/{slot}/high"):
+ storage.lore.attr.AmountJSON = '[{"score":{"objective":"smithed.item","name":"$whole"}},".",{"score":{"objective":"smithed.item","name":"$decimal"}}]'
+ if score $decimal smithed.item matches 0 function generate_path(f"{path}/{slot}/high"):
# say high
if data storage smithed.item:main lore.attr{base:1b}:
- storage.lore.attr.AmountJSON = '[" ",{"score":{"objective":"smithed.data","name":"$whole"}}]'
+ storage.lore.attr.AmountJSON = '[" ",{"score":{"objective":"smithed.item","name":"$whole"}}]'
unless data storage smithed.item:main lore.attr{base:1b}:
- storage.lore.attr.AmountJSON = '[{"score":{"objective":"smithed.data","name":"$whole"}}]'
+ storage.lore.attr.AmountJSON = '[{"score":{"objective":"smithed.item","name":"$whole"}}]'
storage.lore.attr.AmountHigh = data_obj["$whole"]
storage.lore.attr.AmountLow = data_obj["$decimal"]
+ # add to lore
if data storage smithed.item:main lore.attr{base:1b} function generate_path(f"{path}/{slot}/equals"):
generateOperations('equals')
unless data storage smithed.item:main lore.attr{base:1b} function generate_path(f"{path}/{slot}/not_equals"):
- if score $amount smithed.data matches 0.. function generate_path(f"{path}/{slot}/positive"):
+ if score $amount smithed.item matches 0.. function generate_path(f"{path}/{slot}/positive"):
generateOperations('plus')
- if score $amount smithed.data matches ..-1 function generate_path(f"{path}/{slot}/negative"):
+ if score $amount smithed.item matches ..-1 function generate_path(f"{path}/{slot}/negative"):
generateOperations('take')
data modify storage smithed.item:main item.tag.display.Lore append from block -30000000 0 1603 front_text.messages[0]
- if score $iter smithed.data matches 1.. function generate_path(f"{path}/{slot}/loop")
+ if score $iter smithed.item matches 1.. function generate_path(f"{path}/{slot}/loop")
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/build.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/build.mcfunction
index f23fb34..f61ba22 100644
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/build.mcfunction
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/build.mcfunction
@@ -1,46 +1,61 @@
# @public
+# builds the item stats with lore
+# @s = (doesn't matter)
+# located at (doesn't matter)
+# run from durability/update/calc_durability
+# run from api call
+
from bolt_expressions import Scoreboard, Data
storage = Data.storage("smithed.item:main")
-data_obj = Scoreboard("smithed.data")
+data_obj = Scoreboard("smithed.item")
#> input: smithed.item:main item
#> output: smithed.item:main item
+# set up item the first time
execute unless data storage smithed.item:main item.tag.smithed{hasLore:1b} run function ./setup:
+ # store actual lore into temp storage
storage.item.tag.smithed.lore = storage.item.tag.display.Lore
+ # get hideFlags values
storage.item.tag.smithed.hideFlags = {'0':0,'1':0,'2':0,'3':0,'4':0,'5':0,'6':0}
if data storage smithed.item:main item.tag.HideFlags:
data_obj["$hideFlags"] = storage.item.tag.HideFlags
for i in range(7):
- if score $hideFlags smithed.data matches f'{pow(2, 6-i)}..':
+ if score $hideFlags smithed.item matches f'{pow(2, 6-i)}..':
data_obj["$remainder"] = data_obj["$hideFlags"] % 2
data_obj["$hideFlags"] /= 2
- store result storage smithed.item:main f'item.tag.smithed.hideFlags.{i}' int 1 scoreboard players get $remainder smithed.data
+ store result storage smithed.item:main f'item.tag.smithed.hideFlags.{i}' int 1 scoreboard players get $remainder smithed.item
+ # set resulting item to be marked with smithed lore and hide all actual flags (except real durability since that's a debug option)
storage.item.tag.smithed.hasLore = 1b
storage.item.tag.HideFlags = 127
+# remove existing lore, going to build it up manually
data modify storage smithed.item:main item.tag.display.Lore set value []
-#resolve enchantments
+# resolve enchantments
execute if data storage smithed.item:main item.tag.smithed.hideFlags{0:0} if data storage smithed.item:main item.tag.Enchantments run function ./enchantments
-#resolve custom lore
+# resolve custom lore
execute if data storage smithed.item:main item.tag.smithed.lore run function ./custom
-
-#resolve attributes
+# resolve attributes
execute if data storage smithed.item:main item.tag.smithed.hideFlags{1:0} run function ./attributes
-#unbreakable
-execute if data storage smithed.item:main item.tag.smithed.hideFlags{2:0} if data storage smithed.item:main item.tag{Unbreakable:1b} data modify storage smithed.item:main item.tag.display.Lore append value '{"translate":"item.unbreakable","color":"blue","italic":false}'
-#custom pack id
+# unbreakable
+scoreboard players set $unbreakable smithed.item 0
+execute store result score $unbreakable smithed.item run data get storage smithed.item:main item.tag.Unbreakable 1
+execute if data storage smithed.item:main item.tag.smithed.hideFlags{2:0}
+ unless score $unbreakable smithed.item matches 0
+ data modify storage smithed.item:main item.tag.display.Lore append value '{"translate":"item.unbreakable","color":"blue","italic":false}'
+
+# custom pack id
execute if data storage smithed.item:main item.tag.smithed.origin:
data modify storage smithed.item:main item.tag.display.Lore append value '{"text":""}'
data modify storage smithed.item:main item.tag.display.Lore append from storage smithed.item:main item.tag.smithed.origin
-#resolve durability
-execute if data storage smithed.item:main item.tag.smithed.durability.dur run function ./durability
\ No newline at end of file
+# resolve durability
+execute if data storage smithed.item:main item.tag.smithed.durability.dur run function ./durability
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/custom.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/custom.mcfunction
index f11fb67..20a49a7 100644
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/custom.mcfunction
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/custom.mcfunction
@@ -1,13 +1,20 @@
+# builds actual lore into lore
+# @s = (doesn't matter)
+# located at (doesn't matter)
+# run from lore/build
+
+# get stored lore
data modify storage smithed.item:main lore.temp set from storage smithed.item:main item.tag.smithed.lore
-execute store result score $iter smithed.data if data storage smithed.item:main lore.temp[]
+execute store result score $iter smithed.item if data storage smithed.item:main lore.temp[]
execute function ./custom/iter:
+ # for each line of custom lore, add it to the item lore
data modify block -30000000 0 1603 front_text.messages[0] set from storage smithed.item:main lore.temp[-1]
data remove storage smithed.item:main lore.temp[-1]
- scoreboard players remove $iter smithed.data 1
+ scoreboard players remove $iter smithed.item 1
data modify storage smithed.item:main item.tag.display.Lore append from block -30000000 0 1603 front_text.messages[0]
- execute if score $iter smithed.data matches 1.. run function smithed.item:impl/lore/custom/iter
+ execute if score $iter smithed.item matches 1.. run function smithed.item:impl/lore/custom/iter
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/durability.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/durability.mcfunction
index 3d24eef..d0204a0 100644
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/durability.mcfunction
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/durability.mcfunction
@@ -1,2 +1,7 @@
+# builds durability into lore
+# @s = (doesn't matter)
+# located at (doesn't matter)
+# run from lore/build
+
data modify block -30000000 0 1603 front_text.messages[0] set value '{"translate":"item.durability","with":[{"nbt":"item.tag.smithed.durability.dur","storage":"smithed.item:main"},{"nbt":"item.tag.smithed.durability.max","storage":"smithed.item:main"}],"color":"white","italic":false}'
data modify storage smithed.item:main item.tag.display.Lore append from block -30000000 0 1603 front_text.messages[0]
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/enchantments.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/enchantments.mcfunction
index de03c54..173d2a4 100644
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/enchantments.mcfunction
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/enchantments.mcfunction
@@ -1,5 +1,10 @@
+# builds enchantments into lore
+# @s = (doesn't matter)
+# located at (doesn't matter)
+# run from lore/build
+
from bolt_expressions import Scoreboard, Data
-data_obj = Scoreboard("smithed.data")
+data_obj = Scoreboard("smithed.item")
storage = Data.storage("smithed.item:main")
enchantments = [
@@ -48,31 +53,40 @@ storage.enchantments = storage.item.tag.Enchantments
execute function ./enchantments/loop:
+ # go through each enchantment in the order they were added to the item
storage.temp = storage.enchantments[-1]
data remove storage smithed.item:main 'enchantments'[-1]
storage.lore.lvl = storage.temp.lvl
data_obj["$lvl"] = storage.lore.lvl
+ # match enchantment with the proper string
execute function ./enchantments/loop/find_ench:
+ # add the enchantment to the lore
for e in enchantments:
if data storage smithed.item:main temp{id: e}:
storage.lore.ench = ('{"translate":"enchantment.'+e.replace(':','.')+'","italic": "false","color":"gray"}')
+ # custom enchantment handling
function #smithed.item:event/build_custom
+ # match enchantment level with proper string
execute function ./enchantments/loop/find_level:
- if score $lvl smithed.data matches 1 function ./enchantments/loop/special_level:
+ # don't display level 1 if there's only one level
+ if score $lvl smithed.item matches 1 function ./enchantments/loop/special_level:
storage.lore.lvl = ('{"translate":"enchantment.level.1","italic": "false","color":"gray"}')
only_one_level =['minecraft:aqua_affinity','minecraft:channeling','minecraft:riptide','minecraft:curse_of_binding','minecraft:curse_of_vanishing','minecraft:flame','minecraft:infinity','minecraft:mending','minecraft:multishot']
for e in only_one_level:
if data storage smithed.item:main temp{id: e}:
storage.lore.lvl = ''
+ # display 2-10 using translate string
for i in range(2,11):
- if score $lvl smithed.data matches (i):
+ if score $lvl smithed.item matches (i):
storage.lore.lvl = ('{"translate":"enchantment.level.'+str(i)+'","italic": "false","color":"gray"}')
- if score $lvl smithed.data matches 11..:
- storage.lore.lvl = ('{"score":{"objective":"smithed.data","name":"$lvl","italic": "false","color":"gray"}}')
+ # display higher levels with the number (this is NOT how vanilla does it. but it's a better QoL)
+ if score $lvl smithed.item matches 11..:
+ storage.lore.lvl = ('{"score":{"objective":"smithed.item","name":"$lvl","italic": "false","color":"gray"}}')
+ # sign trick to concat name and level into single string
data modify block -30000000 0 1603 front_text.messages[0] set value '[{"nbt":"lore.ench","storage":"smithed.item:main","interpret":true}," ",{"nbt":"lore.lvl","storage":"smithed.item:main","interpret":true}]'
data modify storage smithed.item:main item.tag.display.Lore prepend from block -30000000 0 1603 front_text.messages[0]
- if data storage smithed.item:main 'enchantments'[] function ./enchantments/loop
\ No newline at end of file
+ if data storage smithed.item:main 'enchantments'[] function ./enchantments/loop
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/update_inventory.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/lore/update_inventory.mcfunction
deleted file mode 100644
index e69de29..0000000
From 113f7f038ed9020d7af83bd404c87f5ad1c5387d Mon Sep 17 00:00:00 2001
From: BluePsychoRanger <40612230+BluePsychoRanger@users.noreply.github.com>
Date: Sat, 5 Aug 2023 10:40:08 -0700
Subject: [PATCH 4/4] two small fixes
- fix unbreakable check to only allow numeric tags (int, short, long, byte)
- remove unnecessary xp scoreboards
---
.../impl/durability/damage/force/calc_unbreaking.mcfunction | 2 +-
.../data/smithed.item/functions/impl/technical/load.mcfunction | 3 ---
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force/calc_unbreaking.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force/calc_unbreaking.mcfunction
index 22175a9..caa9173 100644
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force/calc_unbreaking.mcfunction
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/durability/damage/force/calc_unbreaking.mcfunction
@@ -8,7 +8,7 @@ execute store result score $unbreaking_lvl smithed.item run data get storage smi
# check if the item is unbreakable
scoreboard players set $unbreakable smithed.item 0
-execute store result score $unbreakable smithed.item run data get storage smithed.item:main item.tag.Unbreakable
+execute store result score $unbreakable smithed.item run data get storage smithed.item:main item.tag.Unbreakable 1
execute unless score $unbreakable smithed.item matches 0 run scoreboard players set $unbreaking_lvl smithed.item -1
# if delta is positive (i.e. adding durability), ignore unbreaking
diff --git a/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/load.mcfunction b/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/load.mcfunction
index 292019e..a8a7f31 100644
--- a/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/load.mcfunction
+++ b/smithed_libraries/packs/item/data/smithed.item/functions/impl/technical/load.mcfunction
@@ -8,7 +8,4 @@ scoreboard players set 16 smithed.const 16
scoreboard players set 2 smithed.const 2
scoreboard players set 0 smithed.const 0
-scoreboard objectives add smithed.xp xp
-scoreboard objectives add smithed.item.prev_xp dummy
-
#declare storage smithed.item:main