Skip to content

Commit 2ab62df

Browse files
committed
support infinity enchantment in theory
1 parent 47a7116 commit 2ab62df

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/main/java/de/dertoaster/crossbowverhaul/item/IModifiedCrossbowMethod.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package de.dertoaster.crossbowverhaul.item;
22

33
import java.util.List;
4-
import java.util.Random;
54

65
import com.mojang.math.Quaternion;
76
import com.mojang.math.Vector3f;
@@ -20,7 +19,6 @@
2019
import net.minecraft.world.item.CrossbowItem;
2120
import net.minecraft.world.item.ItemStack;
2221
import net.minecraft.world.item.Items;
23-
import net.minecraft.world.item.enchantment.EnchantmentHelper;
2422
import net.minecraft.world.item.enchantment.Enchantments;
2523
import net.minecraft.world.level.Level;
2624
import net.minecraft.world.phys.Vec3;
@@ -116,7 +114,7 @@ public default void modifiedShootProjectile(Level world, LivingEntity shooter, I
116114
}
117115

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

src/main/java/de/dertoaster/crossbowverhaul/item/ItemCrossbow.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import net.minecraft.world.item.CrossbowItem;
1515
import net.minecraft.world.item.ItemStack;
1616
import net.minecraft.world.item.Vanishable;
17-
import net.minecraft.world.item.enchantment.EnchantmentHelper;
1817
import net.minecraft.world.item.enchantment.Enchantments;
1918
import net.minecraft.world.level.Level;
2019

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

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

0 commit comments

Comments
 (0)