PaperMC/Spigot-API-Patches/0033-Arrow-pickup-rule-API.patch
Shane Freeder b5184575e6
limit the range at which we'll consider an attackable target
This patch aims to ensure that MCP World#getNearestAttackablePlayer
will not trigger chunk loads due to PathfinderGoalNearestAttackableTarget
performing a ray trace operation by pre-checking the maximum limit;

Given that the implementation shows that the limit should only ever
decrease when set, allowing us to skip further checks earlier on
when looking for an attackable entity
2018-11-26 13:23:49 +00:00

52 lines
1.6 KiB
Diff

From 5639eb8d022329ed99bb9f92f8dbe416d5e4f377 Mon Sep 17 00:00:00 2001
From: Jedediah Smith <jedediah@silencegreys.com>
Date: Fri, 4 Mar 2016 03:13:18 -0500
Subject: [PATCH] Arrow pickup rule API
diff --git a/src/main/java/org/bukkit/entity/Arrow.java b/src/main/java/org/bukkit/entity/Arrow.java
index 99814eee..34dde443 100644
--- a/src/main/java/org/bukkit/entity/Arrow.java
+++ b/src/main/java/org/bukkit/entity/Arrow.java
@@ -108,4 +108,38 @@ public interface Arrow extends Projectile {
@Override
Spigot spigot();
// Spigot end
+
+ // Paper start
+ /**
+ * Gets the {@link PickupRule} for this arrow.
+ *
+ * <p>This is generally {@link PickupRule#ALLOWED} only if the arrow was
+ * <b>not</b> fired from a bow with the infinity enchantment.</p>
+ *
+ * @return The pickup rule
+ * @deprecated Use {@link Arrow#getPickupStatus()} as an upstream compatible replacement for this function
+ */
+ @Deprecated
+ default PickupRule getPickupRule() {
+ return PickupRule.valueOf(this.getPickupStatus().name());
+ }
+
+ /**
+ * Set the rule for which players can pickup this arrow as an item.
+ *
+ * @param rule The pickup rule
+ * @deprecated Use {@link Arrow#setPickupStatus(PickupStatus)} with {@link PickupStatus} as an upstream compatible replacement for this function
+ */
+ @Deprecated
+ default void setPickupRule(PickupRule rule) {
+ this.setPickupStatus(PickupStatus.valueOf(rule.name()));
+ }
+
+ @Deprecated
+ enum PickupRule {
+ DISALLOWED,
+ ALLOWED,
+ CREATIVE_ONLY;
+ }
+ // Paper end
}
--
2.19.1