Search in sources :

Example 1 with ChargedProperties

use of net.silentchaos512.gear.api.stats.ChargedProperties in project Silent-Gear by SilentChaos512.

the class MaterialInstance method getEnchantmentModifiedStats.

@Deprecated
private void getEnchantmentModifiedStats(List<StatInstance> mods, StatGearKey key) {
    if (key.getStat() == ItemStats.CHARGEABILITY) {
        return;
    }
    // Search for materials that stats
    for (Map.Entry<Enchantment, Integer> entry : EnchantmentHelper.getEnchantments(this.item).entrySet()) {
        Enchantment enchantment = entry.getKey();
        Integer level = entry.getValue();
        if (enchantment instanceof IStatModifierEnchantment) {
            IStatModifierEnchantment statModifierEnchantment = (IStatModifierEnchantment) enchantment;
            ChargedProperties charge = new ChargedProperties(level, getChargeability());
            // Replace modifiers with updated ones (if provided)
            for (int i = 0; i < mods.size(); i++) {
                StatInstance mod = mods.get(i);
                StatInstance newMod = statModifierEnchantment.modifyStat(key, mod, charge);
                if (newMod != null) {
                    mods.remove(i);
                    mods.add(i, newMod);
                }
            }
        }
    }
}
Also used : ChargedProperties(net.silentchaos512.gear.api.stats.ChargedProperties) IStatModifierEnchantment(net.silentchaos512.gear.api.enchantment.IStatModifierEnchantment) StatInstance(net.silentchaos512.gear.api.stats.StatInstance) Enchantment(net.minecraft.world.item.enchantment.Enchantment) IStatModifierEnchantment(net.silentchaos512.gear.api.enchantment.IStatModifierEnchantment)

Aggregations

Enchantment (net.minecraft.world.item.enchantment.Enchantment)1 IStatModifierEnchantment (net.silentchaos512.gear.api.enchantment.IStatModifierEnchantment)1 ChargedProperties (net.silentchaos512.gear.api.stats.ChargedProperties)1 StatInstance (net.silentchaos512.gear.api.stats.StatInstance)1