21
21
22
22
import net .minecraft .tags .ItemTags ;
23
23
import net .minecraft .world .entity .EquipmentSlotGroup ;
24
+ import net .minecraft .world .entity .ai .attributes .AttributeModifier ;
25
+ import net .minecraft .world .entity .ai .attributes .Attributes ;
24
26
import net .minecraft .world .item .enchantment .Enchantments ;
25
27
import net .neoforged .neoforge .common .Tags ;
28
+ import org .auioc .mcmod .harmonicench .api .HEEnchantedValue ;
26
29
import org .auioc .mcmod .harmonicench .api .HEEnchantment ;
30
+ import org .auioc .mcmod .harmonicench .component .HEEDataComponents ;
31
+ import org .auioc .mcmod .harmonicench .enchantment .HEEnchantmentEffectComponents ;
27
32
import org .auioc .mcmod .harmonicench .enchantment .HEEnchantments ;
33
+ import org .auioc .mcmod .harmonicench .enchantment .effect .HEAttributeEffect ;
34
+ import org .auioc .mcmod .harmonicench .enchantment .effect .SetItemProficiency ;
35
+
36
+ import java .util .List ;
28
37
29
38
/**
30
39
* <b>TODO 熟练 Proficiency</b>
@@ -61,6 +70,17 @@ public class ProficiencyEnchantment extends HEEnchantment {
61
70
*/
62
71
private static final Cost COST = dynamicCost (1 , 10 , 61 , 10 );
63
72
73
+
74
+ /**
75
+ * <code>[∑(lvl,k=1)(1/k)]/200</code>
76
+ */
77
+ private static final HEEnchantedValue PROBABILITY = HEEnchantedValue .fraction (
78
+ HEEnchantedValue .harmonic (HEEnchantedValue .level (), 1.0F , HEEnchantedValue .identity ()),
79
+ HEEnchantedValue .constant (200 )
80
+ );
81
+
82
+ private static final HEEnchantedValue BONUS = HEEnchantedValue .fromDataComponent (HEEDataComponents .PROFICIENCY .get ());
83
+
64
84
private static final BuilderFunction BUILDER = define (
65
85
SUPPORTED_ITEMS ,
66
86
PRIMARY_ITEMS ,
@@ -69,9 +89,24 @@ public class ProficiencyEnchantment extends HEEnchantment {
69
89
5 ,
70
90
COST ,
71
91
1 ,
72
- EquipmentSlotGroup .HAND
92
+ EquipmentSlotGroup .MAINHAND
73
93
).andThen ((key , ctx , builder ) -> builder
74
-
94
+ .withEffect (
95
+ HEEnchantmentEffectComponents .BLOCK_DESTROYED .get (),
96
+ new SetItemProficiency (HEEnchantedValue .chance (
97
+ PROBABILITY ,
98
+ HEEnchantedValue .sum (HEEnchantedValue .identity (), HEEnchantedValue .constant (1 )),
99
+ HEEnchantedValue .identity ()
100
+ ))
101
+ ).withSpecialEffect (
102
+ HEEnchantmentEffectComponents .ATTRIBUTES .get (),
103
+ List .of (new HEAttributeEffect (
104
+ HEEnchantments .PROFICIENCY ,
105
+ Attributes .MINING_EFFICIENCY ,
106
+ BONUS ,
107
+ AttributeModifier .Operation .ADD_MULTIPLIED_BASE
108
+ ))
109
+ )
75
110
);
76
111
77
112
public static Bootstrap .Builder bootstrap () {
0 commit comments