Skip to content

Commit 6bf979b

Browse files
committed
Consistently use Ticks where tick based values are used
1 parent c848b1b commit 6bf979b

File tree

9 files changed

+32
-23
lines changed

9 files changed

+32
-23
lines changed

src/main/java/org/spongepowered/api/Server.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.spongepowered.api.scoreboard.Scoreboard;
4343
import org.spongepowered.api.service.ServiceProvider;
4444
import org.spongepowered.api.user.UserManager;
45+
import org.spongepowered.api.util.Ticks;
4546
import org.spongepowered.api.util.locale.LocaleSource;
4647
import org.spongepowered.api.world.difficulty.Difficulty;
4748
import org.spongepowered.api.world.generation.config.WorldGenerationConfig;
@@ -278,7 +279,7 @@ public interface Server extends ForwardingAudience, Engine, LocaleSource {
278279
*
279280
* @return The number of ticks since this server started running
280281
*/
281-
int runningTimeTicks();
282+
Ticks runningTimeTicks();
282283

283284
/**
284285
* Gets the message channel that server-wide messages are sent through.

src/main/java/org/spongepowered/api/entity/ai/goal/builtin/creature/RangedAttackAgainstAgentGoal.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.spongepowered.api.entity.ai.goal.Goal;
3030
import org.spongepowered.api.entity.ai.goal.GoalBuilder;
3131
import org.spongepowered.api.entity.living.Ranger;
32+
import org.spongepowered.api.util.Ticks;
3233

3334
/**
3435
* An {@link Goal} which uses the ranging aspect of the Ranger to attack
@@ -68,7 +69,7 @@ static Builder builder() {
6869
*
6970
* @return The delay in ticks between attempts to attack
7071
*/
71-
int delayBetweenAttacks();
72+
Ticks delayBetweenAttacks();
7273

7374
/**
7475
* The time, in ticks, this {@link Ranger} will wait before attacking
@@ -77,7 +78,7 @@ static Builder builder() {
7778
* @param delay The delay, in ticks
7879
* @return This goal, for chaining
7980
*/
80-
RangedAttackAgainstAgentGoal setDelayBetweenAttacks(int delay);
81+
RangedAttackAgainstAgentGoal setDelayBetweenAttacks(Ticks delay);
8182

8283
/**
8384
* Gets the radius of which the owning {@link Ranger} will attempt to
@@ -101,7 +102,7 @@ interface Builder extends GoalBuilder<Ranger, RangedAttackAgainstAgentGoal, Buil
101102

102103
Builder moveSpeed(double speed);
103104

104-
Builder delayBetweenAttacks(int delay);
105+
Builder delayBetweenAttacks(Ticks delay);
105106

106107
Builder attackRadius(float radius);
107108
}

src/main/java/org/spongepowered/api/entity/living/player/CooldownTracker.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
package org.spongepowered.api.entity.living.player;
2626

2727
import org.spongepowered.api.item.ItemType;
28+
import org.spongepowered.api.util.Ticks;
2829

30+
import java.util.Optional;
2931
import java.util.OptionalDouble;
30-
import java.util.OptionalInt;
3132

3233
/**
3334
* Provides access to the item cooldowns of a {@link Player}.
@@ -51,7 +52,7 @@ public interface CooldownTracker {
5152
* @return The cooldown remaining for this item type in ticks, if not
5253
* on cooldown
5354
*/
54-
OptionalInt cooldown(ItemType type);
55+
Optional<Ticks> cooldown(ItemType type);
5556

5657
/**
5758
* Sets the cooldown for the specified {@link ItemType} for the
@@ -62,7 +63,7 @@ public interface CooldownTracker {
6263
* @return False if setting the cooldown failed, possibly due to the event
6364
* being cancelled
6465
*/
65-
boolean setCooldown(ItemType type, int ticks);
66+
boolean setCooldown(ItemType type, Ticks ticks);
6667

6768
/**
6869
* Resets the cooldown of the specified {@link ItemType} for the

src/main/java/org/spongepowered/api/event/entity/IgniteEntityEvent.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.entity.Entity;
2828
import org.spongepowered.api.event.Cancellable;
2929
import org.spongepowered.api.event.Event;
30+
import org.spongepowered.api.util.Ticks;
3031

3132
/**
3233
* An event that occurs when an entity becomes ignited.
@@ -44,20 +45,20 @@ public interface IgniteEntityEvent extends Event, Cancellable {
4445
* Gets the original amount of fire ticks the entity will remain on fire.
4546
* @return The original fire ticks
4647
*/
47-
int originalFireTicks();
48+
Ticks originalFireTicks();
4849

4950
/**
5051
* Gets the amount of ticks the entity will remain on fire.
5152
*
5253
* @return The amount of ticks the entity will remain on fire
5354
*/
54-
int fireTicks();
55+
Ticks fireTicks();
5556

5657
/**
5758
* Sets the amount of ticks the entity will remain on fire.
5859
*
5960
* @param fireTicks The amount of ticks the entity will remain on fire
6061
*/
61-
void setFireTicks(int fireTicks);
62+
void setFireTicks(Ticks fireTicks);
6263

6364
}

src/main/java/org/spongepowered/api/event/entity/living/player/CooldownEvent.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
import org.spongepowered.api.event.Cancellable;
3030
import org.spongepowered.api.event.Event;
3131
import org.spongepowered.api.item.ItemType;
32+
import org.spongepowered.api.util.Ticks;
3233

