From feb7fb43fcee22ca51ca925bba39b4965835aa60 Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Mon, 24 Jul 2023 15:55:06 +0800 Subject: [PATCH] Bow infinity fix --- ...004-Leaves-Server-Config-And-Command.patch | 9 +++++++-- patches/server/0113-Bow-infinity-fix.patch | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 patches/server/0113-Bow-infinity-fix.patch diff --git a/patches/server/0004-Leaves-Server-Config-And-Command.patch b/patches/server/0004-Leaves-Server-Config-And-Command.patch index 27005db0..0728d330 100644 --- a/patches/server/0004-Leaves-Server-Config-And-Command.patch +++ b/patches/server/0004-Leaves-Server-Config-And-Command.patch @@ -128,10 +128,10 @@ index 35d2da9d91dcdd89de7c0f4af028fd182376ea8d..d73482fb1e71fe2951e96ae0593de268 .withRequiredArg() diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..dd6c1d304914b9387da4b741707878ee1fe38935 +index 0000000000000000000000000000000000000000..f0424eba1d6e01c13497a15c858c4e90ae1a85a5 --- /dev/null +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -0,0 +1,946 @@ +@@ -0,0 +1,951 @@ +package top.leavesmc.leaves; + +import com.destroystokyo.paper.util.SneakyThrow; @@ -903,6 +903,11 @@ index 0000000000000000000000000000000000000000..dd6c1d304914b9387da4b741707878ee + avoidAnvilTooExpensive = getBoolean("settings.modify.avoid-anvil-too-expensive", avoidAnvilTooExpensive); + } + ++ public static boolean bowInfinityFix = false; ++ private static void bowInfinityFix() { ++ bowInfinityFix = getBoolean("settings.modify.bow-infinity-fix", bowInfinityFix); ++ } ++ + public static final class WorldConfig { + + public final String worldName; diff --git a/patches/server/0113-Bow-infinity-fix.patch b/patches/server/0113-Bow-infinity-fix.patch new file mode 100644 index 00000000..e63ffcf6 --- /dev/null +++ b/patches/server/0113-Bow-infinity-fix.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Mon, 24 Jul 2023 15:54:18 +0800 +Subject: [PATCH] Bow infinity fix + + +diff --git a/src/main/java/net/minecraft/world/item/BowItem.java b/src/main/java/net/minecraft/world/item/BowItem.java +index 08d597db1a5345a343777a01427655e6bf2c926b..d4127e4b437960670d5c91179a726b433659b317 100644 +--- a/src/main/java/net/minecraft/world/item/BowItem.java ++++ b/src/main/java/net/minecraft/world/item/BowItem.java +@@ -130,7 +130,7 @@ public class BowItem extends ProjectileWeaponItem implements Vanishable { + @Override + public InteractionResultHolder use(Level world, Player user, InteractionHand hand) { + ItemStack itemstack = user.getItemInHand(hand); +- boolean flag = !user.getProjectile(itemstack).isEmpty(); ++ boolean flag = !user.getProjectile(itemstack).isEmpty() || (top.leavesmc.leaves.LeavesConfig.bowInfinityFix && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.INFINITY_ARROWS, itemstack) > 0); + + if (!user.getAbilities().instabuild && !flag) { + return InteractionResultHolder.fail(itemstack);