Iron's Spells 'n Spellbooks

Iron's Spells 'n Spellbooks

18M Downloads

Only apply 1 spell power attribute as Apotheosis affix

SiverDX opened this issue ยท 3 comments

commented

Feature description

I'm doing this to have such functionality:

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import shadows.apotheosis.adventure.affix.Affix;
import shadows.apotheosis.adventure.loot.LootRarity;

import java.util.Set;

@Mixin(value = LootRarity.LootRule.class, remap = false)
public abstract class LootRarityMixin {
    @ModifyExpressionValue(method = "lambda$execute$3", at = @At(value = "INVOKE", target = "Ljava/util/Set;contains(Ljava/lang/Object;)Z"))
    private static boolean filterAffixes(boolean doesContain, final ItemStack stack, final LootRarity rarity, final Set<Affix> currentAffixes, @Local(argsOnly = true) final Affix affix) {
        if (doesContain) {
            return true;
        }

        String groupId = trialanderro$getGroupId(affix);

        if (!groupId.isBlank()) {
            for (Affix currentAffix : currentAffixes) {
                if (trialanderro$getGroupId(currentAffix).equals(groupId)) {
                    return true;
                }
            }
        }

        return false;
    }

    @Unique
    private static String trialanderro$getGroupId(final Affix affix) {
        if (affix == null) {
            return "";
        }

        ResourceLocation id = affix.getId();
        String[] path = id.getPath().split("/");

        if (path.length > 1 && path[0].equals("group")) {
            return path[1];
        }

        return "";
    }
}

everything in the directory affixes\group\ will be checked
Meaning if you have 5 affixes in affixes\group\spell_power\ only 1 will be applied

You could in theory give the generic spell power a lower amount and the type-specific ones a higher one

How it improves the player experience

Does not clutter the affix table

commented

yeah i was meaning more or less supported like loot categories, compared to mixing in. If shadows is aware, might just wait for official support. We still need to clean up our apoth compat after the big update that overhauled gems.

commented

This is a cool concept. Does apotheosis offer any api-supported ways to do this, or does it require a mixin?

commented

Currently there is no API to my knowledge
The developer is aware of the idea though

image