|
9 | 9 | import com.mmodding.mmodding_lib.library.items.CustomBookItem; |
10 | 10 | import com.mmodding.mmodding_lib.library.enchantments.CustomEnchantment; |
11 | 11 | import com.mmodding.mmodding_lib.library.enchantments.types.EnchantmentType; |
| 12 | +import com.mmodding.mmodding_lib.library.items.CustomEnchantedBookItem; |
12 | 13 | import net.minecraft.enchantment.Enchantment; |
13 | 14 | import net.minecraft.enchantment.EnchantmentHelper; |
14 | 15 | import net.minecraft.item.Item; |
|
22 | 23 | @Mixin(EnchantmentHelper.class) |
23 | 24 | public class EnchantmentHelperMixin { |
24 | 25 |
|
| 26 | + @WrapOperation(method = "get", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z")) |
| 27 | + private static boolean allowGetCustomEnchantedBookItems(ItemStack instance, Item item, Operation<Boolean> original) { |
| 28 | + return instance.getItem() instanceof CustomEnchantedBookItem || original.call(instance, item); |
| 29 | + } |
| 30 | + |
| 31 | + @WrapOperation(method = "set", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z")) |
| 32 | + private static boolean allowSetCustomEnchantedBookItems(ItemStack instance, Item item, Operation<Boolean> original) { |
| 33 | + return instance.getItem() instanceof CustomEnchantedBookItem || original.call(instance, item); |
| 34 | + } |
| 35 | + |
| 36 | + @WrapOperation(method = "enchant", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z")) |
| 37 | + private static boolean allowEnchantingCustomBookItems(ItemStack instance, Item item, Operation<Boolean> original) { |
| 38 | + return instance.getItem() instanceof CustomBookItem || original.call(instance, item); |
| 39 | + } |
| 40 | + |
25 | 41 | @WrapOperation(method = "getPossibleEntries", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z")) |
26 | 42 | private static boolean addCustomBooks(ItemStack stack, Item item, Operation<Boolean> operation, @Share("type") LocalRef<EnchantmentType> type) { |
27 | 43 | type.set(stack.getItem() instanceof CustomBookItem book ? book.getType() : EnchantmentType.DEFAULT); |
|
0 commit comments