From 136b1cc92460c300c99198d119a157edccca1d06 Mon Sep 17 00:00:00 2001
From: WinDanesz <31292708+WinDanesz@users.noreply.github.com>
Date: Fri, 30 Jun 2023 16:03:54 +0200
Subject: [PATCH] feat: Added preventBindingSameSpellTwiceToWands setting
(disabled by default). Controls whether to prevent binding the same spell to
a wand multiple times
---
src/main/java/electroblob/wizardry/Settings.java | 9 +++++++++
src/main/java/electroblob/wizardry/item/ItemWand.java | 9 +++++++++
src/main/resources/assets/ebwizardry/lang/en_us.lang | 2 ++
3 files changed, 20 insertions(+)
diff --git a/src/main/java/electroblob/wizardry/Settings.java b/src/main/java/electroblob/wizardry/Settings.java
index 375ee04f..b36b0594 100644
--- a/src/main/java/electroblob/wizardry/Settings.java
+++ b/src/main/java/electroblob/wizardry/Settings.java
@@ -203,6 +203,8 @@ public final class Settings {
public boolean damageTypePerElement = false;
/** [Server-only] Whether spell books are consumed when they are bound to a wand.*/
public boolean singleUseSpellBooks = false;
+ /** [Server-only] Whether to prevent binding the same spell to a wand multiple times*/
+ public boolean preventBindingSameSpellTwiceToWands = false;
/** [Server-only] Whether to revert to the old wand upgrade system, which only requires tomes of arcana. */
public boolean legacyWandLevelling = false;
/** [Server-only] Whether to tweak the blindness effect to reduce follow distance when used on non-players. */
@@ -646,6 +648,13 @@ public final class Settings {
singleUseSpellBooks = property.getBoolean();
propOrder.add(property.getName());
+ property = config.get(GAMEPLAY_CATEGORY, "preventBindingSameSpellTwiceToWands", false,
+ "Whether to prevent binding the same spell to a wand multiple times");
+ property.setLanguageKey("config." + Wizardry.MODID + ".prevent_binding_same_spell_twice_to_wands");
+ Wizardry.proxy.setToNamedBooleanEntry(property);
+ preventBindingSameSpellTwiceToWands = property.getBoolean();
+ propOrder.add(property.getName());
+
property = config.get(GAMEPLAY_CATEGORY, "playersMoveEachOther", true,
"Whether to allow players to move other players around using magic.");
property.setLanguageKey("config." + Wizardry.MODID + ".players_move_each_other");
diff --git a/src/main/java/electroblob/wizardry/item/ItemWand.java b/src/main/java/electroblob/wizardry/item/ItemWand.java
index 75780b58..ef6c077b 100644
--- a/src/main/java/electroblob/wizardry/item/ItemWand.java
+++ b/src/main/java/electroblob/wizardry/item/ItemWand.java
@@ -46,6 +46,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
+import java.util.Arrays;
import java.util.List;
import java.util.Random;
@@ -843,8 +844,16 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
Spell spell = Spell.byMetadata(spellBooks[i].getStack().getItemDamage());
// If the wand is powerful enough for the spell, it's not already bound to that slot and it's enabled for wands
if(!(spell.getTier().level > this.tier.level) && spells[i] != spell && spell.isEnabled(SpellProperties.Context.WANDS)){
+
+ // Decide if we can bind this multiple times
+ if (Wizardry.settings.preventBindingSameSpellTwiceToWands && Arrays.stream(spells).anyMatch(s -> s == spell)) {
+ continue;
+ }
+
spells[i] = spell;
changed = true;
+
+ // setting to consume books upon use
if (Wizardry.settings.singleUseSpellBooks) {
spellBooks[i].getStack().shrink(1);
}
diff --git a/src/main/resources/assets/ebwizardry/lang/en_us.lang b/src/main/resources/assets/ebwizardry/lang/en_us.lang
index 8e32e52c..5cfc7bd5 100644
--- a/src/main/resources/assets/ebwizardry/lang/en_us.lang
+++ b/src/main/resources/assets/ebwizardry/lang/en_us.lang
@@ -1539,6 +1539,8 @@ config.ebwizardry.damage_type_per_element=Damage Type Per Element
config.ebwizardry.damage_type_per_element.tooltip=Whether damage should be registered with the old system (wizardry_magic/indirect_wizardry_magic) prefixed damage with the elements like necromancy_indirect_wizardry_magic, necromancy_wizardry_magic. This is disabled by default to not break existing modpacks. The intention of this setting is to allow differentiating various damage types for e.g. the Distinct Damage Descriptions mod
config.ebwizardry.single_use_spell_books=Spell Books Are Consumed By Wands
config.ebwizardry.single_use_spell_books.tooltip=Whether spell books are consumed when they are bound to a wand.
+config.ebwizardry.prevent_binding_same_spell_twice_to_wands=Prevent Binding The Same Spell To A Wand Multiple Times
+config.ebwizardry.prevent_binding_same_spell_twice_to_wands.tooltip=Whether to prevent binding the same spell to a wand multiple times
config.ebwizardry.telekinetic_disarmament=Telekinetic Disarmament
config.ebwizardry.telekinetic_disarmament.tooltip=Whether to allow players to disarm other players using the telekinesis spell. Disable to prevent stealing of items.
config.ebwizardry.telekinetic_disarmament.true=Yes - let people steal things