Skip to content

Commit

Permalink
support infinity enchantment in theory
Browse files Browse the repository at this point in the history
  • Loading branch information
DerToaster98 committed Jul 17, 2022
1 parent 47a7116 commit 2ab62df
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.dertoaster.crossbowverhaul.item;

import java.util.List;
import java.util.Random;

import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
Expand All @@ -20,7 +19,6 @@
import net.minecraft.world.item.CrossbowItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -116,7 +114,7 @@ public default void modifiedShootProjectile(Level world, LivingEntity shooter, I
}

public default int modifiedGetChargeDuration(ItemStack crossbow) {
int i = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.QUICK_CHARGE, crossbow);
int i = crossbow.getEnchantmentLevel(Enchantments.QUICK_CHARGE);
return i == 0 ? this.getMaxChargeTime() : this.getMaxChargeTime() - this.getChargeTimeReductionPerQuickChargeLevel() * i;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import net.minecraft.world.item.CrossbowItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Vanishable;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;

Expand Down Expand Up @@ -62,9 +61,9 @@ public void releaseUsing(ItemStack weaponItem, Level world, LivingEntity shooter

// Attention: this actually differs from vanilla!
protected boolean tryLoadProjectiles(LivingEntity shooter, ItemStack weaponItem) {
int multishotEnchantLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.MULTISHOT, weaponItem);
int multishotEnchantLevel = weaponItem.getEnchantmentLevel(Enchantments.MULTISHOT);
int actualShotCount = 1 + (2 * multishotEnchantLevel);
boolean flag = shooter instanceof Player && ((Player) shooter).getAbilities().instabuild;
boolean flag = shooter instanceof Player && (((Player) shooter).getAbilities().instabuild || weaponItem.getEnchantmentLevel(Enchantments.INFINITY_ARROWS) > 0);
ItemStack itemstack = shooter.getProjectile(weaponItem);
ItemStack itemStackForAdditionalProjectiles = itemstack.copy();

Expand Down

0 comments on commit 2ab62df

Please sign in to comment.