Skip to content

Commit 6675c2a

Browse files
committed
Fix migration remove dead code
1 parent 05f389e commit 6675c2a

2 files changed

Lines changed: 8 additions & 27 deletions

File tree

common/src/main/java/net/spell_power/SpellPowerMod.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ public static AttributesConfig.AttributeScope attributeScope() {
156156
}
157157

158158
public static void migrateAttributes(ServerPlayerEntity player) {
159-
var attributes = List.of(SpellSchools.GENERIC.attributeEntry);
159+
var attributes = SpellSchools.all().stream()
160+
.filter(school -> school.isMagicArchetype() && school.ownsAttribute())
161+
.map(school -> school.attributeEntry)
162+
.toList();
160163
for (var attribute: attributes) {
161164
if (attribute == null) {
162165
continue;

common/src/main/java/net/spell_power/api/SpellSchool.java

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ public enum Archetype { ARCHERY, MAGIC, MELEE }
6565
@Nullable public RegistryEntry<EntityAttribute> attributeEntry;
6666
@Nullable public RegistryEntry<Potion> potionEntry;
6767

68-
public float innateBonus = 0;
69-
7068
public SpellSchool(Archetype archetype, Identifier id, int color, RegistryKey<DamageType> damageType, RegistryEntry<EntityAttribute> attributeEntry) {
7169
this(archetype, id, color, damageType, null, null);
7270
this.attributeEntry = attributeEntry;
@@ -79,30 +77,6 @@ public SpellSchool(Archetype archetype, Identifier id, int color, RegistryKey<Da
7977
this.damageType = damageType;
8078
this.ownedAttribute = attribute;
8179
this.ownedBoostEffect = boostEffect;
82-
this.innateBonus = SpellPowerMod.attributesConfig.safeValue().base_spell_power;
83-
}
84-
85-
public SpellSchool innateModifier(float value) {
86-
this.innateBonus = 0F;
87-
return this;
88-
}
89-
90-
public boolean hasInnateModifier() {
91-
return innateBonus >= 0F;
92-
}
93-
94-
private Supplier<EntityAttributeModifier> innateModifier = Suppliers.memoize(() ->
95-
new EntityAttributeModifier(
96-
ModifierDefinitions.INNATE_BONUS,
97-
this.getInnateBonus(),
98-
EntityAttributeModifier.Operation.ADD_VALUE
99-
)
100-
);
101-
private float getInnateBonus() {
102-
return innateBonus;
103-
}
104-
public EntityAttributeModifier getInnateModifier() {
105-
return innateModifier.get();
10680
}
10781

10882
public float attributeBaseValue() {
@@ -134,6 +108,10 @@ public boolean ownsAttribute() {
134108
return ownedAttribute != null;
135109
}
136110

111+
public boolean isMagicArchetype() {
112+
return archetype == Archetype.MAGIC;
113+
}
114+
137115
// Sources
138116
public enum Apply { ADD, MULTIPLY }
139117
public record QueryArgs(LivingEntity entity) { }

0 commit comments

Comments
 (0)