34+
import java.util.Optional;
3335
import java.util.OptionalInt;
3436

3537
/**
@@ -64,28 +66,28 @@ interface Set extends CooldownEvent, Cancellable {
6466
*
6567
* @return The cooldown of the item type beforehand
6668
*/
67-
OptionalInt startingCooldown();
69+
Optional<Ticks> startingCooldown();
6870

6971
/**
7072
* Gets the original new set cooldown at the beginning of the event.
7173
*
7274
* @return The originally set cooldown
7375
*/
74-
int originalNewCooldown();
76+
Ticks originalNewCooldown();
7577

7678
/**
7779
* Gets the new cooldown the item type has for the player.
7880
*
7981
* @return The new cooldown of the item type
8082
*/
81-
int newCooldown();
83+
Ticks newCooldown();
8284

8385
/**
8486
* Sets the new cooldown for the item type for the player.
8587
*
8688
* @param ticks The amount of ticks the cooldown should last for
8789
*/
88-
void setNewCooldown(int ticks);
90+
void setNewCooldown(Ticks ticks);
8991

9092
}
9193

src/main/java/org/spongepowered/api/event/item/inventory/UseItemStackEvent.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.spongepowered.api.item.ItemType;
3131
import org.spongepowered.api.item.inventory.ItemStack;
3232
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
33+
import org.spongepowered.api.util.Ticks;
3334

3435
/**
3536
* Fired when an {@link ItemStack} is used.
@@ -41,21 +42,21 @@ public interface UseItemStackEvent extends Event {
4142
*
4243
* @return The original remaining duration
4344
*/
44-
int originalRemainingDuration();
45+
Ticks originalRemainingDuration();
4546

4647
/**
4748
* Gets the remaining duration of {@link ItemStack} in use.
4849
*
4950
* @return The remaining duration
5051
*/
51-
int remainingDuration();
52+
Ticks remainingDuration();
5253

5354
/**
5455
* Sets the remaining duration of {@link ItemStack} in use.
5556
*
5657
* @param duration The remaining duration to set
5758
*/
58-
void setRemainingDuration(int duration);
59+
void setRemainingDuration(Ticks duration);
5960

6061
/**
6162
* Gets the {@link ItemStack} being consumed.

src/main/java/org/spongepowered/api/event/world/ChangeWeatherEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public interface ChangeWeatherEvent extends Event, Cancellable {
5757
* @param type The weather type
5858
* @param duration The custom weather duration
5959
*/
60-
default void setWeather(WeatherType type, Ticks duration) {
60+
default void setWeather(final WeatherType type, final Ticks duration) {
6161
this.weather().setCustom(Weather.of(type, duration));
6262
}
6363
}

src/main/java/org/spongepowered/api/item/recipe/cooking/CookingRecipe.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.spongepowered.api.item.recipe.RecipeType;
3636
import org.spongepowered.api.item.recipe.crafting.Ingredient;
3737
import org.spongepowered.api.util.ResourceKeyedBuilder;
38+
import org.spongepowered.api.util.Ticks;
3839

3940
import java.util.Optional;
4041
import java.util.function.Function;
@@ -87,7 +88,7 @@ static Builder builder() {
8788
*
8889
* @return The cooking time in ticks.
8990
*/
90-
int cookingTime();
91+
Ticks cookingTime();
9192

9293
/**
9394
* Returns the experience of this recipe.
@@ -117,7 +118,7 @@ interface Builder extends ResourceKeyedBuilder<RecipeRegistration, Builder> {
117118
*
118119
* @return This builder, for chaining
119120
*/
120-
default IngredientStep type(Supplier<RecipeType<CookingRecipe>> type) {
121+
default IngredientStep type(final Supplier<RecipeType<CookingRecipe>> type) {
121122
return this.type(type.get());
122123
}
123124

@@ -238,7 +239,7 @@ interface EndStep extends Builder,
238239
*
239240
* @return This builder, for chaining
240241
*/
241-
EndStep cookingTime(int ticks);
242+
EndStep cookingTime(Ticks ticks);
242243

243244
}
244245
}

src/main/java/org/spongepowered/api/world/server/storage/ServerWorldProperties.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.spongepowered.api.entity.living.trader.WanderingTrader;
3434
import org.spongepowered.api.util.Identifiable;
3535
import org.spongepowered.api.util.MinecraftDayTime;
36+
import org.spongepowered.api.util.Ticks;
3637
import org.spongepowered.api.world.SerializationBehavior;
3738
import org.spongepowered.api.world.WorldType;
3839
import org.spongepowered.api.world.difficulty.Difficulty;
@@ -229,14 +230,14 @@ public interface ServerWorldProperties extends WorldProperties, Identifiable, Re
229230
*
230231
* @return The delay, in ticks
231232
*/
232-
int wanderingTraderSpawnDelay();
233+
Ticks wanderingTraderSpawnDelay();
233234

234235
/**
235236
* Sets the delay before a {@link WanderingTrader} will be spawned.
236237
*
237238
* @param delay The delay, in ticks
238239
*/
239-
void setWanderingTraderSpawnDelay(int delay);
240+
void setWanderingTraderSpawnDelay(Ticks delay);
240241

241242
/**
242243
* Gets the chance that a {@link WanderingTrader} will be spawned, as a percentage

0 commit comments

Comments
 (0)