diff --git a/PATCHNOTES.md b/PATCHNOTES.md
index 0f34f068..7f044f4e 100644
--- a/PATCHNOTES.md
+++ b/PATCHNOTES.md
@@ -33,6 +33,11 @@ Most of these are made by thyreo. Thanks again for awesome new textures!
- Added compat with Sword Blocking Mechanics (#280)
- The Aegis and Midas Gold Swords are now present in the `#mythicmetals:swords` tag
- Empty slot textures now match new tool shapes
+- Updated the Prometheum Auto Repair Component handling
+ - No longer checks for `#c:armor` or `#c:tools`
+ - Will check for items in the `#mythicmetals:abilities/auto_repair` tag
+ - Armor buff only applies items extending `ArmorItem`
+ - Tool buff only applies to non-armor items which hold the `minecraft:attribute_modifiers` component
### Mythril Drill Recipe Rework
diff --git a/src/main/java/nourl/mythicmetals/MythicMetals.java b/src/main/java/nourl/mythicmetals/MythicMetals.java
index 3f88b630..74727121 100644
--- a/src/main/java/nourl/mythicmetals/MythicMetals.java
+++ b/src/main/java/nourl/mythicmetals/MythicMetals.java
@@ -5,7 +5,6 @@
import io.wispforest.owo.itemgroup.gui.ItemGroupButton;
import io.wispforest.owo.registration.reflect.FieldRegistrationHandler;
import net.fabricmc.api.ModInitializer;
-import net.fabricmc.fabric.api.item.v1.DefaultItemComponentEvents;
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.loader.api.FabricLoader;
@@ -23,11 +22,9 @@
import nourl.mythicmetals.blocks.MythicBlocks;
import nourl.mythicmetals.command.MythicCommands;
import nourl.mythicmetals.component.MythicDataComponents;
-import nourl.mythicmetals.component.PrometheumComponent;
import nourl.mythicmetals.conditions.MythicResourceConditions;
import nourl.mythicmetals.config.MythicMetalsConfig;
import nourl.mythicmetals.data.MythicOreKeys;
-import nourl.mythicmetals.data.MythicTags;
import nourl.mythicmetals.effects.MythicStatusEffects;
import nourl.mythicmetals.entity.CombustionCooldown;
import nourl.mythicmetals.entity.MythicEntities;
@@ -106,8 +103,6 @@ public void onInitialize() {
factories.add(new TradeOffers.SellItemFactory(MythicItems.Templates.AEGIS_SMITHING_TEMPLATE, 48, 1, 2, 30));
});
registerDispenserBehaviour();
- registerPrometheumAttributeEvent();
-
if (CONFIG.configVersion() < CONFIG_VERSION) {
for (int i = 0; i < 5; i++) {
@@ -136,22 +131,6 @@ public void onInitialize() {
LOGGER.info("[Mythic Metals] Mythic Metals is now initialized.");
}
- /**
- * Registers an event that modifies all armor items in the tag with bonus attributes when bound
- * When the item is in {@link MythicTags#COMMON_ARMOR} it will gain bonus protection.
- * Note that this has to be {@link net.minecraft.item.ArmorItem}, as otherwise it will not get the effect.
- * When the item is in {@link MythicTags#COMMON_TOOLS} it will gain bonus damage
- *
- * @see nourl.mythicmetals.mixin.ItemMixin
- */
- public static void registerPrometheumAttributeEvent() {
- DefaultItemComponentEvents.MODIFY.register(context -> {
- context.modify(item -> item.getDefaultStack().isIn(MythicTags.AUTO_REPAIR), (builder, item) -> {
- builder.add(MythicDataComponents.PROMETHEUM, PrometheumComponent.DEFAULT);
- });
- });
- }
-
private void registerDispenserBehaviour() {
DispenserBlock.registerBehavior(() -> MythicTools.STAR_PLATINUM_ARROW, new ProjectileDispenserBehavior(MythicTools.STAR_PLATINUM_ARROW));
DispenserBlock.registerBehavior(() -> MythicTools.RUNITE_ARROW, new ProjectileDispenserBehavior(MythicTools.RUNITE_ARROW));
diff --git a/src/main/java/nourl/mythicmetals/component/PrometheumComponent.java b/src/main/java/nourl/mythicmetals/component/PrometheumComponent.java
index a96c1108..d702be61 100644
--- a/src/main/java/nourl/mythicmetals/component/PrometheumComponent.java
+++ b/src/main/java/nourl/mythicmetals/component/PrometheumComponent.java
@@ -9,8 +9,20 @@
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
+import nourl.mythicmetals.data.MythicTags;
import nourl.mythicmetals.misc.RegistryHelper;
+/**
+ * A data carrier which holds and tracks the Prometheum Auto Repair ability.
+ * Only applies to items within the {@link MythicTags#AUTO_REPAIR} tag.
+ *
+ * If the Item is an {@link net.minecraft.item.ArmorItem} it gains bonus armor, and/or armor toughness.
+ * Otherwise, if the Item has {@link net.minecraft.component.DataComponentTypes#ATTRIBUTE_MODIFIERS} it will gain bonus damage.
+ *
+ * Append this component on your {@link net.minecraft.item.Item.Settings} to use it.
+ *
+ * @see nourl.mythicmetals.mixin.ItemMixin
+ */
public record PrometheumComponent(int durabilityRepaired) {
public static final int OVERGROWN_THRESHOLD = 1200;
public static final StructEndec ENDEC = StructEndecBuilder.of(
diff --git a/src/main/java/nourl/mythicmetals/mixin/ItemMixin.java b/src/main/java/nourl/mythicmetals/mixin/ItemMixin.java
index 0545e48d..1693a957 100644
--- a/src/main/java/nourl/mythicmetals/mixin/ItemMixin.java
+++ b/src/main/java/nourl/mythicmetals/mixin/ItemMixin.java
@@ -29,15 +29,14 @@ public abstract class ItemMixin {
// Handle Overgrown modifiers
// Armor gets armor and toughness. Anything else gets extra damage
if (prometheumComponent.isOvergrown()) {
- if (stack.isIn(MythicTags.COMMON_ARMOR) && stack.getItem() instanceof ArmorItem item) {
+ if (stack.getItem() instanceof ArmorItem item) {
var attributeComponent = item.getAttributeModifiers();
var changedComponent = attributeComponent
.with(EntityAttributes.GENERIC_ARMOR, createOvergrownModifier(stack, 1, item.getSlotType()), AttributeModifierSlot.forEquipmentSlot(item.getSlotType()))
.with(EntityAttributes.GENERIC_ARMOR_TOUGHNESS, createOvergrownToughnessModifier(stack, 0), AttributeModifierSlot.forEquipmentSlot(item.getSlotType()));
stack.set(DataComponentTypes.ATTRIBUTE_MODIFIERS, changedComponent);
}
-
- if (stack.isIn(MythicTags.COMMON_TOOLS)) {
+ else if (stack.contains(DataComponentTypes.ATTRIBUTE_MODIFIERS)) {
var attributeComponent = stack.get(DataComponentTypes.ATTRIBUTE_MODIFIERS);
var modifier = createOvergrownModifier(stack, 0);
var changedComponent = attributeComponent.with(EntityAttributes.GENERIC_ATTACK_DAMAGE, modifier, AttributeModifierSlot.MAINHAND);