1
1
package smartin .miapi .mixin ;
2
2
3
3
import com .llamalad7 .mixinextras .injector .ModifyReturnValue ;
4
+ import net .minecraft .core .Holder ;
5
+ import net .minecraft .core .registries .Registries ;
4
6
import net .minecraft .world .item .ItemStack ;
5
7
import net .minecraft .world .item .enchantment .Enchantment ;
6
8
import org .spongepowered .asm .mixin .Mixin ;
7
9
import org .spongepowered .asm .mixin .injection .At ;
8
10
import smartin .miapi .item .modular .ModularItem ;
11
+ import smartin .miapi .modules .ItemModule ;
12
+ import smartin .miapi .modules .ModuleInstance ;
13
+ import smartin .miapi .modules .properties .enchanment .AllowedEnchantments ;
9
14
10
15
@ Mixin (Enchantment .class )
11
16
public abstract class EnchantmentMixin {
@@ -23,7 +28,13 @@ public abstract class EnchantmentMixin {
23
28
private boolean miapi$adjustSupportedItem (boolean original , ItemStack itemStack ) {
24
29
if (ModularItem .isModularItem (itemStack )) {
25
30
Enchantment enchantment = (Enchantment ) (Object ) (this );
26
- //return AllowedEnchantments.isAllowed(itemStack, enchantment, original);
31
+ ModuleInstance moduleInstance = ItemModule .getModules (itemStack );
32
+ if (moduleInstance != null && moduleInstance .registryAccess != null ) {
33
+ Holder <Enchantment > holder = moduleInstance .registryAccess .registry (Registries .ENCHANTMENT ).get ().wrapAsHolder (enchantment );
34
+ if (holder !=null ){
35
+ return AllowedEnchantments .isAllowed (itemStack , holder , original );
36
+ }
37
+ }
27
38
}
28
39
return original ;
29
40
}
@@ -32,7 +43,13 @@ public abstract class EnchantmentMixin {
32
43
private boolean miapi$adjustcanEnchant (boolean original , ItemStack itemStack ) {
33
44
if (ModularItem .isModularItem (itemStack )) {
34
45
Enchantment enchantment = (Enchantment ) (Object ) (this );
35
- //return AllowedEnchantments.isAllowed(itemStack, enchantment, original);
46
+ ModuleInstance moduleInstance = ItemModule .getModules (itemStack );
47
+ if (moduleInstance != null && moduleInstance .registryAccess != null ) {
48
+ Holder <Enchantment > holder = moduleInstance .registryAccess .registry (Registries .ENCHANTMENT ).get ().wrapAsHolder (enchantment );
49
+ if (holder !=null ){
50
+ return AllowedEnchantments .isAllowed (itemStack , holder , original );
51
+ }
52
+ }
36
53
}
37
54
return original ;
38
55
}
0 commit comments