diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 2bda39be87..7c2a39be0a 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -1408,16 +1408,6 @@ public final class Keys { */ public static final Key>> INFINIBURN = Keys.key(ResourceKey.sponge("infiniburn"), new TypeToken>() {}); - /** - * Whether an {@link Item} will not despawn for an infinite time. - */ - public static final Key> INFINITE_DESPAWN_DELAY = Keys.key(ResourceKey.sponge("infinite_despawn_delay"), Boolean.class); - - /** - * Whether an {@link Item} has an infinite pickup delay. - */ - public static final Key> INFINITE_PICKUP_DELAY = Keys.key(ResourceKey.sponge("infinite_pickup_delay"), Boolean.class); - /** * Whether a world of a {@link ServerWorldProperties} was initialized. */ @@ -2087,8 +2077,7 @@ public final class Keys { *

When this value hits 0 or lower, the Vex will receive damage and * then the value will set back to 20 until the Vex dies.

* - *

If the Vex was summoned by a player, this value will be pegged at 0 - * and the Vex will not take any damage.

+ *

If the Vex was summoned by a player, this value will be {@link Ticks#infinite()}

*/ public static final Key> LIFE_TICKS = Keys.key(ResourceKey.sponge("life_ticks"), Ticks.class); diff --git a/src/main/java/org/spongepowered/api/entity/Item.java b/src/main/java/org/spongepowered/api/entity/Item.java index 0954f1b523..e159ce697d 100644 --- a/src/main/java/org/spongepowered/api/entity/Item.java +++ b/src/main/java/org/spongepowered/api/entity/Item.java @@ -52,24 +52,6 @@ default Value.Mutable despawnDelay() { return this.requireValue(Keys.DESPAWN_DELAY).asMutable(); } - /** - * {@link Keys#INFINITE_DESPAWN_DELAY} - * - * @return Whether the item will not despawn for an infinite time - */ - default Value.Mutable infiniteDespawnDelay() { - return this.requireValue(Keys.INFINITE_DESPAWN_DELAY).asMutable(); - } - - /** - * {@link Keys#INFINITE_PICKUP_DELAY} - * - * @return Whether the item has an infinite pickup delay - */ - default Value.Mutable infinitePickupDelay() { - return this.requireValue(Keys.INFINITE_PICKUP_DELAY).asMutable(); - } - /** * {@link Keys#PICKUP_DELAY} * diff --git a/src/main/java/org/spongepowered/api/scheduler/ScheduledUpdateList.java b/src/main/java/org/spongepowered/api/scheduler/ScheduledUpdateList.java index f5259d1a8f..90d76b3870 100644 --- a/src/main/java/org/spongepowered/api/scheduler/ScheduledUpdateList.java +++ b/src/main/java/org/spongepowered/api/scheduler/ScheduledUpdateList.java @@ -196,6 +196,7 @@ default ScheduledUpdate schedule( * @param ticks The delay, in {@link Ticks} * @param priority The priority of the scheduled update * @return The scheduled update + * @throws IllegalArgumentException if the delay is infinite */ default ScheduledUpdate schedule( final int x, final int y, final int z, final T target, final Ticks ticks, final DefaultedRegistryReference priority) { @@ -210,6 +211,7 @@ default ScheduledUpdate schedule( * @param target The target * @param delay The delay * @return The scheduled update + * @throws IllegalArgumentException if the delay is infinite */ default ScheduledUpdate schedule(int x, int y, int z, final T target, final Ticks delay) { return this.schedule(x, y, z, target, delay, TaskPriorities.NORMAL.get()); @@ -221,6 +223,7 @@ default ScheduledUpdate schedule(int x, int y, int z, final T target, final T * @param target The target * @param delay The delay * @return The scheduled update + * @throws IllegalArgumentException if the delay is infinite */ default ScheduledUpdate schedule(final Vector3i pos, final T target, final Ticks delay) { return this.schedule(pos.x(), pos.y(), pos.z(), target, delay, TaskPriorities.NORMAL.get()); @@ -233,6 +236,7 @@ default ScheduledUpdate schedule(final Vector3i pos, final T target, final Ti * @param delay The delay * @param priority The priority of the scheduled update * @return The scheduled update + * @throws IllegalArgumentException if the delay is infinite */ default ScheduledUpdate schedule(final Vector3i pos, final T target, final Ticks delay, final TaskPriority priority) { return this.schedule(pos.x(), pos.y(), pos.z(), target, delay, priority); @@ -263,6 +267,7 @@ default ScheduledUpdate schedule(final int x, final int y, final int z, final * @param delay The delay, in {@link Ticks} * @param priority The priority of the scheduled update * @return The scheduled update + * @throws IllegalArgumentException if the delay is infinite */ ScheduledUpdate schedule(int x, int y, int z, T target, Ticks delay, TaskPriority priority); diff --git a/src/main/java/org/spongepowered/api/scheduler/Task.java b/src/main/java/org/spongepowered/api/scheduler/Task.java index fdae6a5694..6c7e3c71e3 100644 --- a/src/main/java/org/spongepowered/api/scheduler/Task.java +++ b/src/main/java/org/spongepowered/api/scheduler/Task.java @@ -126,7 +126,7 @@ default Builder delay(final long delay, final TimeUnit unit) { * * @param ticks The delay in ticks * @return This builder, for chaining - * @throws IllegalArgumentException If the delay is below 0 + * @throws IllegalArgumentException If the delay is below 0 or infinite */ Builder delay(final Ticks ticks); @@ -203,7 +203,7 @@ default Builder interval(final long interval, final TimeUnit unit) { * * @param ticks The {@link Ticks} between runs. * @return This builder, for chaining - * @throws IllegalArgumentException If the interval is below 0 + * @throws IllegalArgumentException If the interval is below 0 or infinite */ Builder interval(final Ticks ticks); diff --git a/src/main/java/org/spongepowered/api/util/MinecraftDayTime.java b/src/main/java/org/spongepowered/api/util/MinecraftDayTime.java index 54517a6263..7d3c301db4 100644 --- a/src/main/java/org/spongepowered/api/util/MinecraftDayTime.java +++ b/src/main/java/org/spongepowered/api/util/MinecraftDayTime.java @@ -131,7 +131,7 @@ static MinecraftDayTime of(final int day, final int hours, final int minutes) { * @param engine The {@link Engine} to calculate the time for. * @param ticks The {@link Ticks} since the Minecraft Epoch. * @return The {@link MinecraftDayTime} - * @throws IllegalArgumentException if the tick count is negative + * @throws IllegalArgumentException if the tick count is negative or infinite */ static MinecraftDayTime of(final Engine engine, final Ticks ticks) { return Sponge.game().factoryProvider().provide(MinecraftDayTime.Factory.class).of(engine, ticks); @@ -164,6 +164,7 @@ static MinecraftDayTime of(final Engine engine, final Ticks ticks) { * * @param ticks The {@link Ticks} to add. * @return A new {@link MinecraftDayTime} + * @throws IllegalArgumentException if the ticks is infinite */ MinecraftDayTime add(final Ticks ticks); @@ -185,7 +186,7 @@ static MinecraftDayTime of(final Engine engine, final Ticks ticks) { * * @param ticks The {@link Ticks} to subtract. * @return A new {@link MinecraftDayTime} - * @throws IllegalArgumentException if the result would be a negative time. + * @throws IllegalArgumentException if ticks is infinite or the result would be a negative time. */ MinecraftDayTime subtract(final Ticks ticks); @@ -272,7 +273,7 @@ interface Factory { * @param engine The {@link Engine} to calculate the time for. * @param ticks The {@link Ticks} since the Minecraft Epoch. * @return The {@link MinecraftDayTime} - * @throws IllegalArgumentException if the tick count is negative + * @throws IllegalArgumentException if the tick count is negative or infinite */ MinecraftDayTime of(Engine engine, Ticks ticks); diff --git a/src/main/java/org/spongepowered/api/util/Ticks.java b/src/main/java/org/spongepowered/api/util/Ticks.java index 53fe5b3476..a0f8634c90 100644 --- a/src/main/java/org/spongepowered/api/util/Ticks.java +++ b/src/main/java/org/spongepowered/api/util/Ticks.java @@ -123,6 +123,15 @@ static Ticks minecraftDay() { return Sponge.game().factoryProvider().provide(Ticks.Factory.class).minecraftDay(); } + /** + * Represents infinite ticks. + * + * @return A {@link Ticks} + */ + static Ticks infinite() { + return Sponge.game().factoryProvider().provide(Ticks.Factory.class).infinite(); + } + /** * Returns a {@link Ticks} that represents the supplied number of ticks. * @@ -295,6 +304,7 @@ static Ticks ofMinecraftDays(final Engine engine, final long days) { * * @param engine The {@link Engine} to get the {@link Duration} for * @return The effective {@link Duration}. + * @throws IllegalStateException If {@link Ticks#isInfinite()} is true. */ Duration expectedDuration(final Engine engine); @@ -306,6 +316,7 @@ static Ticks ofMinecraftDays(final Engine engine, final long days) { * session.

* * @return The number of ticks that this represents. + * @throws IllegalStateException If {@link Ticks#isInfinite()} is true. */ long ticks(); @@ -321,6 +332,7 @@ static Ticks ofMinecraftDays(final Engine engine, final long days) { * * @param engine The {@link Engine} to calculate the duration for. * @return The approximate number of in-game seconds + * @throws IllegalStateException If {@link Ticks#isInfinite()} is true. */ long minecraftSeconds(final Engine engine); @@ -333,9 +345,19 @@ static Ticks ofMinecraftDays(final Engine engine, final long days) { * * @param engine The {@link Engine} to calculate the duration for. * @return A duration representing the in game time. + * @throws IllegalStateException If {@link Ticks#isInfinite()} is true. */ Duration minecraftDayTimeDuration(final Engine engine); + /** + * Whether this represents infinite ticks. + * + *

When this is true all other methods throw {@link IllegalStateException}.

+ * + * @return True if this represents infinite ticks. + */ + boolean isInfinite(); + /** * Produces {@link Ticks} objects. */ @@ -408,6 +430,13 @@ interface Factory { */ Ticks minecraftDay(); + /** + * @see Ticks#infinite() + * + * @return A {@link Ticks} + */ + Ticks infinite(); + } } diff --git a/src/main/java/org/spongepowered/api/world/chunk/Chunk.java b/src/main/java/org/spongepowered/api/world/chunk/Chunk.java index b3ef032d8e..8d675f5af5 100644 --- a/src/main/java/org/spongepowered/api/world/chunk/Chunk.java +++ b/src/main/java/org/spongepowered/api/world/chunk/Chunk.java @@ -120,6 +120,7 @@ public interface Chunk

> extends * * @see #inhabitedTime() * @param newInhabitedTime The {@link Ticks} to set this value to + * @throws IllegalArgumentException If the inhabited time is infinite */ void setInhabitedTime(Ticks newInhabitedTime); diff --git a/src/main/java/org/spongepowered/api/world/server/ServerLocation.java b/src/main/java/org/spongepowered/api/world/server/ServerLocation.java index da201f71f6..dd1b726b6c 100644 --- a/src/main/java/org/spongepowered/api/world/server/ServerLocation.java +++ b/src/main/java/org/spongepowered/api/world/server/ServerLocation.java @@ -268,6 +268,7 @@ static ServerLocation of(final ResourceKey worldKey, final Vector3i position) { * should be processed * @param priority The priority of the scheduled update * @return The newly created scheduled update + * @throws IllegalArgumentException if the delay is infinite */ ScheduledUpdate scheduleBlockUpdate(Ticks delay, TaskPriority priority); @@ -287,6 +288,7 @@ static ServerLocation of(final ResourceKey worldKey, final Vector3i position) { * @param delay The delay, in {@link Ticks}, before the scheduled update * should be processed * @return The newly created scheduled update + * @throws IllegalArgumentException if the delay is infinite */ ScheduledUpdate scheduleBlockUpdate(Ticks delay); @@ -339,6 +341,7 @@ static ServerLocation of(final ResourceKey worldKey, final Vector3i position) { * @param ticks The delay, in {@link Ticks}, before the scheduled update * should be processed * @return The newly created scheduled update + * @throws IllegalArgumentException if the delay is infinite */ ScheduledUpdate scheduleFluidUpdate(Ticks ticks); @@ -349,6 +352,7 @@ static ServerLocation of(final ResourceKey worldKey, final Vector3i position) { * should be processed * @param priority The priority of the scheduled update * @return The newly created scheduled update + * @throws IllegalArgumentException if the delay is infinite */ ScheduledUpdate scheduleFluidUpdate(Ticks ticks, TaskPriority priority);