mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fixed page count not being computed correctly when first joining a world
This commit is contained in:
parent
88279b18b6
commit
209ddbb972
1 changed files with 7 additions and 3 deletions
|
@ -30,7 +30,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
|||
|
||||
@Nullable
|
||||
private Race prevRace;
|
||||
private long maxPage;
|
||||
private long maxPage = -1;
|
||||
|
||||
public AbilityDispatcher(Pony player) {
|
||||
this.player = player;
|
||||
|
@ -39,6 +39,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
|||
public void clear(AbilitySlot slot) {
|
||||
Stat stat = getStat(slot);
|
||||
|
||||
|
||||
if (stat.canSwitchStates()) {
|
||||
stat.setActiveAbility(null);
|
||||
}
|
||||
|
@ -61,9 +62,12 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
|||
}
|
||||
|
||||
public long getMaxPage() {
|
||||
if (prevRace != player.getSpecies()) {
|
||||
if (maxPage < 0 || prevRace != player.getSpecies()) {
|
||||
prevRace = player.getSpecies();
|
||||
maxPage = Math.max(0, stats.values().stream().mapToLong(Stat::getMaxPage).reduce(0, Math::max) - 1);
|
||||
maxPage = 0;
|
||||
for (AbilitySlot slot : AbilitySlot.values()) {
|
||||
maxPage = Math.max(maxPage, getStat(slot).getMaxPage() - 1);
|
||||
}
|
||||
}
|
||||
return maxPage;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue