File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
src/main/java/dev/dubhe/anvilcraft/item/property/component Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ private static void tickEnabled(ItemStack stack) {
4747 int levels = 0 ;
4848
4949 // 将已无情的魔咒的等级添至总等级
50- ItemEnchantments mercilessEnchs = stack .get (ModComponents .MERCILESS_ENCHANTMENTS );
50+ ItemEnchantments mercilessEnchs = stack .getOrDefault (ModComponents .MERCILESS_ENCHANTMENTS , ItemEnchantments . EMPTY );
5151 for (Holder <Enchantment > enchantment : mercilessEnchs .keySet ()) {
5252 levels += mercilessEnchs .getLevel (enchantment );
5353 }
@@ -114,11 +114,11 @@ private static void tickDisabled(ItemStack stack) {
114114 stack .getOrDefault (DataComponents .ENCHANTMENTS , ItemEnchantments .EMPTY )
115115 );
116116 ItemEnchantments .Mutable mercilessEnchsMut = new ItemEnchantments .Mutable (mercilessEnchs );
117- for (Iterator <Holder <Enchantment >> it = mercilessEnchsMut .keySet ().iterator (); it .hasNext (); ) {
118- Holder <Enchantment > enchantment = it .next ();
117+ for (Holder <Enchantment > enchantment : mercilessEnchsMut .keySet ()) {
119118 enchsMut .set (enchantment , mercilessEnchsMut .getLevel (enchantment ));
120- it .remove ();
121119 }
120+ stack .set (DataComponents .ENCHANTMENTS , enchsMut .toImmutable ());
121+ stack .set (ModComponents .MERCILESS_ENCHANTMENTS , ItemEnchantments .EMPTY );
122122
123123 // 移除属性修饰符
124124 ItemAttributeModifiers .Builder builder = ItemAttributeModifiers .builder ();
You can’t perform that action at this time.
0 commit comments