Skip to content

Commit

Permalink
feat: Dispel Item Curse spell works on modded curses (enchantments) a…
Browse files Browse the repository at this point in the history
…s well, if added to the config. Relates to #227
  • Loading branch information
WinDanesz committed Jan 27, 2024
1 parent 3019d16 commit 3997397
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
19 changes: 15 additions & 4 deletions src/main/java/com/windanesz/ancientspellcraft/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,16 @@ public static class GeneralSettings {
@Config.RangeInt(min = 0, max = 100)
public int spellblade_charge_gain_per_hit = 5;

@Config.Name("Spellblade base hit mana cost per tier")
@Config.Comment("The amount of mana required & consumed when the spellblade is used to hit a target, based on the tier of the blade\n"
+ "Example: if the cost is 5, a novice blade will consume 5 mana, an apprentice sword will consume 2x5 mana, a master blade will consume 20 mana")
@Config.Name("Spellblade basic attack mana cost")
@Config.Comment("The amount of mana required & consumed when the spellblade is used to hit a target")
@Config.RequiresMcRestart
@Config.RangeInt(min = 0, max = 100)
public int spellblade_base_mana_cost = 0;
public int spellblade_base_mana_cost = 1;

@Config.Name("Spellblade base mana per tier")
@Config.Comment("The amount of mana a spell blade has by default for each tier,")
@Config.RequiresMcRestart
public int[] spell_blade_base_mana_per_tier = {150, 300, 600, 900};

@Config.Name("Orb Artefact Potency Percent Bonus")
@Config.Comment("Determines the potency bonus of the elemental orb artefacts in a percentage value")
Expand Down Expand Up @@ -377,6 +381,13 @@ public static class GeneralSettings {
"minecraft:slowness"
};

@Config.Name("Curses that the Dispel Item Curse spell can remove. Should work with modded enchantments as well.")
@Config.RequiresMcRestart
public String[] dispel_item_curse_list = {
"minecraft:vanishing_curse",
"minecraft:binding_curse"
};

@Config.Name("Metamagic - Projectile incompatible spells")
@Config.RequiresMcRestart
public String[] metamagic_projectile_incompatible_spells = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.windanesz.ancientspellcraft.spell;

import com.windanesz.ancientspellcraft.Settings;
import com.windanesz.ancientspellcraft.registry.ASItems;
import electroblob.wizardry.spell.SpellBuff;
import electroblob.wizardry.util.ParticleBuilder;
Expand All @@ -12,7 +13,9 @@
import net.minecraft.init.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.ForgeRegistries;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -35,8 +38,7 @@ protected boolean applyEffects(EntityLivingBase caster, SpellModifiers modifiers
if (!player.getHeldItemOffhand().isEmpty()) {
ItemStack offHandItemStack = player.getHeldItemOffhand();
return attemptRemoveCurseFromItemStack(offHandItemStack);
}
else {
} else {
List<ItemStack> itemStackList = new ArrayList<>();
for (ItemStack stack : player.getArmorInventoryList()) {
if (!stack.isEmpty()) {
Expand All @@ -53,19 +55,18 @@ protected boolean applyEffects(EntityLivingBase caster, SpellModifiers modifiers
}

private static boolean attemptRemoveCurseFromItemStack(ItemStack stack) {
if (EnchantmentHelper.hasBindingCurse(stack)) {
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack);
enchantments.remove(Enchantments.BINDING_CURSE);
EnchantmentHelper.setEnchantments(enchantments, stack);
return true;
} else if (EnchantmentHelper.hasVanishingCurse(stack)) {
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack);
enchantments.remove(Enchantments.VANISHING_CURSE);
EnchantmentHelper.setEnchantments(enchantments, stack);
return true;
} else {
return false;
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack);
for (String registryName : Settings.generalSettings.dispel_item_curse_list) {
if (ForgeRegistries.ENCHANTMENTS.containsKey(new ResourceLocation(registryName))) {
Enchantment currEnchantment = ForgeRegistries.ENCHANTMENTS.getValue(new ResourceLocation(registryName));
if (enchantments.containsKey(currEnchantment)) {
enchantments.remove(currEnchantment);
EnchantmentHelper.setEnchantments(enchantments, stack);
return true;
}
}
}
return false;
}

@Override
Expand Down

0 comments on commit 3997397

Please sign in to comment.