From 65f4ce05ac27c6b11e871ce1fd49d3980a7976ec Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 25 Jun 2020 10:00:00 +1000 Subject: [PATCH] SPIGOT-2106, SPIGOT-3942: Improve collidable API By: Phoenix616 --- .../java/org/bukkit/entity/LivingEntity.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java index 203d135f156..8744f2e5fdf 100644 --- a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java @@ -3,6 +3,7 @@ package org.bukkit.entity; import java.util.Collection; import java.util.List; import java.util.Set; +import java.util.UUID; import org.bukkit.FluidCollisionMode; import org.bukkit.Location; import org.bukkit.Material; @@ -486,11 +487,10 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource public void swingOffHand(); /** - * Set if this entity will be subject to collisions other entities. + * Set if this entity will be subject to collisions with other entities. *

- * Note that collisions are bidirectional, so this method would need to be - * set to false on both the collidee and the collidant to ensure no - * collisions take place. + * Exemptions to this rule can be managed with + * {@link #getCollidableExemptions()} * * @param collidable collision status */ @@ -499,6 +499,9 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource /** * Gets if this entity is subject to collisions with other entities. *

+ * Some entities might be exempted from the collidable rule of this entity. + * Use {@link #getCollidableExemptions()} to get these. + *

* Please note that this method returns only the custom collidable state, * not whether the entity is non-collidable for other reasons such as being * dead. @@ -507,6 +510,24 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource */ boolean isCollidable(); + /** + * Gets a mutable set of UUIDs of the entities which are exempt from the + * entity's collidable rule and which's collision with this entity will + * behave the opposite of it. + *

+ * This set can be modified to add or remove exemptions. + *

+ * For example if collidable is true and an entity is in the exemptions set + * then it will not collide with it. Similarly if collidable is false and an + * entity is in this set then it will still collide with it. + *

+ * Note these exemptions are not (currently) persistent. + * + * @return the collidable exemption set + */ + @NotNull + Set getCollidableExemptions(); + /** * Returns the value of the memory specified. *