![[Fabric] Progressive Archery](https://media.forgecdn.net/avatars/thumbnails/812/965/256/256/638186903615152097.png)
Current mixin structure overriding changes by other mods
DaFuqs opened this issue ยท 3 comments
The Problem
Other mods that add their own enchantable items are not enchantable when Progressive Archery is installed.
Depending on mod load order, this can also lead to crashes and random behavior on startup, depending on which mod loads first.
The Cause
Progressive Archery's current mixins are written as overrides, like this one:
While this works with Progressive Archery alone, this breaks every other mod that wants to add changes of their own, like making their own items enchantable by that enchantment, too, since the changes in the base class get overridden.
The Solution
The mixins should be written using an @Inject
, like described in the fabric wiki, setting
the return value to true, if Progressive Archery's case matches. Your final code could look like this:
@Inject(method= "isAcceptableItem(Lnet/minecraft/item/ItemStack;)Z", at=@At("HEAD"), cancellable = true)
private void isAcceptableItem(ItemStack stack, CallbackInfoReturnable<Boolean> callbackInfoReturnable) {
if (stack.getItem() instanceof RangedWeaponItem) {
callbackInfoReturnable.setReturnValue(true);
}
}
this will always return true
, if the stack is of a RangedWeaponItem
and will still preserve vanilla and other mods behavior
Both SASSOT and Progressive Archery are having the same problem with mixins too in 1.21.
Hello, thank you all for writing in.
- Fortunately, the specific example in the first post is no longer an issue, thanks to significant changes in Item/Enchantment implementation in vanilla Minecraft 1.20.5-. Specifically
PowerEnchantment
is no longer a separate class extendingEnchantment
, and Enchantments have been structurally overhauled. The latest version of Progressive Archery therefore should have had this particular issue solved automatically; Progressive Archery currently does not change the vanilla .json file forminecraft:power
. - @DaFuqs I appreciate the detailed post and concern. Of course, I have been aware of and have used injectors as described since the mod was first published -- I have indeed been cautious of cross-mod compatibility. As mentioned in item 1, the particular exmaple raised is luckily no longer an issue thanks to vanilla updates. If there are any other specific conflicts as such, please feel free to report them as individual dedicated Issues. Suggestions on the general structure of the mod are welcome, it's just that this time it was frankly redundant on my end, and specific reports are far more helpful on a case-by-case basis.
- @makumaku1974 Would you please open a more specific Issue dedicated to the specific problem? If there are specific conflicts with another mod, please provide the details of that conflict with a log/crash report where available. Also, please do so separately for issues from Progressive Archery and issues from SASSOT.
On that note, I will close this Issue thread here.