From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Sun, 4 Oct 2020 19:08:53 -0500 Subject: [PATCH] Infinity bow settings diff --git a/src/main/java/net/minecraft/world/item/BowItem.java b/src/main/java/net/minecraft/world/item/BowItem.java index 6eb5c0f23d9dc61e69ad5ad493c89602a9dcd4b5..4db2032178471860baddc6b669c9a4f8cffd084b 100644 --- a/src/main/java/net/minecraft/world/item/BowItem.java +++ b/src/main/java/net/minecraft/world/item/BowItem.java @@ -26,6 +26,11 @@ public class BowItem extends ProjectileWeaponItem { public void releaseUsing(ItemStack stack, Level world, LivingEntity user, int remainingUseTicks) { if (user instanceof Player player) { ItemStack itemStack = player.getProjectile(stack); + // Purpur start + if (world.purpurConfig.infinityWorksWithoutArrows && itemStack.isEmpty() && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, stack) > 0) { + itemStack = new ItemStack(Items.ARROW); + } + // Purpur end if (!itemStack.isEmpty()) { int i = this.getUseDuration(stack, user) - remainingUseTicks; float f = getPowerForTime(i); @@ -82,7 +87,7 @@ public class BowItem extends ProjectileWeaponItem { public InteractionResultHolder use(Level world, Player user, InteractionHand hand) { ItemStack itemStack = user.getItemInHand(hand); boolean bl = !user.getProjectile(itemStack).isEmpty(); - if (!user.hasInfiniteMaterials() && !bl) { + if (!user.hasInfiniteMaterials() && !bl && !(world.purpurConfig.infinityWorksWithoutArrows && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, itemStack) > 0)) { // Purpur return InteractionResultHolder.fail(itemStack); } else { user.startUsingItem(hand); diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index a0e89374b94852352400d5089052433b6de0fd92..85e16939a1ac27037b1959e4fc1ec57324a7c11e 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -137,6 +137,11 @@ public class PurpurWorldConfig { entityLifeSpan = getInt("gameplay-mechanics.entity-lifespan", entityLifeSpan); } + public boolean infinityWorksWithoutArrows = false; + private void infinityArrowsSettings() { + infinityWorksWithoutArrows = getBoolean("gameplay-mechanics.infinity-bow.works-without-arrows", infinityWorksWithoutArrows); + } + public List itemImmuneToCactus = new ArrayList<>(); public List itemImmuneToExplosion = new ArrayList<>(); public List itemImmuneToFire = new ArrayList<>();