From 16a083735ab7ef150e01642cae5643dc29f18c7c Mon Sep 17 00:00:00 2001 From: Parker Hawke Date: Fri, 23 Jun 2023 09:58:54 +1000 Subject: [PATCH] #876: Add missing Raider API and 'no action ticks' --- .../java/org/bukkit/entity/LivingEntity.java | 24 +++++++ src/main/java/org/bukkit/entity/Raider.java | 70 +++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java index 2b816f0e..b42503a6 100644 --- a/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java @@ -271,6 +271,30 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource */ public void setNoDamageTicks(int ticks); + /** + * Get the ticks that this entity has performed no action. + *

+ * The details of what "no action ticks" entails varies from entity to entity + * and cannot be specifically defined. Some examples include squid using this + * value to determine when to swim, raiders for when they are to be expelled + * from raids, or creatures (such as withers) as a requirement to be despawned. + * + * @return amount of no action ticks + */ + public int getNoActionTicks(); + + /** + * Set the ticks that this entity has performed no action. + *

+ * The details of what "no action ticks" entails varies from entity to entity + * and cannot be specifically defined. Some examples include squid using this + * value to determine when to swim, raiders for when they are to be expelled + * from raids, or creatures (such as withers) as a requirement to be despawned. + * + * @param ticks amount of no action ticks + */ + public void setNoActionTicks(int ticks); + /** * Gets the player identified as the killer of the living entity. *

diff --git a/src/main/java/org/bukkit/entity/Raider.java b/src/main/java/org/bukkit/entity/Raider.java index 987f9b08..9f8c5a38 100644 --- a/src/main/java/org/bukkit/entity/Raider.java +++ b/src/main/java/org/bukkit/entity/Raider.java @@ -1,5 +1,6 @@ package org.bukkit.entity; +import org.bukkit.Raid; import org.bukkit.Sound; import org.bukkit.block.Block; import org.jetbrains.annotations.NotNull; @@ -7,6 +8,35 @@ import org.jetbrains.annotations.Nullable; public interface Raider extends Monster { + /** + * Set the {@link Raid} that this raider is participating in. + * + * @param raid the raid to set + */ + void setRaid(@Nullable Raid raid); + + /** + * Get the {@link Raid} that this raider is participating in, if any. + * + * @return the raid, or null if not participating in a raid + */ + @Nullable + Raid getRaid(); + + /** + * Get the raid wave that this raider spawned as part of. + * + * @return the raid wave, or 0 if not participating in a raid + */ + int getWave(); + + /** + * Set the raid wave that this raider was spawned as part of. + * + * @param wave the raid wave to set. Must be >= 0 + */ + void setWave(int wave); + /** * Gets the block the raider is targeting to patrol. * @@ -50,6 +80,46 @@ public interface Raider extends Monster { */ void setCanJoinRaid(boolean join); + /** + * Get the amount of ticks that this mob has exited the bounds of a village + * as a raid participant. + *

+ * This value is increased only when the mob has had no action for 2,400 ticks + * (according to {@link #getNoActionTicks()}). Once both the no action ticks have + * reached that value and the ticks outside a raid exceeds 30, the mob will be + * expelled from the raid. + * + * @return the ticks outside of a raid + */ + int getTicksOutsideRaid(); + + /** + * Set the amount of ticks that this mob has exited the bounds of a village + * as a raid participant. + *

+ * This value is considered only when the mob has had no action for 2,400 ticks + * (according to {@link #getNoActionTicks()}). Once both the no action ticks have + * reached that value and the ticks outside a raid exceeds 30, the mob will be + * expelled from the raid. + * + * @param ticks the ticks outside of a raid + */ + void setTicksOutsideRaid(int ticks); + + /** + * Check whether or not this raider is celebrating a raid victory. + * + * @return true if celebrating, false otherwise + */ + boolean isCelebrating(); + + /** + * Set whether or not this mob is celebrating a raid victory. + * + * @param celebrating whether or not to celebrate + */ + void setCelebrating(boolean celebrating); + /** * Get the {@link Sound} this entity will play when celebrating. *