Salinity — 通用库模组
Salinity 是我个人使用的实用工具库模组,为我的各类模组提供共享的属性系统和辅助工具,以避免代码冗余。
当前功能状态
以下功能在所有版本(低于 26.1)中均可用:
mitigation — 伤害减免
arrow_damage — 箭矢伤害加成
arrow_speed — 箭矢速度倍率
attack_range — 近战攻击范围
以下与法术相关的功能仅在 26.1 及以上版本可用(低于 26.1 的版本中不存在):
1. 法术属性
1.1 法术伤害与法术强度
| 属性 ID |
显示名称 |
默认值 |
描述 |
salinity:spell_damage |
法术伤害 |
0.0 |
直接增加法术伤害(可修改) |
salinity:spell_power |
法术强度 |
0.0 |
对所有法术的二次倍率加成(可修改) |
1.2 法术抗性
| 属性 ID |
显示名称 |
默认值 |
描述 |
salinity:spell_resistance |
法术抗性 |
0.0 |
减少受到的法术伤害;数值越高,减伤越多 |
所有属性均支持原版修饰符(ADD_VALUE、ADD_MULTIPLIED_BASE、ADD_MULTIPLIED_TOTAL),以便灵活配置。
2. 伤害计算流程
2.1 总体流程
基础伤害 → [法术伤害加成] → [法术强度加成] → [法术抗性减伤] → 最终伤害
2.2 法术伤害加成
将施法者的 spell_damage 属性应用于基础伤害,并按顺序处理所有修饰符:
- 汇总所有
ADD_VALUE 修饰符 → add
- 汇总所有
ADD_MULTIPLIED_BASE 修饰符 → mult_base
- 汇总所有
ADD_MULTIPLIED_TOTAL 修饰符 → mult_total
公式:
after_spell_damage = (base_damage + add) × (1 + mult_base) × (1 + mult_total)
2.3 法术强度加成
将施法者的 spell_power 属性应用于上述结果,使用相同的修饰符顺序:
after_spell_power = (after_spell_damage + add_power) × (1 + mult_base_power) × (1 + mult_total_power)
2.4 法术抗性减伤
应用目标的法术抗性,同时考虑目标的盔甲韧性(minecraft:armor_toughness):
final_damage = after_spell_power × 200 / ( resistance × (1 + toughness/10) × √(after_spell_power) + 200 )
其中:
resistance: 目标的 salinity:spell_resistance 值
toughness: 目标的 minecraft:armor_toughness 值(若无则为 0)
√(after_spell_power): 经过法术强度加成后的伤害值的平方根
注意:如果抗性为 0,则跳过减伤步骤,此时 final_damage = after_spell_power。
3. 法术抗性减伤示例表
下表假设施法者的 spell_damage 和 spell_power 均为 0(即无加成,after_spell_power 等于基础伤害),仅展示抗性与韧性的影响效果。
3.1 韧性 = 0
| 基础伤害 |
Res=5 |
Res=10 |
Res=20 |
| 10 |
9.27 |
8.63 |
7.60 |
| 20 |
17.99 |
16.35 |
13.82 |
| 40 |
34.54 |
30.39 |
24.50 |
3.2 韧性 = 3
| 基础伤害 |
Res=5 |
Res=10 |
Res=20 |
| 10 |
9.07 |
8.30 |
7.09 |
| 20 |
17.46 |
15.50 |
12.65 |
| 40 |
33.18 |
28.35 |
21.95 |
3.3 韧性 = 6
| 基础伤害 |
Res=5 |
Res=10 |
Res=20 |
| 10 |
8.88 |
7.98 |
6.64 |
| 20 |
16.97 |
14.73 |
11.66 |
| 40 |
31.93 |
26.56 |
19.88 |
3.4 韧性 = 12
| 基础伤害 |
Res=5 |
Res=10 |
Res=20 |
| 10 |
8.52 |
7.42 |
5.90 |
| 20 |
16.05 |
13.41 |
10.08 |
| 40 |
29.68 |
23.59 |
16.73 |
所有数值均四舍五入至两位小数;游戏内实际值为浮点数。
4. 伤害类型
- 伤害类型 ID:
salinity:spell
- 特性:
- 无视盔甲
- 不受原版保护附魔的影响
- 不触发原版魔法伤害相关效果(例如药水保护)
5. 向物品添加法术属性(API 示例)
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
ItemStack staff = new ItemStack(ModItems.DOOM_STAFF.get());
// 添加 +5 法术伤害 (ADD_VALUE)
SalinityAPI.addModifier(staff, ModAttributes.SPELL_DAMAGE, "staff_damage", 5.0, AttributeModifier.Operation.ADD_VALUE);
// 添加 +20% 法术强度 (ADD_MULTIPLIED_BASE)
SalinityAPI.addModifier(staff, ModAttributes.SPELL_POWER, "staff_power", 0.2, AttributeModifier.Operation.ADD_MULTIPLIED_BASE);
6. 注意事项(仅限法术功能)
- 抗性公式中的平方根确保了低伤害时减伤较弱,而高伤害时减伤显著。
- 如果目标的法术抗性为 0,则完全跳过减伤步骤。
- 施法者的
spell_damage 和 spell_power 可以通过装备、药水效果等方式动态修改。
用法
- 适用于 Trial Catacombs:Salinity 为必需依赖。若使用低于 26.1 的版本,法术相关属性将无效。
- 适用于其他开发者:可自由将 Salinity 作为依赖使用。按需调用已注册的属性即可。如需使用法术系统,请确保版本 ≥ 26.1。
Technical Info
中文介绍
Salinity — 通用模组库
Salinity 是我为个人模组开发的通用库模组,提供跨模组常用的属性系统和工具类,避免重复造轮子。
当前功能状态
以下功能在所有版本中可用(26.1 以下版本):
mitigation — 减伤
arrow_damage — 箭矢伤害加成
arrow_speed — 箭矢速度倍率
attack_range — 近战攻击距离
以下法术相关功能仅 26.1 及以上版本提供(26.1 以下版本不包含):
1. 法术属性
1.1 法术伤害与法术强度
| 属性ID |
显示名称 |
默认值 |
说明 |
salinity:spell_damage |
法术伤害 |
0.0 |
直接对法术伤害加成(可受修饰符影响) |
salinity:spell_power |
法术强度 |
0.0 |
对所有法术进行二次加成(可受修饰符影响) |
1.2 法术抗性
| 属性ID |
显示名称 |
默认值 |
说明 |
salinity:spell_resistance |
法术抗性 |
0.0 |
减免所受法术伤害,值越高减伤越强 |
所有属性均支持原版修饰符(ADD_VALUE, ADD_MULTIPLIED_BASE, ADD_MULTIPLIED_TOTAL),可灵活配置。
2. 伤害计算流程
2.1 总流程
原始伤害 → [法术伤害加成] → [法术强度加成] → [法术抗性减伤] → 最终伤害
2.2 法术伤害加成
对原始伤害应用施法者的 spell_damage 属性,按以下顺序处理所有修饰符:
- 累加所有
ADD_VALUE 修饰符 → add
- 累加所有
ADD_MULTIPLIED_BASE 修饰符 → mult_base
- 累加所有
ADD_MULTIPLIED_TOTAL 修饰符 → mult_total
计算公式:
after_spell_damage = (原始伤害 + add) × (1 + mult_base) × (1 + mult_total)
2.3 法术强度加成
对上述结果应用施法者的 spell_power 属性,同样按上述顺序处理所有修饰符:
after_spell_power = (after_spell_damage + add_power) × (1 + mult_base_power) × (1 + mult_total_power)
2.4 法术抗性减伤
对加成后的伤害应用目标法术抗性,同时考虑目标的原版盔甲韧性(minecraft:armor_toughness),公式如下:
最终伤害 = after_spell_power × 200 / ( 法抗 × (1 + 韧性/10) × √(after_spell_power) + 200 )
其中:
法抗:目标的 salinity:spell_resistance 属性值
韧性:目标的 minecraft:armor_toughness 属性值(若无则为 0)
√(after_spell_power):加成后伤害的平方根
注意:当法抗为 0 时,跳过减伤步骤,最终伤害 = after_spell_power。
3. 法术抗性减伤效果表(示例)
以下表格假设施法者的 spell_damage 和 spell_power 均为默认值 0(即无加成,after_spell_power = 原始伤害),仅展示抗性和韧性对伤害的影响。
3.1 无韧性(韧性 = 0)
| 原始伤害 |
法抗=5 |
法抗=10 |
法抗=20 |
| 10 |
9.27 |
8.63 |
7.60 |
| 20 |
17.99 |
16.35 |
13.82 |
| 40 |
34.54 |
30.39 |
24.50 |
3.2 韧性 = 3
| 原始伤害 |
法抗=5 |
法抗=10 |
法抗=20 |
| 10 |
9.07 |
8.30 |
7.09 |
| 20 |
17.46 |
15.50 |
12.65 |
| 40 |
33.18 |
28.35 |
21.95 |
3.3 韧性 = 6
| 原始伤害 |
法抗=5 |
法抗=10 |
法抗=20 |
| 10 |
8.88 |
7.98 |
6.64 |
| 20 |
16.97 |
14.73 |
11.66 |
| 40 |
31.93 |
26.56 |
19.88 |
3.4 韧性 = 12
| 原始伤害 |
法抗=5 |
法抗=10 |
法抗=20 |
| 10 |
8.52 |
7.42 |
5.90 |
| 20 |
16.05 |
13.41 |
10.08 |
| 40 |
29.68 |
23.59 |
16.73 |
表格中所有数值保留两位小数,实际游戏内为浮点数。
4. 伤害类型
- 伤害类型 ID:
salinity:spell
- 特性:
- 无视护甲
- 不受原版保护附魔影响
- 不触发原版魔法伤害相关效果(如药水保护)
5. 为物品添加法术属性(API 示例)
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
ItemStack staff = new ItemStack(ModItems.DOOM_STAFF.get());
// 添加 +5 法术伤害(基础值)
SalinityAPI.addModifier(staff, ModAttributes.SPELL_DAMAGE, "staff_damage", 5.0, AttributeModifier.Operation.ADD_VALUE);
// 添加 +20% 法术强度(乘法)
SalinityAPI.addModifier(staff, ModAttributes.SPELL_POWER, "staff_power", 0.2, AttributeModifier.Operation.ADD_MULTIPLIED_BASE);
6.法术功能注意事项
- 法术抗性减伤公式中的平方根确保低伤害时减伤较弱,高伤害时减伤显著。
- 若目标法术抗性为 0,则不进行减伤计算,直接应用加成后伤害。
- 施法者的
spell_damage 和 spell_power 属性可以通过装备、药水效果等动态修改。
使用说明
- 对 Trial Catacombs:Salinity 为必需前置库。如果使用 v26.1 以下版本,法术相关属性将无效。
- 对其他开发者:可将 Salinity 作为依赖,按需调用已注册的属性。如需使用法术系统,请确保版本 ≥ 26.1。
开发信息
Salinity — Common Library Mod
Salinity is my personal utility library mod, providing shared attribute systems and helper tools across my mods to avoid redundant code.
Current Feature Status
The following features are available in all versions (below 26.1):
mitigation — damage reduction
arrow_damage — arrow damage bonus
arrow_speed — arrow speed multiplier
attack_range — melee attack range
The following spell-related features are only available in 26.1 and above (not present in versions below 26.1):
1. Spell Attributes
1.1 Spell Damage & Spell Power
| Attribute ID |
Display Name |
Default |
Description |
salinity:spell_damage |
Spell Damage |
0.0 |
Direct bonus to spell damage (modifiable) |
salinity:spell_power |
Spell Power |
0.0 |
Secondary multiplier to all spells (modifiable) |
1.2 Spell Resistance
| Attribute ID |
Display Name |
Default |
Description |
salinity:spell_resistance |
Spell Resistance |
0.0 |
Reduces incoming spell damage; higher = more reduction |
All attributes support vanilla modifiers (ADD_VALUE, ADD_MULTIPLIED_BASE, ADD_MULTIPLIED_TOTAL) for flexible configuration.
2. Damage Calculation Flow
2.1 Overall Flow
Base Damage → [Spell Damage Bonus] → [Spell Power Bonus] → [Spell Resistance Reduction] → Final Damage
2.2 Spell Damage Bonus
Apply the caster's spell_damage attribute to the base damage, processing all modifiers in order:
- Sum all
ADD_VALUE modifiers → add
- Sum all
ADD_MULTIPLIED_BASE modifiers → mult_base
- Sum all
ADD_MULTIPLIED_TOTAL modifiers → mult_total
Formula:
after_spell_damage = (base_damage + add) × (1 + mult_base) × (1 + mult_total)
2.3 Spell Power Bonus
Apply the caster's spell_power attribute to the result above, using the same modifier order:
after_spell_power = (after_spell_damage + add_power) × (1 + mult_base_power) × (1 + mult_total_power)
2.4 Spell Resistance Reduction
Apply the target's spell resistance, also considering the target's vanilla armor toughness (minecraft:armor_toughness):
final_damage = after_spell_power × 200 / ( resistance × (1 + toughness/10) × √(after_spell_power) + 200 )
Where:
resistance: target's salinity:spell_resistance value
toughness: target's minecraft:armor_toughness value (0 if absent)
√(after_spell_power): square root of the damage after spell power bonus
Note: If resistance is 0, the reduction step is skipped and final_damage = after_spell_power.
3. Spell Resistance Reduction Example Tables
The tables below assume the caster's spell_damage and spell_power are both 0 (i.e., no bonus, after_spell_power = base damage), showing only the effect of resistance and toughness.
3.1 Toughness = 0
| Base Damage |
Res=5 |
Res=10 |
Res=20 |
| 10 |
9.27 |
8.63 |
7.60 |
| 20 |
17.99 |
16.35 |
13.82 |
| 40 |
34.54 |
30.39 |
24.50 |
3.2 Toughness = 3
| Base Damage |
Res=5 |
Res=10 |
Res=20 |
| 10 |
9.07 |
8.30 |
7.09 |
| 20 |
17.46 |
15.50 |
12.65 |
| 40 |
33.18 |
28.35 |
21.95 |
3.3 Toughness = 6
| Base Damage |
Res=5 |
Res=10 |
Res=20 |
| 10 |
8.88 |
7.98 |
6.64 |
| 20 |
16.97 |
14.73 |
11.66 |
| 40 |
31.93 |
26.56 |
19.88 |
3.4 Toughness = 12
| Base Damage |
Res=5 |
Res=10 |
Res=20 |
| 10 |
8.52 |
7.42 |
5.90 |
| 20 |
16.05 |
13.41 |
10.08 |
| 40 |
29.68 |
23.59 |
16.73 |
All values are rounded to two decimals; actual in-game values are floating point.
4. Damage Type
- Damage Type ID:
salinity:spell
- Characteristics:
- Ignores armor
- Not affected by vanilla Protection enchantments
- Does not trigger vanilla magic damage related effects (e.g., potion protection)
5 Adding Spell Attributes to Items (API Example)
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
ItemStack staff = new ItemStack(ModItems.DOOM_STAFF.get());
// Add +5 spell damage (ADD_VALUE)
SalinityAPI.addModifier(staff, ModAttributes.SPELL_DAMAGE, "staff_damage", 5.0, AttributeModifier.Operation.ADD_VALUE);
// Add +20% spell power (ADD_MULTIPLIED_BASE)
SalinityAPI.addModifier(staff, ModAttributes.SPELL_POWER, "staff_power", 0.2, AttributeModifier.Operation.ADD_MULTIPLIED_BASE);
6. Notes (Spell Features Only)
- The square root in the resistance formula ensures weaker reduction for low damage and significant reduction for high damage.
- If the target's spell resistance is 0, the reduction step is skipped entirely.
- The caster's
spell_damage and spell_power can be dynamically modified via equipment, potion effects, etc.
Usage
- For Trial Catacombs: Salinity is a required dependency. If using a version below 26.1, spell-related attributes will have no effect.
- For other developers: Feel free to use Salinity as a dependency. Call the registered attributes as needed. To use the spell system, ensure version ≥ 26.1.
Technical Info
中文介绍
Salinity — 通用模组库
Salinity 是我为个人模组开发的通用库模组,提供跨模组常用的属性系统和工具类,避免重复造轮子。
当前功能状态
以下功能在所有版本中可用(26.1 以下版本):
mitigation — 减伤
arrow_damage — 箭矢伤害加成
arrow_speed — 箭矢速度倍率
attack_range — 近战攻击距离
以下法术相关功能仅 26.1 及以上版本提供(26.1 以下版本不包含):
1. 法术属性
1.1 法术伤害与法术强度
| 属性ID |
显示名称 |
默认值 |
说明 |
salinity:spell_damage |
法术伤害 |
0.0 |
直接对法术伤害加成(可受修饰符影响) |
salinity:spell_power |
法术强度 |
0.0 |
对所有法术进行二次加成(可受修饰符影响) |
1.2 法术抗性
| 属性ID |
显示名称 |
默认值 |
说明 |
salinity:spell_resistance |
法术抗性 |
0.0 |
减免所受法术伤害,值越高减伤越强 |
所有属性均支持原版修饰符(ADD_VALUE, ADD_MULTIPLIED_BASE, ADD_MULTIPLIED_TOTAL),可灵活配置。
2. 伤害计算流程
2.1 总流程
原始伤害 → [法术伤害加成] → [法术强度加成] → [法术抗性减伤] → 最终伤害
2.2 法术伤害加成
对原始伤害应用施法者的 spell_damage 属性,按以下顺序处理所有修饰符:
- 累加所有
ADD_VALUE 修饰符 → add
- 累加所有
ADD_MULTIPLIED_BASE 修饰符 → mult_base
- 累加所有
ADD_MULTIPLIED_TOTAL 修饰符 → mult_total
计算公式:
after_spell_damage = (原始伤害 + add) × (1 + mult_base) × (1 + mult_total)
2.3 法术强度加成
对上述结果应用施法者的 spell_power 属性,同样按上述顺序处理所有修饰符:
after_spell_power = (after_spell_damage + add_power) × (1 + mult_base_power) × (1 + mult_total_power)
2.4 法术抗性减伤
对加成后的伤害应用目标的法术抗性,同时考虑目标的原版盔甲韧性(minecraft:armor_toughness),公式如下:
最终伤害 = after_spell_power × 200 / ( 法抗 × (1 + 韧性/10) × √(after_spell_power) + 200 )
其中:
法抗:目标的 salinity:spell_resistance 属性值
韧性:目标的 minecraft:armor_toughness 属性值(若无则为 0)
√(after_spell_power):加成后伤害的平方根
注意:当法抗为 0 时,跳过减伤步骤,最终伤害 = after_spell_power。
3. 法术抗性减伤效果表(示例)
以下表格假设施法者的 spell_damage 和 spell_power 均为默认值 0(即无加成,after_spell_power = 原始伤害),仅展示抗性和韧性对伤害的影响。
3.1 无韧性(韧性 = 0)
| 原始伤害 |
法抗=5 |
法抗=10 |
法抗=20 |
| 10 |
9.27 |
8.63 |
7.60 |
| 20 |
17.99 |
16.35 |
13.82 |
| 40 |
34.54 |
30.39 |
24.50 |
3.2 韧性 = 3
| 原始伤害 |
法抗=5 |
法抗=10 |
法抗=20 |
| 10 |
9.07 |
8.30 |
7.09 |
| 20 |
17.46 |
15.50 |
12.65 |
| 40 |
33.18 |
28.35 |
21.95 |
3.3 韧性 = 6
| 原始伤害 |
法抗=5 |
法抗=10 |
法抗=20 |
| 10 |
8.88 |
7.98 |
6.64 |
| 20 |
16.97 |
14.73 |
11.66 |
| 40 |
31.93 |
26.56 |
19.88 |
3.4 韧性 = 12
| 原始伤害 |
法抗=5 |
法抗=10 |
法抗=20 |
| 10 |
8.52 |
7.42 |
5.90 |
| 20 |
16.05 |
13.41 |
10.08 |
| 40 |
29.68 |
23.59 |
16.73 |
表格中所有数值保留两位小数,实际游戏内为浮点数。
4. 伤害类型
- 伤害类型 ID:
salinity:spell
- 特性:
- 无视护甲
- 不受原版保护附魔影响
- 不触发原版魔法伤害相关效果(如药水保护)
5. 为物品添加法术属性(API 示例)
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
ItemStack staff = new ItemStack(ModItems.DOOM_STAFF.get());
// 添加 +5 法术伤害(基础值)
SalinityAPI.addModifier(staff, ModAttributes.SPELL_DAMAGE, "staff_damage", 5.0, AttributeModifier.Operation.ADD_VALUE);
// 添加 +20% 法术强度(乘法)
SalinityAPI.addModifier(staff, ModAttributes.SPELL_POWER, "staff_power", 0.2, AttributeModifier.Operation.ADD_MULTIPLIED_BASE);
6.法术功能注意事项
- 法术抗性减伤公式中的平方根确保低伤害时减伤较弱,高伤害时减伤显著。
- 若目标法术抗性为 0,则不进行减伤计算,直接应用加成后伤害。
- 施法者的
spell_damage 和 spell_power 属性可以通过装备、药水效果等动态修改。
使用说明
- 对 Trial Catacombs:Salinity 为必需前置库。如果使用 v26.1 以下版本,法术相关属性将无效。
- 对其他开发者:可将 Salinity 作为依赖,按需调用已注册的属性。如需使用法术系统,请确保版本 ≥ 26.1。
开发信息
评论 0
登录后参与评分
还没有评论,来抢沙发吧