mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fixed carry ability not showing on the first page for alicorns
This commit is contained in:
parent
0f70bec9bc
commit
132980d4fe
1 changed files with 11 additions and 3 deletions
|
@ -3,8 +3,11 @@ package com.minelittlepony.unicopia.ability;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
|
@ -204,11 +207,16 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
|||
|
||||
public Optional<Ability<?>> getAbility(long page) {
|
||||
Race race = player.getSpecies();
|
||||
return Abilities.BY_SLOT.computeIfAbsent(slot, c -> Collections.emptySet())
|
||||
List<Ability<?>> found = Abilities.BY_SLOT.computeIfAbsent(slot, c -> Collections.emptySet())
|
||||
.stream()
|
||||
.filter(a -> a.canUse(race))
|
||||
.skip(page)
|
||||
.findFirst();
|
||||
.collect(Collectors.toList());
|
||||
if (found.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
page = Math.min(found.size() - 1, page);
|
||||
|
||||
return Optional.ofNullable(found.get((int)page));
|
||||
}
|
||||
|
||||
public long getMaxPage() {
|
||||
|
|
Loading…
Reference in a new issue