MC Dungeons Weapons

MC Dungeons Weapons

8M Downloads

Bows break compatibility with Infinity Mixin

BrekiTomasson opened this issue ยท 2 comments

commented

I've got a method in one of my mods that looks like this:

@Mixin(BowItem.class)
public class InfinityBowArrowMixin {
    @Inject(at = @At("HEAD"), cancellable = true, method = "use(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/TypedActionResult;")
    private void use(World world, PlayerEntity player, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> ci) {
        ItemStack stack = player.getStackInHand(hand);

        if (EnchantmentHelper.getLevel(Enchantments.INFINITY, stack) > 0) {
            player.setCurrentHand(hand);
            ci.setReturnValue(TypedActionResult.success(stack));
        }

    }
}

Essentially, this means that if a bow has the Infinity enchantment applied, the bow will be able to fire without the need for an arrow in your inventory. However, due to the way you have implemented Bows in MC Dungeons Weapons, this does not work with those weapons.

Any chance you could look into the code for your bows to see if there is any way to make them compatible with this mixin?

commented

I can take a look and see if I cannot get the two to be compatible

commented

It took be a while to figure it out, but I finally think that I got the bows working with this mixin :D