Skip to content

Commit

Permalink
fix crossbow frugality enchantment
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Jul 6, 2024
1 parent 3a89903 commit 6bc3d2d
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ public int getUseDuration(@NotNull ItemStack crossbow) {
public InteractionResultHolder<ItemStack> use(@NotNull Level p_77659_1_, Player p_77659_2_, @NotNull InteractionHand p_77659_3_) {
ItemStack itemstack = p_77659_2_.getItemInHand(p_77659_3_);
if (isCharged(itemstack)) {
List<ItemStack> originalProjectile = CrossbowItemMixin.getChargedProjectiles(itemstack);
performShootingMod(p_77659_1_, p_77659_2_, p_77659_3_, itemstack, getShootingPowerMod(itemstack), 1.0F); //call modded shoot function with shooting power
setUncharged(p_77659_2_, itemstack); //set uncharged with extra steps
setUncharged(p_77659_2_, itemstack, originalProjectile); //set uncharged with extra steps
return InteractionResultHolder.consume(itemstack);
} else if (!p_77659_2_.getProjectile(itemstack).isEmpty()) {
if (!isCharged(itemstack)) {
Expand Down Expand Up @@ -238,9 +239,10 @@ public int getChargeDurationMod(ItemStack crossbow) {
return i == 0 ? this.chargeTime : this.chargeTime - 2 * i;
}

protected void setUncharged(Player player, ItemStack stack) {
protected void setUncharged(Player player, ItemStack stack, List<ItemStack> originalProjectile) {
int frugal = isFrugal(stack);
if (frugal > 0 && player.getRandom().nextInt(Math.max(2, 4- frugal)) == 0) {
originalProjectile.forEach(ammo -> CrossbowItemMixin.addChargedProjectile(stack, ammo));
return;
}
setCharged(stack, false);
Expand Down

0 comments on commit 6bc3d2d

Please sign in to comment.