Files
Purpur/patches/unapplied-server/0093-Infinity-bow-settings.patch
2024-10-25 18:36:30 -07:00

48 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
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<ItemStack> 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 18faf8ef7c09b72849502a9e3b880d62bcc50a3f..0abf6598e8bf4ac59ea4387ee07d4de68032076b 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -135,6 +135,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<Item> itemImmuneToCactus = new ArrayList<>();
public List<Item> itemImmuneToExplosion = new ArrayList<>();
public List<Item> itemImmuneToFire = new ArrayList<>();