Skip to content

Commit

Permalink
Remove Prometheum Attribute Event, and simplify Prometheum handling
Browse files Browse the repository at this point in the history
This event did not actually function.
Tags are not populated until the world loads,
which is way too late for this event.

The tag checks for the Prometheum tick are
also not strictly needed to handle everything correctly.
The handling already requires armor to be an ArmorItem,
and tools to hold attributes.
  • Loading branch information
Noaaan committed Mar 1, 2025
1 parent 7051577 commit 19466a8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
5 changes: 5 additions & 0 deletions PATCHNOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 0 additions & 21 deletions src/main/java/nourl/mythicmetals/MythicMetals.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <br>
* 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.
* <br>
* 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<PrometheumComponent> ENDEC = StructEndecBuilder.of(
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/nourl/mythicmetals/mixin/ItemMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 19466a8

Please sign in to comment.