Skip to content

Commit 17d832f

Browse files
BillyGalbreathgranny
authored andcommitted
Infinity bow settings
1 parent d274f1e commit 17d832f

3 files changed

Lines changed: 28 additions & 47 deletions

File tree

patches/server/0091-Infinity-bow-settings.patch

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--- a/net/minecraft/world/item/BowItem.java
2+
+++ b/net/minecraft/world/item/BowItem.java
3+
@@ -28,6 +_,11 @@
4+
return false;
5+
} else {
6+
ItemStack projectile = player.getProjectile(stack);
7+
+ // Purpur start - Infinity bow settings
8+
+ if (level.purpurConfig.infinityWorksWithoutArrows && projectile.isEmpty() && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, stack) > 0) {
9+
+ projectile = new ItemStack(Items.ARROW);
10+
+ }
11+
+ // Purpur end - Infinity bow settings
12+
if (projectile.isEmpty()) {
13+
return false;
14+
} else {
15+
@@ -89,7 +_,7 @@
16+
public InteractionResult use(Level level, Player player, InteractionHand hand) {
17+
ItemStack itemInHand = player.getItemInHand(hand);
18+
boolean flag = !player.getProjectile(itemInHand).isEmpty();
19+
- if (!player.hasInfiniteMaterials() && !flag) {
20+
+ if (!player.hasInfiniteMaterials() && !flag && !(level.purpurConfig.infinityWorksWithoutArrows && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, itemInHand) > 0)) { // Purpur - Infinity bow settings
21+
return InteractionResult.FAIL;
22+
} else {
23+
player.startUsingItem(hand);

purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ private void entitySettings() {
126126
entityLifeSpan = getInt("gameplay-mechanics.entity-lifespan", entityLifeSpan);
127127
}
128128

129+
public boolean infinityWorksWithoutArrows = false;
130+
private void infinityArrowsSettings() {
131+
infinityWorksWithoutArrows = getBoolean("gameplay-mechanics.infinity-bow.works-without-arrows", infinityWorksWithoutArrows);
132+
}
133+
129134
public List<Item> itemImmuneToCactus = new ArrayList<>();
130135
public List<Item> itemImmuneToExplosion = new ArrayList<>();
131136
public List<Item> itemImmuneToFire = new ArrayList<>();

0 commit comments

Comments
 (0)